Search in sources :

Example 1 with Sensitive

use of com.bc.pmpheep.back.po.Sensitive in project pmph by BCSquad.

the class SensitiveServiceTest method listTest.

@Test
public void listTest() {
    Sensitive sen = sensitiveService.add(sensitive);
    PageParameter<Sensitive> pageParameter = new PageParameter<>(1, 5);
    Sensitive sensitive = new Sensitive();
    pageParameter.setParameter(sensitive);
    PageResult<Sensitive> pageResult = sensitiveService.list(pageParameter);
    Assert.assertNotNull("获取失败", pageResult.getRows());
}
Also used : Sensitive(com.bc.pmpheep.back.po.Sensitive) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest)

Example 2 with Sensitive

use of com.bc.pmpheep.back.po.Sensitive in project pmph by BCSquad.

the class MigrationPlus method sensitive.

protected void sensitive() {
    Sensitive sensitive = new Sensitive("妈的", 1, "不文明用语", false, false, null, null);
    sensitiveService.add(sensitive);
    Sensitive sensitive1 = new Sensitive("闭嘴", 2, "不礼貌", false, false, null, null);
    sensitiveService.add(sensitive1);
    Sensitive sensitive2 = new Sensitive("死人", 3, null, false, false, null, null);
    sensitiveService.add(sensitive2);
    Sensitive sensitive3 = new Sensitive("王八蛋", 4, "不文明用语", false, false, null, null);
    sensitiveService.add(sensitive3);
    Sensitive sensitive4 = new Sensitive("傻逼", 5, null, false, false, null, null);
    sensitiveService.add(sensitive4);
    Sensitive sensitive5 = new Sensitive("垃圾", 6, "不合适用语", false, false, null, null);
    sensitiveService.add(sensitive5);
    Sensitive sensitive6 = new Sensitive("渣渣", 7, "网络用语", false, true, null, null);
    sensitiveService.add(sensitive6);
    Sensitive sensitive7 = new Sensitive("二", 8, "网络用语", true, false, null, null);
    sensitiveService.add(sensitive7);
    Sensitive sensitive8 = new Sensitive("放屁", 9, "口头用语", true, true, null, null);
    sensitiveService.add(sensitive8);
}
Also used : Sensitive(com.bc.pmpheep.back.po.Sensitive)

Example 3 with Sensitive

use of com.bc.pmpheep.back.po.Sensitive in project pmph by BCSquad.

the class SensitiveController method list.

/**
 * 功能描述:分页查询敏感词
 *
 * @param word
 * @param pageSize
 * @param pageNumber
 * @return
 */
@ResponseBody
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "分页查询敏感词")
@RequestMapping(value = "/list", method = RequestMethod.GET)
public ResponseBean list(String word, Integer pageSize, Integer pageNumber) {
    PageParameter<Sensitive> pageParameter = new PageParameter<>(pageNumber, pageSize);
    Sensitive sensitive = new Sensitive();
    sensitive.setWord(word);
    pageParameter.setParameter(sensitive);
    return new ResponseBean(sensitiveService.list(pageParameter));
}
Also used : Sensitive(com.bc.pmpheep.back.po.Sensitive) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) ResponseBean(com.bc.pmpheep.controller.bean.ResponseBean) LogDetail(com.bc.pmpheep.annotation.LogDetail) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with Sensitive

use of com.bc.pmpheep.back.po.Sensitive in project pmph by BCSquad.

the class SensitiveServiceImpl method update.

@Override
public String update(Sensitive sensitive) throws CheckedServiceException {
    if (ObjectUtil.isNull(sensitive.getId())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.SENSITIVE, CheckedExceptionResult.NULL_PARAM, "需要修改的敏感词id为空");
    }
    if (StringUtil.notEmpty(sensitive.getNote())) {
        if (sensitive.getNote().length() > 100) {
            throw new CheckedServiceException(CheckedExceptionBusiness.SENSITIVE, CheckedExceptionResult.ILLEGAL_PARAM, "备注太长了,请控制在100个字以内");
        }
    } else {
        sensitive.setNote("-");
    }
    String result = "FAIL";
    if (StringUtil.notEmpty(sensitive.getWord())) {
        if (sensitive.getWord().length() > 10) {
            throw new CheckedServiceException(CheckedExceptionBusiness.SENSITIVE, CheckedExceptionResult.ILLEGAL_PARAM, "敏感词太长了,请控制在10个字以内");
        }
        Sensitive sen = sensitiveDao.getSensitiveId(sensitive.getWord());
        if (ObjectUtil.notNull(sen)) {
            Long id = sen.getId();
            if (null != id && !sensitive.getId().equals(id)) {
                throw new CheckedServiceException(CheckedExceptionBusiness.SENSITIVE, CheckedExceptionResult.ILLEGAL_PARAM, "修改的敏感词重复了");
            }
        }
    }
    Integer total = sensitiveDao.update(sensitive);
    if (total > 0) {
        result = "SUCCESS";
    }
    return result;
}
Also used : Sensitive(com.bc.pmpheep.back.po.Sensitive) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Example 5 with Sensitive

use of com.bc.pmpheep.back.po.Sensitive in project pmph by BCSquad.

the class SensitiveServiceTest method updateTest.

@Test
public void updateTest() {
    Sensitive sen = sensitiveService.add(sensitive);
    sen.setWord("jkgh");
    String result = sensitiveService.update(sen);
    Assert.assertTrue("修改失败", result.equals("SUCCESS"));
}
Also used : Sensitive(com.bc.pmpheep.back.po.Sensitive) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest)

Aggregations

Sensitive (com.bc.pmpheep.back.po.Sensitive)7 BaseTest (com.bc.pmpheep.test.BaseTest)4 Test (org.junit.Test)4 PageParameter (com.bc.pmpheep.back.plugin.PageParameter)2 LogDetail (com.bc.pmpheep.annotation.LogDetail)1 ResponseBean (com.bc.pmpheep.controller.bean.ResponseBean)1 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1