use of com.bc.pmpheep.back.po.WriterUserTrendst 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;
}
use of com.bc.pmpheep.back.po.WriterUserTrendst in project pmph by BCSquad.
the class CmsContentServiceImpl method checkContentById.
@Override
public Integer checkContentById(Long id, Short authStatus, Long categoryId, String sessionId) throws CheckedServiceException {
// 获取当前登陆用户
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (ObjectUtil.isNull(pmphUser) || ObjectUtil.isNull(pmphUser.getId())) {
throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "用户为空");
}
if (ObjectUtil.isNull(id) || ObjectUtil.isNull(authStatus)) {
throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "参数为空");
}
Boolean isPublished = false;
Boolean isStaging = false;
if (Const.CMS_AUTHOR_STATUS_2 == authStatus) {
// 发布
isPublished = true;
isStaging = true;
}
Integer count = 0;
count = cmsContentDao.checkContentById(new CmsContent(id, authStatus, pmphUser.getId(), DateUtil.formatTimeStamp("yyyy-MM-dd HH:mm:ss", DateUtil.getCurrentTime()), isPublished, isStaging, Const.MATERIAL_TYPE_ID));
CmsContent cmsContent = this.getCmsContentById(id);
if (ObjectUtil.isNull(cmsContent)) {
throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.OBJECT_NOT_FOUND, "获取对象为空");
}
// 评论审核通过,评论数加1
if (Const.CMS_CATEGORY_ID_0.longValue() == categoryId.longValue() && isPublished) {
this.updatCmsContentCommentsById(id, 1);
this.updateCmsContentByParentId(cmsContent.getParentId(), 1);
}
Integer type = 0;
if (Const.CMS_CATEGORY_ID_0.longValue() == categoryId.longValue()) {
type = Const.WRITER_USER_TRENDST_TYPE_2;
} else if (Const.CMS_CATEGORY_ID_1.longValue() == categoryId.longValue()) {
type = Const.WRITER_USER_TRENDST_TYPE_1;
}
if (isPublished) {
writerUserTrendstService.addWriterUserTrendst(new WriterUserTrendst(cmsContent.getAuthorId(), type, id));
}
// 当文章通过的时候 给用户增加积分
if (Const.CMS_CATEGORY_ID_1.longValue() == categoryId.longValue() && isPublished && Const.CMS_AUTHOR_TYPE_2 == cmsContent.getAuthorType()) {
String ruleName = "发表文章";
writerPointLogService.addWriterPointLogByRuleName(ruleName, cmsContent.getAuthorId());
}
return count;
}
use of com.bc.pmpheep.back.po.WriterUserTrendst in project pmph by BCSquad.
the class CmsContentServiceImpl method publishCmsContentById.
@Override
public Integer publishCmsContentById(Long id, String sessionId) throws CheckedServiceException {
// 获取当前登陆用户
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (ObjectUtil.isNull(pmphUser) || ObjectUtil.isNull(pmphUser.getId())) {
throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "用户为空");
}
if (ObjectUtil.isNull(id)) {
throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "参数为空");
}
// count = cmsContentDao.publishCmsContentById(id);
Integer count = cmsContentDao.updateCmsContent(new CmsContent(id, Boolean.TRUE, Boolean.FALSE, Const.CMS_AUTHOR_STATUS_2, pmphUser.getId(), DateUtil.formatTimeStamp("yyyy-MM-dd HH:mm:ss", DateUtil.getCurrentTime())));
CmsContent cmsContent = this.getCmsContentById(id);
writerUserTrendstService.addWriterUserTrendst(new WriterUserTrendst(cmsContent.getAuthorId(), Const.WRITER_USER_TRENDST_TYPE_1, id));
return count;
}
use of com.bc.pmpheep.back.po.WriterUserTrendst in project pmph by BCSquad.
the class WriterUserTrendstServiceTest method testAddWriterUserTrendst.
@Test
public void testAddWriterUserTrendst() {
writerUserTrendst.setType(0);
writerUserTrendst.setUserId(20L);
writerUserTrendst.setDetail("111");
WriterUserTrendst userTrendst = writerUserTrendstService.addWriterUserTrendst(writerUserTrendst);
Assert.assertTrue("新增失败", userTrendst.getId() != null);
}
Aggregations