use of com.bc.pmpheep.back.po.BookUserComment in project pmph by BCSquad.
the class BookUserCommentServiceImpl method deleteBookUserCommentById.
@Override
public String deleteBookUserCommentById(Long[] ids) throws CheckedServiceException {
if (ArrayUtil.isEmpty(ids)) {
throw new CheckedServiceException(CheckedExceptionBusiness.BOOK, CheckedExceptionResult.NULL_PARAM, "评论id为空");
}
String result = "FAIL";
for (Long id : ids) {
BookUserComment bookUserComment = bookUserCommentDao.getBookUserCommentById(id);
Long bookId = bookUserComment.getBookId();
if (bookUserComment.getIsAuth() == 1) {
bookService.updateDownComments(bookId);
}
}
int num = bookUserCommentDao.deleteBookUserCommentById(ids);
if (num > 0) {
result = "SUCCESS";
} else {
throw new CheckedServiceException(CheckedExceptionBusiness.BOOK, CheckedExceptionResult.NULL_PARAM, "删除失败");
}
return result;
}
use of com.bc.pmpheep.back.po.BookUserComment in project pmph by BCSquad.
the class BookUserCommentServiceImpl method updateBookUserCommentByAuth.
@Override
public String updateBookUserCommentByAuth(Long[] ids, Integer isAuth, String sessionId) throws CheckedServiceException {
String result = "FAIL";
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (ArrayUtil.isEmpty(ids)) {
throw new CheckedServiceException(CheckedExceptionBusiness.BOOK, CheckedExceptionResult.NULL_PARAM, "评论id为空");
}
if (ObjectUtil.isNull(isAuth)) {
throw new CheckedServiceException(CheckedExceptionBusiness.BOOK, CheckedExceptionResult.NULL_PARAM, "审核内容为空");
}
int num = 0;
for (Long id : ids) {
BookUserComment bookUserComment = bookUserCommentDao.getBookUserCommentById(id);
if (bookUserComment.getIsAuth() != 0) {
throw new CheckedServiceException(CheckedExceptionBusiness.BOOK, CheckedExceptionResult.ILLEGAL_PARAM, "您选中的评论中有已经审核完成的评论,请确认后再次提交");
}
if (isAuth == 1) {
WriterUserTrendst writerUserTrendst = new WriterUserTrendst();
writerUserTrendst.setUserId(bookUserComment.getWriterId());
writerUserTrendst.setType(5);
writerUserTrendst.setBookId(bookUserComment.getBookId());
writerUserTrendst.setBookCommentId(id);
writerUserTrendstService.addWriterUserTrendst(writerUserTrendst);
}
bookUserComment.setId(id);
bookUserComment.setIsAuth(isAuth);
bookUserComment.setAuthUserId(pmphUser.getId());
bookUserComment.setAuthDate(DateUtil.getCurrentTime());
num += bookUserCommentDao.updateBookUserComment(bookUserComment);
if (isAuth == 1) {
// 更新评分
bookService.updateBookCore(bookUserComment.getBookId());
// 更新书的评论数
bookService.updateUpComments(bookUserComment.getBookId());
}
// 当用户评论过后 增加相应积分
if (isAuth == 1) {
String ruleName = "图书评论";
writerPointLogService.addWriterPointLogByRuleName(ruleName, bookUserComment.getWriterId());
}
}
if (num > 0) {
result = "SUCCESS";
}
return result;
}
use of com.bc.pmpheep.back.po.BookUserComment in project pmph by BCSquad.
the class BookUserCommentServiceImpl method updateBookUserComment.
@Override
public String updateBookUserComment(Long[] ids, Boolean isStick, Boolean isPromote, Boolean isHot, Integer sort, Integer sortPromote, Integer sortHot) throws CheckedServiceException {
if (ArrayUtil.isEmpty(ids)) {
throw new CheckedServiceException(CheckedExceptionBusiness.BOOK, CheckedExceptionResult.NULL_PARAM, "评论id为空");
}
String result = "FAIL";
int num = 0;
for (Long id : ids) {
BookUserComment bookUserComment = new BookUserComment();
bookUserComment.setId(id);
bookUserComment.setIsHot(isHot);
bookUserComment.setIsPromote(isPromote);
bookUserComment.setIsStick(isStick);
if (null != isStick && isStick) {
Long bookId = bookUserCommentDao.getBookUserCommentById(id).getBookId();
sort = bookUserCommentDao.getMinSort(bookId) - 1;
}
bookUserComment.setSort(sort);
bookUserComment.setSortHot(sortHot);
bookUserComment.setSortPromote(sortPromote);
num += bookUserCommentDao.updateBookUserComment(bookUserComment);
}
if (num > 0) {
result = "SUCCESS";
}
return result;
}
Aggregations