Commit f7b0c111 authored by wuwz's avatar wuwz

修改评论必填

parent 2d130ad8
......@@ -159,7 +159,38 @@ public class UserCommentBiz extends BaseBiz<UserCommentMapper, UserComment>{
point += jsonObject.getInteger("point");
}
userComment.setPoint(point);
addOrUpd(userComment);
Integer parentId = userComment.getParentId() == null ? 0 : userComment.getParentId();
Integer rootParentId = userComment.getRootParentId() == null ? 0 : userComment.getRootParentId();
if (parentId > 0){
UserComment parentComment = selectById(parentId);
if (parentComment == null ){
throw new BaseException("该评论不存在", ResultCode.FAILED_CODE);
}
rootParentId=parentComment.getRootParentId();
userComment.setSoureId(parentComment.getSoureId());
userComment.setSoureUserId(parentComment.getSoureUserId());
userComment.setSoureType(parentComment.getSoureType());
userComment.setToUserId(parentComment.getUserId());
userComment.setRootParentId(rootParentId);
}else {
if (StringUtils.isBlank(userComment.getSoureId())){
throw new BaseException("资源ID不能为空", ResultCode.FAILED_CODE);
}
}
userComment.setCreateTime(new Date());
insertSelective(userComment);
Integer id = userComment.getId();
if (id > 0 ){
if (rootParentId == 0){
UserComment userComment1=new UserComment();
userComment1.setId(id);
userComment1.setRootParentId(id);
updateSelectiveById(userComment1);
}else {
mapper.addreplyNum(rootParentId);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment