From 5a5ab268dd8f761f8d2cc4bc26a2a7c814074d7f Mon Sep 17 00:00:00 2001 From: yang <2119157826@qq.com> Date: Sat, 15 Feb 2025 23:21:57 +0800 Subject: [PATCH] =?UTF-8?q?feat(resource):=20=E7=82=B9=E8=B5=9E=E6=B6=88?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/SysAdviceController.java | 13 ++++ .../com/mcwl/resource/domain/SysAdvice.java | 5 ++ .../resource/domain/vo/CommentAdviceVo.java | 16 ++--- .../mcwl/resource/domain/vo/LikeAdviceVo.java | 19 ++++++ .../resource/service/ISysAdviceService.java | 3 + .../impl/ModelCommentLikeServiceImpl.java | 43 ++++++++++--- .../ModelImageCommentLikeServiceImpl.java | 38 +++++++++-- .../impl/ModelImageLikeServiceImpl.java | 37 ++++++++++- .../service/impl/ModelLikeServiceImpl.java | 40 +++++++++++- .../service/impl/SysAdviceServiceImpl.java | 64 ++++++++++++++++--- .../impl/WorkFlowCommentLikeServiceImpl.java | 32 ++++++++++ .../service/impl/WorkFlowLikeServiceImpl.java | 30 +++++++++ 12 files changed, 307 insertions(+), 33 deletions(-) create mode 100644 mcwl-resource/src/main/java/com/mcwl/resource/domain/vo/LikeAdviceVo.java diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/system/SysAdviceController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/system/SysAdviceController.java index ad84123..6d25171 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/system/SysAdviceController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/system/SysAdviceController.java @@ -3,6 +3,7 @@ package com.mcwl.web.controller.system; import com.mcwl.common.core.domain.R; import com.mcwl.resource.domain.vo.AdviceVo; import com.mcwl.resource.domain.vo.CommentAdviceVo; +import com.mcwl.resource.domain.vo.LikeAdviceVo; import com.mcwl.resource.service.ISysAdviceService; import io.swagger.annotations.ApiParam; import lombok.RequiredArgsConstructor; @@ -73,5 +74,17 @@ public class SysAdviceController { return R.ok(adviceVo); } + /** + * 获取点赞通知 + */ + @GetMapping("getLikeMsg") + public R> getLikeMsg(@Valid + @NotNull(message = "类型不能为空") + @ApiParam(value = "类型 0模型 1工作流 2图片 3评论 4全部", required = true) + Integer productType) { + List likeAdviceVoList = sysAdviceService.getLikeMsg(productType); + return R.ok(likeAdviceVoList); + } + } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/domain/SysAdvice.java b/mcwl-resource/src/main/java/com/mcwl/resource/domain/SysAdvice.java index 8f8ff63..c68efcb 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/domain/SysAdvice.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/domain/SysAdvice.java @@ -48,6 +48,11 @@ public class SysAdvice extends BaseEntity { */ private Integer productType; + /** + * 评论id + */ + private Long commentId; + /** * 是否已读 0否 1是 */ diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/domain/vo/CommentAdviceVo.java b/mcwl-resource/src/main/java/com/mcwl/resource/domain/vo/CommentAdviceVo.java index 750f90b..2a9bac9 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/domain/vo/CommentAdviceVo.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/domain/vo/CommentAdviceVo.java @@ -7,7 +7,7 @@ import lombok.Data; import java.util.Date; @Data -@ApiModel(description = "评论回复消息") +@ApiModel(description = "评论/点赞消息") public class CommentAdviceVo { /** @@ -17,9 +17,9 @@ public class CommentAdviceVo { private Long id; /** - * 评论用户头像 + * 评论/点赞用户头像 */ - @ApiModelProperty(value = "评论用户头像") + @ApiModelProperty(value = "评论/点赞用户头像") private String userAvatar; /** @@ -30,21 +30,21 @@ public class CommentAdviceVo { /** - * 评论的商品id + * 评论/点赞的商品id */ - @ApiModelProperty(value = "评论的商品id") + @ApiModelProperty(value = "评论/点赞的商品id") private Long productId; /** - * 评论的商品图片 + * 评论/点赞的商品图片 */ @ApiModelProperty(value = "商品图片") private String productImag; /** - * 评论的商品类型 0模型 1工作流 2图片 + * 评论/点赞的商品类型 0模型 1工作流 2图片 */ - @ApiModelProperty(value = "评论的商品类型 0模型 1工作流 2图片") + @ApiModelProperty(value = "评论/点赞的商品类型 0模型 1工作流 2图片") private Integer productType; /** diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/domain/vo/LikeAdviceVo.java b/mcwl-resource/src/main/java/com/mcwl/resource/domain/vo/LikeAdviceVo.java new file mode 100644 index 0000000..24f97fb --- /dev/null +++ b/mcwl-resource/src/main/java/com/mcwl/resource/domain/vo/LikeAdviceVo.java @@ -0,0 +1,19 @@ +package com.mcwl.resource.domain.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(description = "评论/点赞消息") +public class LikeAdviceVo extends CommentAdviceVo { + + /** + * 评论id + */ + @ApiModelProperty(value = "评论id") + private Long commentId; + +} diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/ISysAdviceService.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/ISysAdviceService.java index 50fb192..5fa9f8c 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/ISysAdviceService.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/ISysAdviceService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.mcwl.resource.domain.SysAdvice; import com.mcwl.resource.domain.vo.AdviceVo; import com.mcwl.resource.domain.vo.CommentAdviceVo; +import com.mcwl.resource.domain.vo.LikeAdviceVo; import java.util.List; @@ -23,4 +24,6 @@ public interface ISysAdviceService extends IService { List getAllMsg(); List getCommentMsg(Integer productType); + + List getLikeMsg(Integer productType); } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelCommentLikeServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelCommentLikeServiceImpl.java index 7a2386b..6b759e0 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelCommentLikeServiceImpl.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelCommentLikeServiceImpl.java @@ -1,33 +1,28 @@ package com.mcwl.resource.service.impl; -import com.baomidou.mybatisplus.core.conditions.Wrapper; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.mcwl.common.exception.ServiceException; import com.mcwl.common.utils.SecurityUtils; +import com.mcwl.common.utils.StringUtils; import com.mcwl.resource.domain.ModelComment; import com.mcwl.resource.domain.ModelCommentLike; -import com.mcwl.resource.domain.ModelImageComment; -import com.mcwl.resource.domain.ModelImageCommentLike; +import com.mcwl.resource.domain.SysAdvice; import com.mcwl.resource.mapper.ModelCommentLikeMapper; import com.mcwl.resource.mapper.ModelCommentMapper; -import com.mcwl.resource.mapper.ModelImageCommentMapper; import com.mcwl.resource.service.ModelCommentLikeService; +import com.mcwl.system.domain.enums.AdviceEnum; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.Collection; import java.util.Date; -import java.util.Map; import java.util.Objects; -import java.util.function.Function; /** * 模型评论点赞 */ @Service -public class ModelCommentLikeServiceImpl extends ServiceImpl implements ModelCommentLikeService { +public class ModelCommentLikeServiceImpl extends ServiceImpl implements ModelCommentLikeService { @Autowired private ModelCommentMapper modelCommentMapper; @@ -50,6 +45,7 @@ public class ModelCommentLikeServiceImpl extends ServiceImpl initPage(PageDomain pageDomain) { Page page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize()); if (StringUtils.isBlank(pageDomain.getOrderByColumn())) { @@ -136,4 +168,6 @@ public class ModelLikeServiceImpl extends ServiceImpl getLikeMsg(Integer productType) { + this.postConstruct(); + List sysAdviceList; + if (productType == 3) { + sysAdviceList = baseMapper.selectList(new LambdaQueryWrapper() + .eq(SysAdvice::getType, AdviceEnum.LIKE_REMIND) + .eq(SysAdvice::getReceiverId, SecurityUtils.getUserId()) + .isNotNull(SysAdvice::getCommentId)); + } else { + sysAdviceList = baseMapper.selectList(new LambdaQueryWrapper() + .eq(SysAdvice::getType, AdviceEnum.LIKE_REMIND) + .eq(SysAdvice::getReceiverId, SecurityUtils.getUserId()) + .eq(productType != 4, SysAdvice::getProductType, productType)); + } + + + List likeAdviceVoList = new ArrayList<>(); + for (SysAdvice sysAdvice : sysAdviceList) { + LikeAdviceVo likeAdviceVo = BeanUtil.copyProperties(sysAdvice, LikeAdviceVo.class); + + Long senderId = sysAdvice.getSenderId(); + SysUser senderUser = sysUserService.selectUserById(senderId); + likeAdviceVo.setUserAvatar(senderUser.getAvatar()); + if (productType == 0) { + ModelProduct modelProduct = modelProductMap.get(sysAdvice.getProductId()); + if (Objects.nonNull(modelProduct)) { + likeAdviceVo.setProductImag(modelProduct.getSurfaceUrl()); + } + } else if (productType == 1) { + WorkFlow workFlow = workFlowMap.get(sysAdvice.getProductId()); + if (Objects.nonNull(workFlow)) { + likeAdviceVo.setProductImag(workFlow.getCoverPath()); + } + } else if (productType == 2) { + ModelImage modelImage = modelImageMap.get(sysAdvice.getProductId()); + if (Objects.nonNull(modelImage)) { + likeAdviceVo.setProductImag(modelImage.getImagePaths().split(",")[0]); + } + } + + likeAdviceVoList.add(likeAdviceVo); + } + + return likeAdviceVoList; + } public void postConstruct() { Long userId = SecurityUtils.getUserId(); diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/WorkFlowCommentLikeServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/WorkFlowCommentLikeServiceImpl.java index f4cbe28..be9036d 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/WorkFlowCommentLikeServiceImpl.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/WorkFlowCommentLikeServiceImpl.java @@ -3,11 +3,14 @@ package com.mcwl.resource.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.mcwl.common.exception.ServiceException; import com.mcwl.common.utils.SecurityUtils; +import com.mcwl.common.utils.StringUtils; +import com.mcwl.resource.domain.SysAdvice; import com.mcwl.resource.domain.WorkFlowComment; import com.mcwl.resource.domain.WorkFlowCommentLike; import com.mcwl.resource.mapper.WorkFlowCommentLikeMapper; import com.mcwl.resource.mapper.WorkFlowCommentMapper; import com.mcwl.resource.service.WorkFlowCommentLikeService; +import com.mcwl.system.domain.enums.AdviceEnum; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -47,6 +50,7 @@ public class WorkFlowCommentLikeServiceImpl extends ServiceImpl initPage(PageDomain pageDomain) { Page page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize()); if (StringUtils.isBlank(pageDomain.getOrderByColumn())) {