| | |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.CommentJoinMapper; |
| | | import com.doumee.dao.business.CommentMapper; |
| | | import com.doumee.dao.business.MemberMapper; |
| | | import com.doumee.dao.business.MultifileMapper; |
| | | import com.doumee.dao.business.model.Activity; |
| | | import com.doumee.dao.business.model.Comment; |
| | | import com.doumee.dao.business.model.Member; |
| | | import com.doumee.dao.business.model.Multifile; |
| | | import com.doumee.dao.business.*; |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.dao.web.dto.CommentDTO; |
| | | import com.doumee.dao.web.dto.ZanDTO; |
| | | import com.doumee.dao.web.dto.activity.ActivityCommentDTO; |
| | |
| | | private MemberMapper memberMapper; |
| | | |
| | | @Autowired |
| | | private NoticeMapper noticeMapper; |
| | | |
| | | @Autowired |
| | | private ZanService zanService; |
| | | |
| | | @Autowired |
| | |
| | | ); |
| | | reply = Optional.ofNullable(reply).orElseThrow(() -> new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "回复目标不存在")); |
| | | target.setReplyId(reply.getId()); |
| | | target.setReplyMemberId(reply.getMemberId()); |
| | | target.setReplyMemberNikeName(reply.getReplyMemberNikeName()); |
| | | target.setCommentId(reply.getId()); |
| | | target.setCommentMemberId(reply.getMemberId()); |
| | | target.setCommentId(Objects.isNull(reply.getCommentId())?reply.getId():reply.getCommentId()); |
| | | target.setType(Constants.ONE); |
| | | target.setCommentId(reply.getCommentId()); |
| | | target.setCommentMemberId(reply.getCommentMemberId()); |
| | | }else if (comment.getCommentId() != null ){ |
| | | target.setCommentMemberId(reply.getMemberId()); |
| | | |
| | | if(!Constants.equalsInteger(memberId,reply.getMemberId())){ |
| | | Member member = memberMapper.selectById(memberId); |
| | | //评论发送用户消息 |
| | | //发送核销通知 |
| | | Notice notice = Notice.getNotice( |
| | | Constants.NoticeType.COMMENT, |
| | | reply.getMemberId(), |
| | | reply.getActivityId() |
| | | ); |
| | | notice.setContent(notice.getContent().replace("{param}",member.getNickname())); |
| | | noticeMapper.insert(notice); |
| | | } |
| | | }else if(comment.getCommentId() != null ){ |
| | | Comment reply = commentMapper.selectById(comment.getCommentId()); |
| | | reply = Optional.ofNullable(reply).orElseThrow(() -> new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "一级评论目标不存在")); |
| | | target.setCommentId(reply.getCommentId()); |
| | |
| | | |
| | | |
| | | @Override |
| | | public void deleteById(Integer id) { |
| | | commentMapper.deleteById(id); |
| | | public void deleteById(Integer id,Integer memberId) { |
| | | Comment comment = commentMapper.selectById(id); |
| | | if(Objects.isNull(comment)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "评论不存在"); |
| | | } |
| | | if(!Constants.equalsInteger(memberId,comment.getMemberId())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "非您的评论无权限删除"); |
| | | } |
| | | commentMapper.update(new UpdateWrapper<Comment>().lambda() |
| | | .set(Comment::getIsdeleted,Constants.ONE) |
| | | .eq(Comment::getId,id) |
| | | ); |
| | | } |
| | | |
| | | @Override |
| | |
| | | queryWrapper.eq(Comment::getType, Constants.ZERO); |
| | | queryWrapper.eq(Comment::getStatus, Constants.ZERO); |
| | | queryWrapper.eq(Comment::getActivityId,pageWrap.getModel().getActivityId()); |
| | | queryWrapper.orderByDesc(Comment::getId); |
| | | queryWrapper.orderByAsc(Comment::getId); |
| | | IPage<ActivityCommentDTO> result = commentJoinMapper.selectJoinPage(page, ActivityCommentDTO.class, queryWrapper); |
| | | |
| | | if (CollectionUtils.isEmpty(result.getRecords())){ |
| | |
| | | MPJLambdaWrapper<Comment> replyWrapper = new MPJLambdaWrapper<>(); |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | replyWrapper.selectAs(Comment::getId,ActivityReplyCommentDTO::getId); |
| | | replyWrapper.selectAs(Comment::getReplyId,ActivityReplyCommentDTO::getReplyId); |
| | | replyWrapper.selectAs(Comment::getIsdeleted,ActivityReplyCommentDTO::getIsdeleted); |
| | | if(Objects.isNull(pageWrap.getModel().getMemberId())){ |
| | | replyWrapper.select(" 0 ",ActivityReplyCommentDTO::getZanStatus); |
| | | }else{ |
| | |
| | | replyWrapper.selectAs(Member::getImgurl,ActivityReplyCommentDTO::getMemberImgUrl); |
| | | replyWrapper.selectCount(Comment::getId,ActivityReplyCommentDTO::getReplyCount); |
| | | replyWrapper.selectMin(Comment::getCreateDate,ActivityReplyCommentDTO::getCreateDate); |
| | | replyWrapper.select("reply.NICKNAME",ActivityReplyCommentDTO::getReplyMemberNikeName); |
| | | replyWrapper.leftJoin(Member.class,Member::getId,Comment::getMemberId); |
| | | replyWrapper.leftJoin("member reply on reply.id = t.REPLY_MEMBER_ID"); |
| | | replyWrapper.eq(Comment::getType, Constants.ONE); |
| | | replyWrapper.eq(Comment::getStatus, Constants.ZERO); |
| | | replyWrapper.in(Comment::getCommentId,commentIds); |
| | | replyWrapper.orderByDesc(Comment::getId); |
| | | replyWrapper.groupBy(Comment::getCommentId); |
| | | |
| | | List<ActivityReplyCommentDTO> activityCommentDTOS = commentJoinMapper.selectJoinList(ActivityReplyCommentDTO.class, replyWrapper); |
| | |
| | | } |
| | | } |
| | | result.getRecords().forEach(s->{ |
| | | s.setMemberImgUrl(StringUtils.isNotBlank(s.getMemberImgUrl())?memberFile+s.getMemberImgUrl():null); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){ |
| | | s.setMultifileList(multifileList.stream().filter(t -> t.getObjId().equals(s.getId())).collect(Collectors.toList())); |
| | | if(Constants.equalsInteger(s.getIsdeleted(),Constants.ONE)){ |
| | | s.setContent("该评论已被原作者删除"); |
| | | }else{ |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){ |
| | | s.setMultifileList(multifileList.stream().filter(t -> t.getObjId().equals(s.getId())).collect(Collectors.toList())); |
| | | } |
| | | } |
| | | s.setMemberImgUrl(StringUtils.isNotBlank(s.getMemberImgUrl())?memberFile+s.getMemberImgUrl():null); |
| | | ZanDTO object = MapUtils.getObject(count, s.getId()); |
| | | ActivityReplyCommentDTO replyCommentDTO = collect.get(s.getId()); |
| | | if(Objects.nonNull(replyCommentDTO)){ |
| | | ZanDTO replyZan = MapUtils.getObject(count, replyCommentDTO.getId()); |
| | | replyCommentDTO.setZanCount(replyZan != null ? replyZan.getCount() : 0); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){ |
| | | replyCommentDTO.setMultifileList(multifileList.stream().filter(t -> t.getObjId().equals(s.getId())).collect(Collectors.toList())); |
| | | if(Constants.equalsInteger(replyCommentDTO.getIsdeleted(),Constants.ONE)){ |
| | | replyCommentDTO.setContent("该评论已被原作者删除"); |
| | | }else{ |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){ |
| | | replyCommentDTO.setMultifileList(multifileList.stream().filter(t -> t.getObjId().equals(replyCommentDTO.getId())).collect(Collectors.toList())); |
| | | } |
| | | } |
| | | replyCommentDTO.setMemberImgUrl(StringUtils.isNotBlank(replyCommentDTO.getMemberImgUrl())?memberFile+replyCommentDTO.getMemberImgUrl():null); |
| | | s.setActivityReplyCommentDTO(replyCommentDTO); |
| | |
| | | queryWrapper.select(" (select count(1) from zan z where z.OBJ_ID = t.id and z.ISDELETED = 0 and z.OBJ_TYPE = 0) ",ActivityReplyCommentDTO::getZanCount); |
| | | queryWrapper.select("reply.NICKNAME as replyMemberNikeName"); |
| | | queryWrapper.leftJoin(Member.class,Member::getId,Comment::getMemberId); |
| | | queryWrapper.leftJoin("member reply on reply.id = t.REPLY_MEMBER_ID"); |
| | | queryWrapper.leftJoin("member reply on reply.id = t.COMMENT_MEMBER_ID"); |
| | | queryWrapper.eq(Comment::getType, Constants.ONE); |
| | | queryWrapper.eq(Comment::getStatus, Constants.ZERO); |
| | | queryWrapper.eq(Comment::getCommentId,pageWrap.getModel().getCommentId()); |
| | | queryWrapper.orderByDesc(Comment::getId); |
| | | queryWrapper.orderByAsc(Comment::getId); |
| | | IPage<ActivityReplyCommentDTO> result = commentJoinMapper.selectJoinPage(page, ActivityReplyCommentDTO.class, queryWrapper); |
| | | if (CollectionUtils.isEmpty(result.getRecords())){ |
| | | return PageData.from(result); |
| | |
| | | } |
| | | } |
| | | List<Integer> integerStream = result.getRecords().stream().map(s -> s.getId()).collect(Collectors.toList()); |
| | | |
| | | Map<Integer, ZanDTO> count = zanService.count(integerStream); |
| | | result.getRecords().forEach(s->{ |
| | | s.setMemberImgUrl(StringUtils.isNotBlank(s.getMemberImgUrl())?memberFile+s.getMemberImgUrl():null); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){ |
| | | s.setMultifileList(multifileList.stream().filter(t -> t.getObjId().equals(s.getId())).collect(Collectors.toList())); |
| | | if(Constants.equalsInteger(s.getIsdeleted(),Constants.ONE)){ |
| | | s.setContent("该评论已被原作者删除"); |
| | | }else{ |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){ |
| | | s.setMultifileList(multifileList.stream().filter(t -> t.getObjId().equals(s.getId())).collect(Collectors.toList())); |
| | | } |
| | | } |
| | | s.setMemberImgUrl(StringUtils.isNotBlank(s.getMemberImgUrl())?memberFile+s.getMemberImgUrl():null); |
| | | ZanDTO replyZan = MapUtils.getObject(count, s.getId()); |
| | | s.setZanCount(replyZan != null ? replyZan.getCount() : 0); |
| | | if (pageWrap.getModel().getCommentId().equals(s.getReplyId())){ |
| | | s.setReplyMemberNikeName(null); |
| | | } |
| | | }); |
| | | |
| | | return PageData.from(result); |
| | | } |
| | | } |