From fc9240bd6b246ad71c4050510880a49ce07138a3 Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期五, 13 二月 2026 09:51:13 +0800
Subject: [PATCH] Merge branch 'master' of http://139.186.142.91:10010/r/productDev/dingyuannongji
---
server/dmmall_service/src/main/java/com/doumee/service/business/impl/CommentServiceImpl.java | 141 +++++++++++++++++++++++++++++++++++++++-------
1 files changed, 118 insertions(+), 23 deletions(-)
diff --git a/server/dmmall_service/src/main/java/com/doumee/service/business/impl/CommentServiceImpl.java b/server/dmmall_service/src/main/java/com/doumee/service/business/impl/CommentServiceImpl.java
index 64c0413..899ea8b 100644
--- a/server/dmmall_service/src/main/java/com/doumee/service/business/impl/CommentServiceImpl.java
+++ b/server/dmmall_service/src/main/java/com/doumee/service/business/impl/CommentServiceImpl.java
@@ -1,5 +1,6 @@
package com.doumee.service.business.impl;
+import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.config.listener.event.IntegralEvent;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
@@ -10,13 +11,17 @@
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.web.dto.CommentDTO;
import com.doumee.dao.web.dto.ZanDTO;
import com.doumee.dao.web.dto.activity.ActivityCommentDTO;
import com.doumee.dao.web.dto.activity.ActivityReplyCommentDTO;
+import com.doumee.dao.web.request.CommentApplyRequest;
import com.doumee.service.business.CommentService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -51,32 +56,39 @@
private CommentJoinMapper commentJoinMapper;
@Autowired
- private MemberService memberService;
+ private MemberMapper memberMapper;
@Autowired
private ZanService zanService;
@Autowired
private ApplicationEventPublisher applicationEventPublisher;
+
+ @Autowired
+ private MultifileMapper multifileMapper;
+
+ @Autowired
+ private SystemDictDataBiz systemDictDataBiz;
+
@Override
- public Integer create(Comment comment,Integer memberId) {
- LoginUserInfo loginUserInfo = (LoginUserInfo)SecurityUtils.getSubject().getPrincipal();
+ public Comment apply(CommentApplyRequest comment, Integer memberId) {
Comment target = new Comment();
- target.setCreator(loginUserInfo.getId());
target.setCreateDate(new Date());
- target.setEditor(loginUserInfo.getId());
target.setEditDate(new Date());
target.setRemark(comment.getRemark());
- target.setMemberId(loginUserInfo.getMemberId());
+ target.setMemberId(memberId);
target.setActivityId(comment.getActivityId());
target.setContent(comment.getContent());
- target.setAnonymous(comment.getAnonymous());
+ target.setAnonymous(Constants.ONE);
+ target.setStatus(Constants.ZERO);
+ target.setType(Constants.ZERO);
if (comment.getReplyId() != null){
Comment reply = commentMapper.selectById(comment.getReplyId());
reply = Optional.ofNullable(reply).orElseThrow(() -> new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "鍥炲鐩爣涓嶅瓨鍦�"));
target.setReplyId(reply.getId());
target.setReplyMemberId(reply.getMemberId());
+ target.setCommentId(reply.getId());
target.setType(Constants.ONE);
}
@@ -89,11 +101,38 @@
target.setRecIntegral(new BigDecimal("0"));
commentMapper.insert(target);
+ String path = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode() ;
+ if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(comment.getMultifileList())){
+ String commentFile = path + systemDictDataBiz.queryByCode(Constants.OSS, Constants.COMMENT_FILE).getCode();
+ for (Multifile multifile:comment.getMultifileList()) {
+ multifile.setCreateDate(new Date());
+ multifile.setEditDate(new Date());
+ multifile.setObjId(target.getId());
+ multifile.setObjType(Constants.MultiFile.COMMENT_FILE.getKey());
+ multifile.setFileFullUrl(commentFile + multifile.getFileurl());
+ }
+ multifileMapper.insert(comment.getMultifileList());
+ target.setMultifileList(comment.getMultifileList());
+ }
+
+ Member member = memberMapper.selectById(memberId);
+ if(Objects.nonNull(member)){
+ target.setNikeName(member.getNickname());
+ if(StringUtils.isNotBlank(member.getImgurl())){
+ String memberFile = path + systemDictDataBiz.queryByCode(Constants.OSS, Constants.MEMBER_FILE).getCode();
+ target.setMemberImgUrl(memberFile + member.getImgurl());
+ }
+ }
IntegralEvent<Comment> integralEvent = new IntegralEvent(this,target, Constants.CoffeeBeanTask.POST_COMMENTS,memberId);
applicationEventPublisher.publishEvent(integralEvent);
-
- return comment.getId();
+ target.setZanCount(Constants.ZERO);
+ target.setZanStatus(Constants.ZERO);
+ return target;
}
+
+
+
+
@Override
public void deleteById(Integer id) {
@@ -193,13 +232,19 @@
MPJLambdaWrapper<Comment> queryWrapper = new MPJLambdaWrapper<>();
Utils.MP.blankToNull(pageWrap.getModel());
queryWrapper.selectAll(Comment.class);
+ if(Objects.isNull(pageWrap.getModel().getMemberId())){
+ queryWrapper.select(" 0 ",ActivityCommentDTO::getZanStatus);
+ }else{
+ queryWrapper.select(" (select count(1) from zan z where z.OBJ_ID = t.id and z.MEMBER_ID = "+pageWrap.getModel().getMemberId()+" and z.ISDELETED = 0 and z.OBJ_TYPE = 1) ",ActivityCommentDTO::getZanStatus);
+ }
+ queryWrapper.select(" (select count(1) from zan z where z.OBJ_ID = t.id and z.ISDELETED = 0 and z.OBJ_TYPE = 0) ",ActivityCommentDTO::getZanCount);
queryWrapper.selectAs(Member::getNickname,ActivityCommentDTO::getNikeName);
- queryWrapper.selectAs(Member::getImgurl,ActivityCommentDTO::getMemberImgUrl);
queryWrapper.selectAs(Member::getImgurl,ActivityCommentDTO::getMemberImgUrl);
queryWrapper.leftJoin(Member.class,Member::getId,Comment::getMemberId);
queryWrapper.eq(Comment::getType, Constants.ZERO);
queryWrapper.eq(Comment::getStatus, Constants.ZERO);
queryWrapper.eq(Comment::getActivityId,pageWrap.getModel().getActivityId());
+ queryWrapper.orderByDesc(Comment::getId);
IPage<ActivityCommentDTO> result = commentJoinMapper.selectJoinPage(page, ActivityCommentDTO.class, queryWrapper);
if (CollectionUtils.isEmpty(result.getRecords())){
@@ -207,10 +252,15 @@
}
// 鏌ヨ鍚勪釜璇勮 鐨勯鏉″洖澶� 鍜屽洖澶嶆�绘潯鏁�
List<Integer> commentIds = result.getRecords().stream().map(s -> s.getId()).collect(Collectors.toList());
-
MPJLambdaWrapper<Comment> replyWrapper = new MPJLambdaWrapper<>();
Utils.MP.blankToNull(pageWrap.getModel());
replyWrapper.selectAs(Comment::getId,ActivityReplyCommentDTO::getId);
+ if(Objects.isNull(pageWrap.getModel().getMemberId())){
+ replyWrapper.select(" 0 ",ActivityReplyCommentDTO::getZanStatus);
+ }else{
+ replyWrapper.select(" (select count(1) from zan z where z.OBJ_ID = t.id and z.MEMBER_ID = "+pageWrap.getModel().getMemberId()+" and z.ISDELETED = 0 and z.OBJ_TYPE = 1) ",ActivityReplyCommentDTO::getZanStatus);
+ }
+ replyWrapper.select(" (select count(1) from zan z where z.OBJ_ID = t.id and z.ISDELETED = 0 and z.OBJ_TYPE = 0) ",ActivityReplyCommentDTO::getZanCount);
replyWrapper.selectAs(Comment::getCommentId,ActivityReplyCommentDTO::getCommentId);
replyWrapper.selectAs(Comment::getMemberId,ActivityReplyCommentDTO::getMemberId);
replyWrapper.selectAs(Comment::getContent,ActivityReplyCommentDTO::getContent);
@@ -224,26 +274,47 @@
replyWrapper.in(Comment::getCommentId,commentIds);
replyWrapper.groupBy(Comment::getCommentId);
- List<ActivityReplyCommentDTO> activityCommentDTOS = commentJoinMapper.selectJoinList(ActivityReplyCommentDTO.class, queryWrapper);
-
+ List<ActivityReplyCommentDTO> activityCommentDTOS = commentJoinMapper.selectJoinList(ActivityReplyCommentDTO.class, replyWrapper);
List<Integer> integerStream = activityCommentDTOS.stream().map(s -> s.getId()).collect(Collectors.toList());
commentIds.addAll(integerStream);
-
Map<Integer, ZanDTO> count = zanService.count(commentIds);
-
Map<Integer, ActivityReplyCommentDTO> collect = activityCommentDTOS.stream().collect(Collectors.toMap(s -> s.getCommentId(), s -> s));
+ String path = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode();
+ String memberFile = path + systemDictDataBiz.queryByCode(Constants.OSS, Constants.MEMBER_FILE).getCode();
+ String commentFile = path + systemDictDataBiz.queryByCode(Constants.OSS, Constants.COMMENT_FILE).getCode();
+
+ List<Multifile> multifileList = multifileMapper.selectList(new QueryWrapper<Multifile>()
+ .lambda()
+ .eq(Multifile::getIsdeleted,Constants.ZERO)
+ .in(Multifile::getObjId,commentIds)
+ .eq(Multifile::getObjType,Constants.MultiFile.COMMENT_FILE.getKey())
+ .orderByDesc(Multifile::getId)
+ );
+ if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){
+ for (Multifile multifile:multifileList) {
+ multifile.setFileFullUrl(commentFile + multifile.getFileurl());
+ }
+ }
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()));
+ }
ZanDTO object = MapUtils.getObject(count, s.getId());
-
ActivityReplyCommentDTO replyCommentDTO = collect.get(s.getId());
- ZanDTO replyZan = MapUtils.getObject(count, replyCommentDTO.getId());
- replyCommentDTO.setZanCount(replyZan != null ? replyZan.getCount() : 0);
- s.setActivityReplyCommentDTO(replyCommentDTO);
- s.setReplyCount(replyCommentDTO.getReplyCount());
+ 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()));
+ }
+ replyCommentDTO.setMemberImgUrl(StringUtils.isNotBlank(replyCommentDTO.getMemberImgUrl())?memberFile+replyCommentDTO.getMemberImgUrl():null);
+ s.setActivityReplyCommentDTO(replyCommentDTO);
+ s.setReplyCount(replyCommentDTO.getReplyCount());
+ }
s.setZanCount(object != null ? object.getCount() : 0);
- });
+ });
return PageData.from(result);
}
@@ -255,6 +326,12 @@
queryWrapper.selectAll(Comment.class);
queryWrapper.selectAs(Member::getNickname,ActivityReplyCommentDTO::getMemberNikeName);
queryWrapper.selectAs(Member::getImgurl,ActivityReplyCommentDTO::getMemberImgUrl);
+ if(Objects.isNull(pageWrap.getModel().getMemberId())){
+ queryWrapper.select(" 0 ",ActivityReplyCommentDTO::getZanStatus);
+ }else{
+ queryWrapper.select(" (select count(1) from zan z where z.OBJ_ID = t.id and z.MEMBER_ID = "+pageWrap.getModel().getMemberId()+" and z.ISDELETED = 0 and z.OBJ_TYPE = 1) ",ActivityReplyCommentDTO::getZanStatus);
+ }
+ 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");
@@ -265,11 +342,29 @@
if (CollectionUtils.isEmpty(result.getRecords())){
return PageData.from(result);
}
-
+ String path = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode();
+ String memberFile = path + systemDictDataBiz.queryByCode(Constants.OSS, Constants.MEMBER_FILE).getCode();
+ String commentFile = path + systemDictDataBiz.queryByCode(Constants.OSS, Constants.COMMENT_FILE).getCode();
+ List<Multifile> multifileList = multifileMapper.selectList(new QueryWrapper<Multifile>()
+ .lambda()
+ .eq(Multifile::getIsdeleted,Constants.ZERO)
+ .eq(Multifile::getObjId,pageWrap.getModel().getCommentId())
+ .eq(Multifile::getObjType,Constants.MultiFile.COMMENT_FILE.getKey())
+ .orderByDesc(Multifile::getId)
+ );
+ if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){
+ for (Multifile multifile:multifileList) {
+ multifile.setFileFullUrl(commentFile + multifile.getFileurl());
+ }
+ }
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()));
+ }
ZanDTO replyZan = MapUtils.getObject(count, s.getId());
s.setZanCount(replyZan != null ? replyZan.getCount() : 0);
if (pageWrap.getModel().getCommentId().equals(s.getReplyId())){
--
Gitblit v1.9.3