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);
}
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));
}
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);
}
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;
}
Aggregations