Search in sources :

Example 1 with BookCorrection

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

the class BookCorrectionServiceTest method testUpdateBookCorrection.

@Test
@Rollback(Const.ISROLLBACK)
public void testUpdateBookCorrection() {
    // 新增
    bookCorrectionService.addBookCorrection(bookCorrection);
    Long id = bookCorrection.getId();
    BookCorrection bookCorrection = new BookCorrection((long) r.nextInt(200), (long) r.nextInt(200), r.nextInt(200), r.nextInt(200), String.valueOf(r.nextInt(200)), String.valueOf(r.nextInt(200)), String.valueOf(r.nextInt(200)), true, true, String.valueOf(r.nextInt(200)), true, String.valueOf(r.nextInt(200)), true, new Date());
    bookCorrection.setId(id);
    // 修改
    Assert.assertTrue("更新失败", bookCorrectionService.updateBookCorrection(bookCorrection) > 0);
    // 修改
    bookCorrection = new BookCorrection((long) r.nextInt(200), (long) r.nextInt(200), r.nextInt(200), r.nextInt(200), String.valueOf(r.nextInt(200)), String.valueOf(r.nextInt(200)), String.valueOf(r.nextInt(200)), true, true, String.valueOf(r.nextInt(200)), true, String.valueOf(r.nextInt(200)), true, new Date());
    bookCorrection.setId((long) r.nextInt(200));
    Assert.assertTrue("更新失败", bookCorrectionService.updateBookCorrection(bookCorrection) >= 0);
}
Also used : BookCorrection(com.bc.pmpheep.back.po.BookCorrection) Date(java.util.Date) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Example 2 with BookCorrection

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

the class BookCorrectionServiceTest method testGetBookCorrectionById.

@Test
@Rollback(Const.ISROLLBACK)
public void testGetBookCorrectionById() {
    // 新增
    bookCorrectionService.addBookCorrection(bookCorrection);
    BookCorrection bookCorrection = bookCorrectionService.getBookCorrectionById(this.bookCorrection.getId());
    // 查询
    Assert.assertNotNull("获取数据失败", bookCorrection);
    bookCorrection = bookCorrectionService.getBookCorrectionById((long) r.nextInt(200));
}
Also used : BookCorrection(com.bc.pmpheep.back.po.BookCorrection) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Example 3 with BookCorrection

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

the class BookCorrectionServiceImpl method updateToAcceptancing.

@Override
public Integer updateToAcceptancing(Long id) throws CheckedServiceException {
    if (null == id) {
        throw new CheckedServiceException(CheckedExceptionBusiness.BOOK_CORRECTION, CheckedExceptionResult.NULL_PARAM, "主键为空");
    }
    BookCorrection bookCorrection = this.getBookCorrectionById(id);
    if (!bookCorrection.getIsAuthorReplied()) {
    // throw new CheckedServiceException(CheckedExceptionBusiness.BOOK_CORRECTION,
    // CheckedExceptionResult.NULL_PARAM, "请先主编审核");
    }
    bookCorrection.setIsEditorHandling(true);
    return this.updateBookCorrection(bookCorrection);
}
Also used : BookCorrection(com.bc.pmpheep.back.po.BookCorrection) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Example 4 with BookCorrection

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

the class BookCorrectionServiceImpl method replyWriter.

@Override
public Integer replyWriter(Long id, Boolean result, String editorReply) throws CheckedServiceException {
    if (null == id) {
        throw new CheckedServiceException(CheckedExceptionBusiness.BOOK_CORRECTION, CheckedExceptionResult.NULL_PARAM, "主键为空");
    }
    if (null == result) {
        throw new CheckedServiceException(CheckedExceptionBusiness.BOOK_CORRECTION, CheckedExceptionResult.NULL_PARAM, "检查结果为空");
    }
    if (StringUtil.isEmpty(editorReply)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.BOOK_CORRECTION, CheckedExceptionResult.NULL_PARAM, "回复内容为空");
    }
    if (editorReply.length() > 500) {
        throw new CheckedServiceException(CheckedExceptionBusiness.BOOK_CORRECTION, CheckedExceptionResult.NULL_PARAM, "回复内容超过最长限制500");
    }
    BookCorrection bookCorrection = this.getBookCorrectionById(id);
    Long bookId = bookCorrection.getBookId();
    Long submitUserId = bookCorrection.getUserId();
    if (!bookCorrection.getIsAuthorReplied()) {
    // throw new CheckedServiceException(CheckedExceptionBusiness.BOOK_CORRECTION,
    // CheckedExceptionResult.NULL_PARAM, "请先主编审核");
    }
    if (!bookCorrection.getIsEditorHandling()) {
    // throw new CheckedServiceException(CheckedExceptionBusiness.BOOK_CORRECTION,
    // CheckedExceptionResult.NULL_PARAM, "策划编辑未受理");
    }
    if (bookCorrection.getIsEditorReplied()) {
    /*throw new CheckedServiceException(CheckedExceptionBusiness.BOOK_CORRECTION,
					CheckedExceptionResult.NULL_PARAM, "策划编辑不能再次回复");*/
    }
    bookCorrection = new BookCorrection();
    bookCorrection.setId(id);
    bookCorrection.setResult(result);
    bookCorrection.setIsEditorReplied(true);
    bookCorrection.setEditorReply(editorReply);
    bookCorrection.setIsEditorHandling(true);
    WriterUserTrendst writerUserTrendst = new WriterUserTrendst();
    writerUserTrendst.setUserId(submitUserId);
    writerUserTrendst.setBookId(bookId);
    // 自己可见
    writerUserTrendst.setIsPublic(false);
    writerUserTrendst.setType(10);
    String detail = "";
    if (result) {
        // 有问题
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("title", CheckedExceptionBusiness.BOOKCORRECTION);
        map.put("content", "您的图书纠错已核实。");
        map.put("img", 1);
        detail = new Gson().toJson(map);
    // 更新评论数
    // bookService.updateComments(bookId);
    } else {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("title", CheckedExceptionBusiness.BOOKCORRECTION);
        map.put("content", "您的图书纠错未核实到该问题。");
        map.put("img", 2);
        detail = new Gson().toJson(map);
    }
    // 当审核有问题的时候则给用户增加积分
    if (result) {
        String ruleName = "图书纠错";
        writerPointLogService.addWriterPointLogByRuleName(ruleName, submitUserId);
    }
    writerUserTrendst.setDetail(detail);
    Integer res = this.updateBookCorrection(bookCorrection);
    writerUserTrendstService.addWriterUserTrendst(writerUserTrendst);
    return res;
}
Also used : WriterUserTrendst(com.bc.pmpheep.back.po.WriterUserTrendst) HashMap(java.util.HashMap) BookCorrection(com.bc.pmpheep.back.po.BookCorrection) Gson(com.google.gson.Gson) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Aggregations

BookCorrection (com.bc.pmpheep.back.po.BookCorrection)4 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)2 BaseTest (com.bc.pmpheep.test.BaseTest)2 Test (org.junit.Test)2 Rollback (org.springframework.test.annotation.Rollback)2 WriterUserTrendst (com.bc.pmpheep.back.po.WriterUserTrendst)1 Gson (com.google.gson.Gson)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1