feat(resource): 评论通知功能
parent
461b75cce2
commit
7e40833bb7
|
@ -1,15 +1,22 @@
|
|||
package com.mcwl.web.controller.system;
|
||||
|
||||
import com.mcwl.common.core.domain.AjaxResult;
|
||||
import com.mcwl.system.domain.vo.AdviceVo;
|
||||
import com.mcwl.system.service.ISysAdviceService;
|
||||
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.service.ISysAdviceService;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 消息通知
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("system/advice")
|
||||
@RequiredArgsConstructor
|
||||
|
@ -18,39 +25,52 @@ public class SysAdviceController {
|
|||
private final ISysAdviceService sysAdviceService;
|
||||
|
||||
/**
|
||||
* 根据当前用户获取新消息提醒
|
||||
* 根据当前用户获取新消息通知
|
||||
*/
|
||||
@GetMapping("getUserNewMsg")
|
||||
public AjaxResult getUserNewMsg() {
|
||||
public R<List<AdviceVo>> getUserNewMsg() {
|
||||
List<AdviceVo> adviceVo = sysAdviceService.getUserNewMsg();
|
||||
return AjaxResult.success(adviceVo);
|
||||
return R.ok(adviceVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据当前用户获取系统公告
|
||||
*/
|
||||
@GetMapping("getUserSystemNotice")
|
||||
public AjaxResult getUserSystemNotice() {
|
||||
public R<List<AdviceVo>> getUserSystemNotice() {
|
||||
List<AdviceVo> adviceVo = sysAdviceService.getUserSystemNotice();
|
||||
return AjaxResult.success(adviceVo);
|
||||
return R.ok(adviceVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据当前用户获取所有消息
|
||||
* 根据当前用户获取所有通知
|
||||
*/
|
||||
@GetMapping("getUserAllMsg")
|
||||
public AjaxResult getUserAllMsg() {
|
||||
public R<List<AdviceVo>> getUserAllMsg() {
|
||||
List<AdviceVo> adviceVo = sysAdviceService.getUserAllMsg();
|
||||
return AjaxResult.success(adviceVo);
|
||||
return R.ok(adviceVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有消息
|
||||
* 获取所有通知
|
||||
*/
|
||||
@GetMapping("getAllMsg")
|
||||
public AjaxResult getAllMsg() {
|
||||
public R<List<AdviceVo>> getAllMsg() {
|
||||
List<AdviceVo> adviceVo = sysAdviceService.getAllMsg();
|
||||
return AjaxResult.success(adviceVo);
|
||||
return R.ok(adviceVo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取评论通知
|
||||
*/
|
||||
@GetMapping("getCommentMsg")
|
||||
public R<List<CommentAdviceVo>> getCommentMsg(@Valid
|
||||
@NotNull(message = "类型不能为空")
|
||||
@ApiParam(value = "类型 0模型 1工作流 2图片 3全部", required = true)
|
||||
Integer productType) {
|
||||
List<CommentAdviceVo> adviceVo = sysAdviceService.getCommentMsg(productType);
|
||||
return R.ok(adviceVo);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -45,6 +45,12 @@
|
|||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
<version>3.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mcwl</groupId>
|
||||
<artifactId>mcwl-resource</artifactId>
|
||||
<version>3.8.8</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -2,12 +2,10 @@ package com.mcwl.memberCenter.consumer;
|
|||
|
||||
import com.mcwl.common.constant.QueueConstants;
|
||||
import com.mcwl.common.core.domain.entity.SysUser;
|
||||
import com.mcwl.common.utils.SecurityUtils;
|
||||
import com.mcwl.memberCenter.domain.Member;
|
||||
import com.mcwl.memberCenter.service.MemberService;
|
||||
import com.mcwl.system.domain.SysAdvice;
|
||||
import com.mcwl.resource.domain.SysAdvice;
|
||||
import com.mcwl.resource.service.ISysAdviceService;
|
||||
import com.mcwl.system.domain.enums.AdviceEnum;
|
||||
import com.mcwl.system.service.ISysAdviceService;
|
||||
import com.mcwl.system.service.ISysUserService;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import org.springframework.amqp.core.Message;
|
||||
|
|
|
@ -3,9 +3,9 @@ package com.mcwl.memberCenter.consumer;
|
|||
import com.mcwl.common.constant.QueueConstants;
|
||||
import com.mcwl.common.core.domain.entity.SysUser;
|
||||
import com.mcwl.memberCenter.domain.Member;
|
||||
import com.mcwl.system.domain.SysAdvice;
|
||||
import com.mcwl.resource.domain.SysAdvice;
|
||||
import com.mcwl.system.domain.enums.AdviceEnum;
|
||||
import com.mcwl.system.service.ISysAdviceService;
|
||||
import com.mcwl.resource.service.ISysAdviceService;
|
||||
import com.mcwl.system.service.ISysUserService;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
|
|
@ -32,5 +32,12 @@
|
|||
<artifactId>mcwl-system</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- rabbitmq依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
<version>3.1.2</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.mcwl.system.domain;
|
||||
package com.mcwl.resource.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
@ -28,11 +28,6 @@ public class SysAdvice extends BaseEntity {
|
|||
*/
|
||||
private Long receiverId;
|
||||
|
||||
/**
|
||||
* 消息类型 表示新消息提醒,系统公告等
|
||||
*/
|
||||
private AdviceEnum type;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
|
@ -44,9 +39,24 @@ public class SysAdvice extends BaseEntity {
|
|||
private String content;
|
||||
|
||||
/**
|
||||
* 是否已读 0 是 1 否
|
||||
* 商品id
|
||||
*/
|
||||
private String isRead;
|
||||
private Long productId;
|
||||
|
||||
/**
|
||||
* 商品类型 0模型 1工作流 2图片
|
||||
*/
|
||||
private Integer productType;
|
||||
|
||||
/**
|
||||
* 是否已读 0否 1是
|
||||
*/
|
||||
private Integer isRead;
|
||||
|
||||
/**
|
||||
* 消息类型 表示新消息提醒,系统公告等
|
||||
*/
|
||||
private AdviceEnum type;
|
||||
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ public class ModelCommentRes {
|
|||
/**
|
||||
* 回复人
|
||||
*/
|
||||
@ApiModelProperty(value = "回复人")
|
||||
@ApiModelProperty(value = "回复人", required = true)
|
||||
private Long replyUserId;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.mcwl.system.domain.vo;
|
||||
package com.mcwl.resource.domain.vo;
|
||||
|
||||
import com.mcwl.system.domain.enums.AdviceEnum;
|
||||
import lombok.Data;
|
||||
|
@ -22,7 +22,7 @@ public class AdviceVo {
|
|||
private String content;
|
||||
|
||||
/**
|
||||
* 是否已读 0 是 1 否
|
||||
* 是否已读 0否 1是
|
||||
*/
|
||||
private String isRead;
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package com.mcwl.resource.domain.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@ApiModel(description = "评论回复消息")
|
||||
public class CommentAdviceVo {
|
||||
|
||||
/**
|
||||
* 通知id
|
||||
*/
|
||||
@ApiModelProperty(value = "通知id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 评论用户头像
|
||||
*/
|
||||
@ApiModelProperty(value = "评论用户头像")
|
||||
private String userAvatar;
|
||||
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
@ApiModelProperty(value = "内容")
|
||||
private String content;
|
||||
|
||||
|
||||
/**
|
||||
* 评论的商品id
|
||||
*/
|
||||
@ApiModelProperty(value = "评论的商品id")
|
||||
private Long productId;
|
||||
|
||||
/**
|
||||
* 评论的商品图片
|
||||
*/
|
||||
@ApiModelProperty(value = "商品图片")
|
||||
private String productImag;
|
||||
|
||||
/**
|
||||
* 评论的商品类型 0模型 1工作流 2图片
|
||||
*/
|
||||
@ApiModelProperty(value = "评论的商品类型 0模型 1工作流 2图片")
|
||||
private Integer productType;
|
||||
|
||||
/**
|
||||
* 是否已读 0否 1是
|
||||
*/
|
||||
@ApiModelProperty(value = "是否已读 0否 1是")
|
||||
private Integer isRead;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
}
|
|
@ -1,12 +1,9 @@
|
|||
package com.mcwl.system.mapper;
|
||||
package com.mcwl.resource.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mcwl.system.domain.SysAdvice;
|
||||
import com.mcwl.system.domain.SysConfig;
|
||||
import com.mcwl.resource.domain.SysAdvice;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 消息通知
|
||||
*/
|
|
@ -1,9 +1,9 @@
|
|||
package com.mcwl.system.service;
|
||||
package com.mcwl.resource.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mcwl.system.domain.SysAdvice;
|
||||
import com.mcwl.system.domain.SysConfig;
|
||||
import com.mcwl.system.domain.vo.AdviceVo;
|
||||
import com.mcwl.resource.domain.SysAdvice;
|
||||
import com.mcwl.resource.domain.vo.AdviceVo;
|
||||
import com.mcwl.resource.domain.vo.CommentAdviceVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -21,4 +21,6 @@ public interface ISysAdviceService extends IService<SysAdvice> {
|
|||
List<AdviceVo> getUserAllMsg();
|
||||
|
||||
List<AdviceVo> getAllMsg();
|
||||
|
||||
List<CommentAdviceVo> getCommentMsg(Integer productType);
|
||||
}
|
|
@ -3,20 +3,27 @@ package com.mcwl.resource.service.impl;
|
|||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mcwl.common.constant.QueueConstants;
|
||||
import com.mcwl.common.core.domain.entity.SysUser;
|
||||
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.SysAdvice;
|
||||
import com.mcwl.resource.domain.WorkFlowComment;
|
||||
import com.mcwl.resource.domain.dto.ModelCommentRes;
|
||||
import com.mcwl.resource.domain.vo.ModelCommentVo;
|
||||
import com.mcwl.resource.mapper.ModelCommentMapper;
|
||||
import com.mcwl.resource.mapper.ModelImageMapper;
|
||||
import com.mcwl.resource.service.ISysAdviceService;
|
||||
import com.mcwl.resource.service.ModelCommentLikeService;
|
||||
import com.mcwl.resource.service.ModelCommentService;
|
||||
import com.mcwl.system.domain.enums.AdviceEnum;
|
||||
import com.mcwl.system.service.ISysUserService;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
|
@ -37,10 +44,15 @@ public class ModelCommentServiceImpl extends ServiceImpl<ModelCommentMapper, Mod
|
|||
@Autowired
|
||||
private ModelCommentLikeService modelCommentLikeService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private ISysAdviceService sysAdviceService;
|
||||
|
||||
@Autowired
|
||||
private ModelImageMapper modelImageMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void comment(ModelCommentRes modelCommentRes) {
|
||||
Long parentId = modelCommentRes.getParentId();
|
||||
|
||||
|
@ -52,9 +64,42 @@ public class ModelCommentServiceImpl extends ServiceImpl<ModelCommentMapper, Mod
|
|||
}
|
||||
ModelComment modelComment = new ModelComment();
|
||||
BeanUtil.copyProperties(modelCommentRes, modelComment);
|
||||
modelComment.setUserId(SecurityUtils.getUserId());
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
modelComment.setUserId(userId);
|
||||
modelCommentMapper.insert(modelComment);
|
||||
|
||||
|
||||
Long replyUserId = modelCommentRes.getReplyUserId();
|
||||
|
||||
if (Objects.isNull(replyUserId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ModelComment mc = modelCommentMapper.selectById(replyUserId);
|
||||
if (Objects.isNull(mc)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Objects.equals(userId, mc.getUserId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String content = StringUtils.format("{}给您的模型发了一条评论:{}",
|
||||
SecurityUtils.getUsername(), modelCommentRes.getContent());
|
||||
|
||||
// 向通知表中插入一条记录
|
||||
SysAdvice sysAdvice = new SysAdvice();
|
||||
sysAdvice.setSenderId(userId);
|
||||
sysAdvice.setReceiverId(mc.getUserId());
|
||||
sysAdvice.setContent(content);
|
||||
sysAdvice.setProductId(modelCommentRes.getModelId());
|
||||
sysAdvice.setProductType(0);
|
||||
sysAdvice.setIsRead(0);
|
||||
sysAdvice.setType(AdviceEnum.COMMENT_REMIND);
|
||||
sysAdviceService.save(sysAdvice);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,18 +5,19 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mcwl.common.core.domain.entity.SysUser;
|
||||
import com.mcwl.common.utils.SecurityUtils;
|
||||
import com.mcwl.resource.domain.ModelComment;
|
||||
import com.mcwl.resource.domain.ModelImageComment;
|
||||
import com.mcwl.resource.domain.ModelImageCommentLike;
|
||||
import com.mcwl.resource.domain.WorkFlowComment;
|
||||
import com.mcwl.common.utils.StringUtils;
|
||||
import com.mcwl.resource.domain.*;
|
||||
import com.mcwl.resource.domain.dto.ModelImageCommentRes;
|
||||
import com.mcwl.resource.domain.vo.ModelImageCommentVo;
|
||||
import com.mcwl.resource.mapper.ModelImageCommentMapper;
|
||||
import com.mcwl.resource.service.ISysAdviceService;
|
||||
import com.mcwl.resource.service.ModelImageCommentLikeService;
|
||||
import com.mcwl.resource.service.ModelImageCommentService;
|
||||
import com.mcwl.system.domain.enums.AdviceEnum;
|
||||
import com.mcwl.system.service.ISysUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
|
@ -33,7 +34,10 @@ public class ModelImageCommentServiceImpl extends ServiceImpl<ModelImageCommentM
|
|||
|
||||
private final ModelImageCommentLikeService modelImageCommentLikeService;
|
||||
|
||||
private final ISysAdviceService sysAdviceService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void comment(ModelImageCommentRes modelImageCommentRes) {
|
||||
Long parentId = modelImageCommentRes.getParentId();
|
||||
|
||||
|
@ -46,9 +50,42 @@ public class ModelImageCommentServiceImpl extends ServiceImpl<ModelImageCommentM
|
|||
|
||||
ModelImageComment modelImageComment = new ModelImageComment();
|
||||
BeanUtil.copyProperties(modelImageCommentRes, modelImageComment);
|
||||
modelImageComment.setUserId(SecurityUtils.getUserId());
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
modelImageComment.setUserId(userId);
|
||||
baseMapper.insert(modelImageComment);
|
||||
|
||||
|
||||
Long replyUserId = modelImageCommentRes.getReplyUserId();
|
||||
|
||||
if (Objects.isNull(replyUserId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ModelImageComment mic = baseMapper.selectById(replyUserId);
|
||||
if (Objects.isNull(mic)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Objects.equals(userId, mic.getUserId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String content = StringUtils.format("{}给您的图片发了一条评论:{}",
|
||||
SecurityUtils.getUsername(), modelImageCommentRes.getContent());
|
||||
|
||||
// 向通知表中插入一条记录
|
||||
SysAdvice sysAdvice = new SysAdvice();
|
||||
sysAdvice.setSenderId(userId);
|
||||
sysAdvice.setReceiverId(mic.getUserId());
|
||||
sysAdvice.setContent(content);
|
||||
sysAdvice.setProductId(modelImageCommentRes.getModelImageId());
|
||||
sysAdvice.setProductType(0);
|
||||
sysAdvice.setIsRead(0);
|
||||
sysAdvice.setType(AdviceEnum.COMMENT_REMIND);
|
||||
sysAdviceService.save(sysAdvice);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.mcwl.resource.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
@ -26,10 +27,7 @@ import lombok.RequiredArgsConstructor;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 图片点赞实现
|
||||
|
@ -162,14 +160,23 @@ public class ModelImageLikeServiceImpl extends ServiceImpl<ModelImageLikeMapper,
|
|||
pageHelper.startPage(pageVo.getPageNumber(),pageVo.getPageSize());
|
||||
|
||||
List<ResponseModelImage> responseModelImageList = modelImageMapper.imageList(pageVo);
|
||||
|
||||
List<Long> modelImageLikeIds = new ArrayList<>();
|
||||
|
||||
List<ModelImageLike> modelImageLikes = baseMapper.selectList(new LambdaQueryWrapper<ModelImageLike>()
|
||||
.eq(ModelImageLike::getUserId, SecurityUtils.getUserId()));
|
||||
for (ModelImageLike modelImageLike : modelImageLikes) {
|
||||
modelImageLikeIds.add(modelImageLike.getModelImageId());
|
||||
}
|
||||
|
||||
|
||||
for (ResponseModelImage responseModelImage : responseModelImageList) {
|
||||
|
||||
String[] split = responseModelImage.getImagePaths().split(",");
|
||||
responseModelImage.setPath(split[0]);
|
||||
|
||||
//查询模型是否点赞
|
||||
ModelImageLike likeImage = baseMapper.getLikeImage(SecurityUtils.getUserId(), responseModelImage.getId());
|
||||
if (likeImage == null){
|
||||
//查询是否点赞
|
||||
if (!modelImageLikeIds.contains(responseModelImage.getId())){
|
||||
responseModelImage.setIsLike(0);
|
||||
}else {
|
||||
responseModelImage.setIsLike(1);
|
||||
|
|
|
@ -0,0 +1,164 @@
|
|||
package com.mcwl.resource.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mcwl.common.core.domain.entity.SysUser;
|
||||
import com.mcwl.common.utils.SecurityUtils;
|
||||
import com.mcwl.resource.domain.ModelImage;
|
||||
import com.mcwl.resource.domain.ModelProduct;
|
||||
import com.mcwl.resource.domain.WorkFlow;
|
||||
import com.mcwl.resource.service.ModelImageService;
|
||||
import com.mcwl.resource.service.ModelService;
|
||||
import com.mcwl.resource.service.WorkFlowService;
|
||||
import com.mcwl.resource.domain.SysAdvice;
|
||||
import com.mcwl.system.domain.enums.AdviceEnum;
|
||||
import com.mcwl.resource.domain.vo.AdviceVo;
|
||||
import com.mcwl.resource.domain.vo.CommentAdviceVo;
|
||||
import com.mcwl.resource.mapper.SysAdviceMapper;
|
||||
import com.mcwl.resource.service.ISysAdviceService;
|
||||
import com.mcwl.system.service.ISysUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* 消息管理 业务层处理
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SysAdviceServiceImpl extends ServiceImpl<SysAdviceMapper, SysAdvice> implements ISysAdviceService {
|
||||
|
||||
private final ISysUserService sysUserService;
|
||||
|
||||
private final ModelService modelService;
|
||||
|
||||
private final WorkFlowService workFlowService;
|
||||
|
||||
private final ModelImageService modelImageService;
|
||||
|
||||
private final Map<Long, ModelProduct> modelProductMap = new ConcurrentHashMap<>();
|
||||
private final Map<Long, WorkFlow> workFlowMap = new ConcurrentHashMap<>();
|
||||
private final Map<Long, ModelImage> modelImageMap = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
@Override
|
||||
public List<AdviceVo> getUserNewMsg() {
|
||||
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
|
||||
List<SysAdvice> sysAdvices = baseMapper.selectList(lambdaQuery()
|
||||
.eq(SysAdvice::getReceiverId, userId)
|
||||
.eq(SysAdvice::getType, AdviceEnum.NEW_MESSAGE_REMIND));
|
||||
|
||||
return BeanUtil.copyToList(sysAdvices, AdviceVo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AdviceVo> getUserSystemNotice() {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
|
||||
List<SysAdvice> sysAdvices = baseMapper.selectList(lambdaQuery()
|
||||
.eq(SysAdvice::getReceiverId, userId)
|
||||
.eq(SysAdvice::getType, AdviceEnum.SYSTEM_NOTICE));
|
||||
|
||||
return BeanUtil.copyToList(sysAdvices, AdviceVo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AdviceVo> getUserAllMsg() {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
|
||||
List<SysAdvice> sysAdvices = baseMapper.selectList(lambdaQuery()
|
||||
.eq(SysAdvice::getReceiverId, userId));
|
||||
|
||||
return BeanUtil.copyToList(sysAdvices, AdviceVo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AdviceVo> getAllMsg() {
|
||||
|
||||
List<SysAdvice> sysAdvices = baseMapper.selectList(null);
|
||||
|
||||
return BeanUtil.copyToList(sysAdvices, AdviceVo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommentAdviceVo> getCommentMsg(Integer productType) {
|
||||
|
||||
this.postConstruct();
|
||||
|
||||
List<SysAdvice> sysAdviceList = baseMapper.selectList(new LambdaQueryWrapper<SysAdvice>()
|
||||
.eq(SysAdvice::getType, AdviceEnum.COMMENT_REMIND)
|
||||
.eq(SysAdvice::getReceiverId, SecurityUtils.getUserId())
|
||||
.eq(productType != 3, SysAdvice::getProductType, productType));
|
||||
|
||||
List<CommentAdviceVo> commentAdviceVoList = new ArrayList<>();
|
||||
for (SysAdvice sysAdvice : sysAdviceList) {
|
||||
CommentAdviceVo commentAdviceVo = BeanUtil.copyProperties(sysAdvice, CommentAdviceVo.class);
|
||||
|
||||
Long senderId = sysAdvice.getSenderId();
|
||||
SysUser senderUser = sysUserService.selectUserById(senderId);
|
||||
commentAdviceVo.setUserAvatar(senderUser.getAvatar());
|
||||
if (productType == 0) {
|
||||
ModelProduct modelProduct = modelProductMap.get(sysAdvice.getProductId());
|
||||
if (Objects.nonNull(modelProduct)) {
|
||||
commentAdviceVo.setProductImag(modelProduct.getSurfaceUrl());
|
||||
}
|
||||
} else if (productType == 1) {
|
||||
WorkFlow workFlow = workFlowMap.get(sysAdvice.getProductId());
|
||||
if (Objects.nonNull(workFlow)) {
|
||||
commentAdviceVo.setProductImag(workFlow.getCoverPath());
|
||||
}
|
||||
} else if (productType == 2) {
|
||||
ModelImage modelImage = modelImageMap.get(sysAdvice.getProductId());
|
||||
if (Objects.nonNull(modelImage)) {
|
||||
commentAdviceVo.setProductImag(modelImage.getImagePaths().split(",")[0]);
|
||||
}
|
||||
}
|
||||
|
||||
commentAdviceVoList.add(commentAdviceVo);
|
||||
}
|
||||
|
||||
return commentAdviceVoList;
|
||||
}
|
||||
|
||||
|
||||
public void postConstruct() {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
|
||||
// 并行加载数据
|
||||
CompletableFuture<List<ModelProduct>> productsFuture = CompletableFuture.supplyAsync(() ->
|
||||
modelService.lambdaQuery().eq(ModelProduct::getUserId, userId).list()
|
||||
);
|
||||
|
||||
CompletableFuture<List<WorkFlow>> workflowsFuture = CompletableFuture.supplyAsync(() ->
|
||||
workFlowService.lambdaQuery().eq(WorkFlow::getUserId, userId).list()
|
||||
);
|
||||
|
||||
CompletableFuture<List<ModelImage>> imagesFuture = CompletableFuture.supplyAsync(() ->
|
||||
modelImageService.lambdaQuery().eq(ModelImage::getUserId, userId).list()
|
||||
);
|
||||
|
||||
// 等待所有任务完成
|
||||
CompletableFuture.allOf(productsFuture, workflowsFuture, imagesFuture).join();
|
||||
|
||||
// 更新缓存
|
||||
modelProductMap.clear();
|
||||
productsFuture.join().forEach(p -> modelProductMap.put(p.getId(), p));
|
||||
|
||||
workFlowMap.clear();
|
||||
workflowsFuture.join().forEach(w -> workFlowMap.put(w.getId(), w));
|
||||
|
||||
modelImageMap.clear();
|
||||
imagesFuture.join().forEach(i -> modelImageMap.put(i.getId(), i));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -5,13 +5,18 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mcwl.common.core.domain.entity.SysUser;
|
||||
import com.mcwl.common.utils.SecurityUtils;
|
||||
import com.mcwl.common.utils.StringUtils;
|
||||
import com.mcwl.resource.domain.ModelImageComment;
|
||||
import com.mcwl.resource.domain.SysAdvice;
|
||||
import com.mcwl.resource.domain.WorkFlowComment;
|
||||
import com.mcwl.resource.domain.WorkFlowCommentLike;
|
||||
import com.mcwl.resource.domain.dto.WorkFlowCommentRes;
|
||||
import com.mcwl.resource.domain.vo.WorkFlowCommentVo;
|
||||
import com.mcwl.resource.mapper.WorkFlowCommentMapper;
|
||||
import com.mcwl.resource.service.ISysAdviceService;
|
||||
import com.mcwl.resource.service.WorkFlowCommentLikeService;
|
||||
import com.mcwl.resource.service.WorkFlowCommentService;
|
||||
import com.mcwl.system.domain.enums.AdviceEnum;
|
||||
import com.mcwl.system.service.ISysUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -43,6 +48,10 @@ public class WorkFlowCommentServiceImpl extends ServiceImpl<WorkFlowCommentMappe
|
|||
private WorkFlowCommentLikeService workFlowCommentLikeService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private ISysAdviceService sysAdviceService;
|
||||
|
||||
|
||||
@Override
|
||||
public void comment(WorkFlowCommentRes workFlowCommentRes) {
|
||||
Long parentId = workFlowCommentRes.getParentId();
|
||||
|
@ -55,9 +64,43 @@ public class WorkFlowCommentServiceImpl extends ServiceImpl<WorkFlowCommentMappe
|
|||
}
|
||||
WorkFlowComment workFlowComment = new WorkFlowComment();
|
||||
BeanUtil.copyProperties(workFlowCommentRes, workFlowComment);
|
||||
workFlowComment.setUserId(SecurityUtils.getUserId());
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
workFlowComment.setUserId(userId);
|
||||
workFlowCommentMapper.insert(workFlowComment);
|
||||
|
||||
|
||||
Long replyUserId = workFlowCommentRes.getReplyUserId();
|
||||
|
||||
if (Objects.isNull(replyUserId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
WorkFlowComment wfc = workFlowCommentMapper.selectById(replyUserId);
|
||||
if (Objects.isNull(wfc)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Objects.equals(userId, wfc.getUserId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String content = StringUtils.format("{}给您的图片发了一条评论:{}",
|
||||
SecurityUtils.getUsername(), workFlowCommentRes.getContent());
|
||||
|
||||
// 向通知表中插入一条记录
|
||||
SysAdvice sysAdvice = new SysAdvice();
|
||||
sysAdvice.setSenderId(userId);
|
||||
sysAdvice.setReceiverId(wfc.getUserId());
|
||||
sysAdvice.setContent(content);
|
||||
sysAdvice.setProductId(workFlowCommentRes.getWorkFlowId());
|
||||
sysAdvice.setProductType(0);
|
||||
sysAdvice.setIsRead(0);
|
||||
sysAdvice.setType(AdviceEnum.COMMENT_REMIND);
|
||||
sysAdviceService.save(sysAdvice);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
<update id="updateDelFlagById">
|
||||
update model_image_like
|
||||
set del_flag = #{delFlag}
|
||||
where user_id = #{userId} and model_image_id = #{imageId}
|
||||
where user_id = #{userId} and model_image_id = #{modelImageId}
|
||||
</update>
|
||||
|
||||
<select id="getLikeImage" resultMap="ModelImageLikeResult">
|
||||
|
|
|
@ -12,42 +12,46 @@ import lombok.Getter;
|
|||
public enum AdviceEnum {
|
||||
|
||||
/**
|
||||
* 新消息提醒
|
||||
* 新消息通知
|
||||
*/
|
||||
NEW_MESSAGE_REMIND("newMessageRemind", "新消息提醒"),
|
||||
NEW_MESSAGE_REMIND("newMessageRemind", "新消息通知"),
|
||||
|
||||
/**
|
||||
* 系统公告
|
||||
*/
|
||||
SYSTEM_NOTICE("systemNotice", "系统公告"),
|
||||
SYSTEM_NOTICE("systemNotice", "系统通知"),
|
||||
|
||||
/**
|
||||
* 邮件提醒
|
||||
* 邮件通知
|
||||
*/
|
||||
EMAIL_REMIND("emailRemind", "邮件提醒"),
|
||||
EMAIL_REMIND("emailRemind", "邮件通知"),
|
||||
|
||||
/**
|
||||
* 短信提醒
|
||||
* 短信通知
|
||||
*/
|
||||
SMS_REMIND("smsRemind", "短信提醒"),
|
||||
SMS_REMIND("smsRemind", "短信通知"),
|
||||
|
||||
/**
|
||||
* 推送提醒
|
||||
* 推送通知
|
||||
*/
|
||||
PUSH_REMIND("pushRemind", "推送提醒"),
|
||||
PUSH_REMIND("pushRemind", "推送通知"),
|
||||
|
||||
/**
|
||||
* 点赞提醒
|
||||
* 点赞通知
|
||||
*/
|
||||
LIKE_REMIND("likeRemind", "点赞提醒"),
|
||||
LIKE_REMIND("likeRemind", "点赞通知"),
|
||||
/**
|
||||
* 评论提醒
|
||||
* 评论通知
|
||||
*/
|
||||
COMMENT_REMIND("commentRemind", "评论提醒"),
|
||||
COMMENT_REMIND("commentRemind", "评论回复通知"),
|
||||
/**
|
||||
* 私信提醒
|
||||
* 粉丝通知
|
||||
*/
|
||||
PRIVATE_MESSAGE_REMIND("privateMessageRemind", "私信提醒");
|
||||
FANS_REMIND("fansRemind", "粉丝通知"),
|
||||
/**
|
||||
* 私信通知
|
||||
*/
|
||||
PRIVATE_MESSAGE_REMIND("privateMessageRemind", "私信通知");
|
||||
|
||||
private final String name;
|
||||
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
package com.mcwl.system.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mcwl.common.utils.SecurityUtils;
|
||||
import com.mcwl.system.domain.SysAdvice;
|
||||
import com.mcwl.system.domain.SysUserThirdAccount;
|
||||
import com.mcwl.system.domain.enums.AdviceEnum;
|
||||
import com.mcwl.system.domain.vo.AdviceVo;
|
||||
import com.mcwl.system.mapper.SysAdviceMapper;
|
||||
import com.mcwl.system.service.ISysAdviceService;
|
||||
import com.mcwl.system.service.IWXService;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 消息管理 业务层处理
|
||||
*/
|
||||
@Service
|
||||
public class SysAdviceServiceImpl extends ServiceImpl<SysAdviceMapper, SysAdvice> implements ISysAdviceService {
|
||||
|
||||
|
||||
@Override
|
||||
public List<AdviceVo> getUserNewMsg() {
|
||||
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
|
||||
List<SysAdvice> sysAdvices = baseMapper.selectList(lambdaQuery()
|
||||
.eq(SysAdvice::getReceiverId, userId)
|
||||
.eq(SysAdvice::getType, AdviceEnum.NEW_MESSAGE_REMIND));
|
||||
|
||||
return BeanUtil.copyToList(sysAdvices, AdviceVo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AdviceVo> getUserSystemNotice() {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
|
||||
List<SysAdvice> sysAdvices = baseMapper.selectList(lambdaQuery()
|
||||
.eq(SysAdvice::getReceiverId, userId)
|
||||
.eq(SysAdvice::getType, AdviceEnum.SYSTEM_NOTICE));
|
||||
|
||||
return BeanUtil.copyToList(sysAdvices, AdviceVo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AdviceVo> getUserAllMsg() {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
|
||||
List<SysAdvice> sysAdvices = baseMapper.selectList(lambdaQuery()
|
||||
.eq(SysAdvice::getReceiverId, userId));
|
||||
|
||||
return BeanUtil.copyToList(sysAdvices, AdviceVo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AdviceVo> getAllMsg() {
|
||||
|
||||
List<SysAdvice> sysAdvices = baseMapper.selectList(null);
|
||||
|
||||
return BeanUtil.copyToList(sysAdvices, AdviceVo.class);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue