Merge remote-tracking branch 'origin/preview' into preview
commit
aacf29a3db
|
@ -0,0 +1,105 @@
|
|||
package com.mcwl.web.controller.resource;
|
||||
|
||||
import com.mcwl.common.core.domain.R;
|
||||
import com.mcwl.resource.domain.vo.AdviceVo;
|
||||
import com.mcwl.resource.domain.vo.AttentionAdviceVo;
|
||||
import com.mcwl.resource.domain.vo.CommentAdviceVo;
|
||||
import com.mcwl.resource.domain.vo.LikeAdviceVo;
|
||||
import com.mcwl.resource.service.ISysAdviceService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
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("advice")
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "消息通知")
|
||||
public class SysAdviceController {
|
||||
|
||||
private final ISysAdviceService sysAdviceService;
|
||||
|
||||
|
||||
/**
|
||||
* 已读
|
||||
*/
|
||||
@GetMapping("read")
|
||||
@ApiOperation(value = "已读")
|
||||
public R<String> read(@Valid
|
||||
@NotNull(message = "消息id不能为空")
|
||||
@ApiParam(value = "消息id", required = true)
|
||||
Long adviceId) {
|
||||
sysAdviceService.read(adviceId);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 一键已读
|
||||
*/
|
||||
@GetMapping("readAll")
|
||||
@ApiOperation(value = "一键已读")
|
||||
public R<String> readAll() {
|
||||
sysAdviceService.readAll();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有通知
|
||||
*/
|
||||
@GetMapping("getAllMsg")
|
||||
@ApiOperation(value = "获取所有通知")
|
||||
public R<List<AdviceVo>> getAllMsg() {
|
||||
List<AdviceVo> adviceVo = sysAdviceService.getAllMsg();
|
||||
return R.ok(adviceVo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取评论通知
|
||||
*/
|
||||
@GetMapping("getCommentMsg")
|
||||
@ApiOperation(value = "获取评论通知")
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取点赞通知
|
||||
*/
|
||||
@GetMapping("getLikeMsg")
|
||||
@ApiOperation(value = "获取点赞通知")
|
||||
public R<List<LikeAdviceVo>> getLikeMsg(@Valid
|
||||
@NotNull(message = "类型不能为空")
|
||||
@ApiParam(value = "类型 0模型 1工作流 2图片 3评论 4全部", required = true)
|
||||
Integer productType) {
|
||||
List<LikeAdviceVo> likeAdviceVoList = sysAdviceService.getLikeMsg(productType);
|
||||
return R.ok(likeAdviceVoList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取关注通知
|
||||
*/
|
||||
@GetMapping("getAttentionMsg")
|
||||
@ApiOperation(value = "获取关注通知")
|
||||
public R<List<AttentionAdviceVo>> getAttentionMsg() {
|
||||
List<AttentionAdviceVo> attentionAdviceVoList = sysAdviceService.getAttentionMsg();
|
||||
return R.ok(attentionAdviceVoList);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
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 lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("system/advice")
|
||||
@RequiredArgsConstructor
|
||||
public class SysAdviceController {
|
||||
|
||||
private final ISysAdviceService sysAdviceService;
|
||||
|
||||
/**
|
||||
* 根据当前用户获取新消息提醒
|
||||
*/
|
||||
@GetMapping("getUserNewMsg")
|
||||
public AjaxResult getUserNewMsg() {
|
||||
List<AdviceVo> adviceVo = sysAdviceService.getUserNewMsg();
|
||||
return AjaxResult.success(adviceVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据当前用户获取系统公告
|
||||
*/
|
||||
@GetMapping("getUserSystemNotice")
|
||||
public AjaxResult getUserSystemNotice() {
|
||||
List<AdviceVo> adviceVo = sysAdviceService.getUserSystemNotice();
|
||||
return AjaxResult.success(adviceVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据当前用户获取所有消息
|
||||
*/
|
||||
@GetMapping("getUserAllMsg")
|
||||
public AjaxResult getUserAllMsg() {
|
||||
List<AdviceVo> adviceVo = sysAdviceService.getUserAllMsg();
|
||||
return AjaxResult.success(adviceVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有消息
|
||||
*/
|
||||
@GetMapping("getAllMsg")
|
||||
public AjaxResult getAllMsg() {
|
||||
List<AdviceVo> adviceVo = sysAdviceService.getAllMsg();
|
||||
return AjaxResult.success(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,29 @@ public class SysAdvice extends BaseEntity {
|
|||
private String content;
|
||||
|
||||
/**
|
||||
* 是否已读 0 是 1 否
|
||||
* 商品id
|
||||
*/
|
||||
private String isRead;
|
||||
private Long productId;
|
||||
|
||||
/**
|
||||
* 商品类型 0模型 1工作流 2图片
|
||||
*/
|
||||
private Integer productType;
|
||||
|
||||
/**
|
||||
* 评论id
|
||||
*/
|
||||
private Long commentId;
|
||||
|
||||
/**
|
||||
* 是否已读 0否 1是
|
||||
*/
|
||||
private Integer isRead;
|
||||
|
||||
/**
|
||||
* 消息类型 表示新消息提醒,系统公告等
|
||||
*/
|
||||
private AdviceEnum type;
|
||||
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ public class ModelCommentRes {
|
|||
/**
|
||||
* 回复人
|
||||
*/
|
||||
@ApiModelProperty(value = "回复人")
|
||||
@ApiModelProperty(value = "回复人", required = true)
|
||||
private Long replyUserId;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package com.mcwl.resource.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.mcwl.system.domain.enums.AdviceEnum;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@ApiModel(description = "消息通知")
|
||||
public class AdviceVo {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@ApiModelProperty(value = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
@ApiModelProperty(value = "标题")
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
@ApiModelProperty(value = "内容")
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 是否已读 0否 1是
|
||||
*/
|
||||
@ApiModelProperty(value = "是否已读 0否 1是")
|
||||
private String isRead;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.mcwl.resource.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@ApiModel(description = "关注消息")
|
||||
public class AttentionAdviceVo {
|
||||
|
||||
/**
|
||||
* 通知id
|
||||
*/
|
||||
@ApiModelProperty(value = "通知id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 关注我的用户头像
|
||||
*/
|
||||
@ApiModelProperty(value = "关注我的用户头像")
|
||||
private String userAvatar;
|
||||
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
@ApiModelProperty(value = "内容")
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 是否已读 0否 1是
|
||||
*/
|
||||
@ApiModelProperty(value = "是否已读 0否 1是")
|
||||
private Integer isRead;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package com.mcwl.resource.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* 消息通知
|
||||
*/
|
|
@ -0,0 +1,35 @@
|
|||
package com.mcwl.resource.service;
|
||||
|
||||
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.AttentionAdviceVo;
|
||||
import com.mcwl.resource.domain.vo.CommentAdviceVo;
|
||||
import com.mcwl.resource.domain.vo.LikeAdviceVo;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 消息通知 服务层
|
||||
*
|
||||
* @author mcwl
|
||||
*/
|
||||
public interface ISysAdviceService extends IService<SysAdvice> {
|
||||
|
||||
List<AdviceVo> getAllMsg();
|
||||
|
||||
List<CommentAdviceVo> getCommentMsg(Integer productType);
|
||||
|
||||
List<LikeAdviceVo> getLikeMsg(Integer productType);
|
||||
|
||||
List<AttentionAdviceVo> getAttentionMsg();
|
||||
|
||||
void read(Long adviceId);
|
||||
|
||||
/**
|
||||
* 一键已读
|
||||
*/
|
||||
void readAll();
|
||||
}
|
|
@ -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<ModelCommentLikeMapper,ModelCommentLike> implements ModelCommentLikeService {
|
||||
public class ModelCommentLikeServiceImpl extends ServiceImpl<ModelCommentLikeMapper, ModelCommentLike> implements ModelCommentLikeService {
|
||||
|
||||
@Autowired
|
||||
private ModelCommentMapper modelCommentMapper;
|
||||
|
@ -50,6 +45,7 @@ public class ModelCommentLikeServiceImpl extends ServiceImpl<ModelCommentLikeMap
|
|||
} else {
|
||||
modelCommentLike.setDelFlag("0");
|
||||
modelComment.setLikeNum(modelComment.getLikeNum() + 1);
|
||||
this.addLikeAdvice(modelComment);
|
||||
}
|
||||
// 更新点赞记录
|
||||
baseMapper.updateDelFlagById(modelCommentLike);
|
||||
|
@ -70,6 +66,35 @@ public class ModelCommentLikeServiceImpl extends ServiceImpl<ModelCommentLikeMap
|
|||
// 更新模型点赞数
|
||||
modelComment.setLikeNum(modelComment.getLikeNum() + 1);
|
||||
modelCommentMapper.updateById(modelComment);
|
||||
|
||||
this.addLikeAdvice(modelComment);
|
||||
}
|
||||
|
||||
|
||||
private void addLikeAdvice(ModelComment modelComment) {
|
||||
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
Long receiverUserId = modelComment.getUserId();
|
||||
|
||||
if (Objects.equals(userId, receiverUserId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String content = StringUtils.format("恭喜!{}点赞了您的评论",
|
||||
SecurityUtils.getUsername());
|
||||
|
||||
SysAdvice sysAdvice = new SysAdvice();
|
||||
sysAdvice.setSenderId(userId);
|
||||
sysAdvice.setReceiverId(receiverUserId);
|
||||
sysAdvice.setContent(content);
|
||||
sysAdvice.setProductId(modelComment.getModelId());
|
||||
sysAdvice.setProductType(0);
|
||||
sysAdvice.setCommentId(modelComment.getId());
|
||||
sysAdvice.setIsRead(0);
|
||||
sysAdvice.setType(AdviceEnum.LIKE_REMIND);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,15 +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.resource.domain.ModelImage;
|
||||
import com.mcwl.common.utils.StringUtils;
|
||||
import com.mcwl.resource.domain.ModelImageComment;
|
||||
import com.mcwl.resource.domain.ModelImageCommentLike;
|
||||
import com.mcwl.resource.domain.ModelImageLike;
|
||||
import com.mcwl.resource.domain.dto.ModelImageCommentRes;
|
||||
import com.mcwl.resource.domain.SysAdvice;
|
||||
import com.mcwl.resource.mapper.ModelImageCommentLikeMapper;
|
||||
import com.mcwl.resource.mapper.ModelImageCommentMapper;
|
||||
import com.mcwl.resource.service.ModelImageCommentLikeService;
|
||||
import com.mcwl.resource.service.ModelImageCommentService;
|
||||
import com.mcwl.system.domain.enums.AdviceEnum;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
@ -46,6 +45,7 @@ public class ModelImageCommentLikeServiceImpl extends ServiceImpl<ModelImageComm
|
|||
} else {
|
||||
modelImageCommentLike.setDelFlag("0");
|
||||
modelImageComment.setLikeNum(modelImageComment.getLikeNum() + 1);
|
||||
this.addLikeAdvice(modelImageComment);
|
||||
}
|
||||
// 更新点赞记录
|
||||
baseMapper.updateDelFlagById(modelImageCommentLike);
|
||||
|
@ -66,6 +66,36 @@ public class ModelImageCommentLikeServiceImpl extends ServiceImpl<ModelImageComm
|
|||
// 更新图片点赞数
|
||||
modelImageComment.setLikeNum(modelImageComment.getLikeNum() + 1);
|
||||
modelImageCommentMapper.updateById(modelImageComment);
|
||||
|
||||
this.addLikeAdvice(modelImageComment);
|
||||
}
|
||||
|
||||
|
||||
private void addLikeAdvice(ModelImageComment modelImageComment) {
|
||||
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
Long receiverUserId = modelImageComment.getUserId();
|
||||
|
||||
if (Objects.equals(userId, receiverUserId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String content = StringUtils.format("恭喜!{}点赞了您的评论",
|
||||
SecurityUtils.getUsername());
|
||||
|
||||
SysAdvice sysAdvice = new SysAdvice();
|
||||
sysAdvice.setSenderId(userId);
|
||||
sysAdvice.setReceiverId(receiverUserId);
|
||||
sysAdvice.setContent(content);
|
||||
sysAdvice.setProductId(modelImageComment.getModelImageId());
|
||||
sysAdvice.setProductType(2);
|
||||
sysAdvice.setCommentId(modelImageComment.getId());
|
||||
sysAdvice.setIsRead(0);
|
||||
sysAdvice.setType(AdviceEnum.LIKE_REMIND);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -15,12 +16,14 @@ import com.mcwl.common.utils.SecurityUtils;
|
|||
import com.mcwl.common.utils.StringUtils;
|
||||
import com.mcwl.resource.domain.ModelImage;
|
||||
import com.mcwl.resource.domain.ModelImageLike;
|
||||
import com.mcwl.resource.domain.SysAdvice;
|
||||
import com.mcwl.resource.domain.response.ResponseModelImage;
|
||||
import com.mcwl.resource.domain.vo.ModelImageLikeVo;
|
||||
import com.mcwl.resource.domain.vo.PageVo;
|
||||
import com.mcwl.resource.mapper.ModelImageLikeMapper;
|
||||
import com.mcwl.resource.mapper.ModelImageMapper;
|
||||
import com.mcwl.resource.service.ModelImageLikeService;
|
||||
import com.mcwl.system.domain.enums.AdviceEnum;
|
||||
import com.mcwl.system.service.ISysUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -60,6 +63,7 @@ public class ModelImageLikeServiceImpl extends ServiceImpl<ModelImageLikeMapper,
|
|||
} else {
|
||||
modelImageLike.setDelFlag("0");
|
||||
modelImage.setLikeNum(modelImage.getLikeNum() + 1);
|
||||
this.addLikeAdvice(modelImage);
|
||||
}
|
||||
// 更新点赞记录
|
||||
baseMapper.updateDelFlagById(modelImageLike);
|
||||
|
@ -80,6 +84,8 @@ public class ModelImageLikeServiceImpl extends ServiceImpl<ModelImageLikeMapper,
|
|||
// 更新图片点赞数
|
||||
modelImage.setLikeNum(modelImage.getLikeNum() + 1);
|
||||
modelImageMapper.updateById(modelImage);
|
||||
|
||||
this.addLikeAdvice(modelImage);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -162,14 +168,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);
|
||||
|
@ -180,4 +195,31 @@ public class ModelImageLikeServiceImpl extends ServiceImpl<ModelImageLikeMapper,
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void addLikeAdvice(ModelImage modelImage) {
|
||||
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
Long receiverUserId = modelImage.getUserId();
|
||||
|
||||
if (Objects.equals(userId, receiverUserId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String content = StringUtils.format("恭喜!{}点赞了您的图片:{}",
|
||||
SecurityUtils.getUsername(), modelImage.getTitle());
|
||||
|
||||
SysAdvice sysAdvice = new SysAdvice();
|
||||
sysAdvice.setSenderId(userId);
|
||||
sysAdvice.setReceiverId(receiverUserId);
|
||||
sysAdvice.setContent(content);
|
||||
sysAdvice.setProductId(modelImage.getId());
|
||||
sysAdvice.setProductType(2);
|
||||
sysAdvice.setIsRead(0);
|
||||
sysAdvice.setType(AdviceEnum.LIKE_REMIND);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -11,11 +11,14 @@ import com.mcwl.common.core.page.TableDataInfo;
|
|||
import com.mcwl.common.exception.ServiceException;
|
||||
import com.mcwl.common.utils.SecurityUtils;
|
||||
import com.mcwl.common.utils.StringUtils;
|
||||
import com.mcwl.resource.domain.*;
|
||||
import com.mcwl.resource.domain.ModelLike;
|
||||
import com.mcwl.resource.domain.ModelProduct;
|
||||
import com.mcwl.resource.domain.SysAdvice;
|
||||
import com.mcwl.resource.domain.vo.ModelLikeVo;
|
||||
import com.mcwl.resource.mapper.ModelMapper;
|
||||
import com.mcwl.resource.mapper.ModelLikeMapper;
|
||||
import com.mcwl.resource.mapper.ModelMapper;
|
||||
import com.mcwl.resource.service.ModelLikeService;
|
||||
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;
|
||||
|
@ -41,7 +44,7 @@ public class ModelLikeServiceImpl extends ServiceImpl<ModelLikeMapper, ModelLike
|
|||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void like(Long modelId) {
|
||||
ModelProduct model = modelMapper.selectById(modelId);
|
||||
if (Objects.isNull(model)) {
|
||||
|
@ -58,6 +61,7 @@ public class ModelLikeServiceImpl extends ServiceImpl<ModelLikeMapper, ModelLike
|
|||
} else {
|
||||
modelLike.setDelFlag("0");
|
||||
model.setLikeNum(model.getLikeNum() + 1);
|
||||
this.addLikeAdvice(model);
|
||||
}
|
||||
// 更新点赞记录
|
||||
baseMapper.updateDelFlagById(modelLike);
|
||||
|
@ -78,6 +82,8 @@ public class ModelLikeServiceImpl extends ServiceImpl<ModelLikeMapper, ModelLike
|
|||
// 更新图片点赞数
|
||||
model.setNumbers(model.getLikeNum() + 1);
|
||||
modelMapper.updateById(model);
|
||||
|
||||
this.addLikeAdvice(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -126,6 +132,32 @@ public class ModelLikeServiceImpl extends ServiceImpl<ModelLikeMapper, ModelLike
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void addLikeAdvice(ModelProduct model) {
|
||||
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
Long receiverUserId = model.getUserId();
|
||||
|
||||
if (Objects.equals(userId, receiverUserId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String content = StringUtils.format("恭喜!{}点赞了您的模型:{}",
|
||||
SecurityUtils.getUsername(), model.getModelName());
|
||||
|
||||
SysAdvice sysAdvice = new SysAdvice();
|
||||
sysAdvice.setSenderId(userId);
|
||||
sysAdvice.setReceiverId(receiverUserId);
|
||||
sysAdvice.setContent(content);
|
||||
sysAdvice.setProductId(model.getId());
|
||||
sysAdvice.setProductType(0);
|
||||
sysAdvice.setIsRead(0);
|
||||
sysAdvice.setType(AdviceEnum.LIKE_REMIND);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private Page<ModelLike> initPage(PageDomain pageDomain) {
|
||||
Page<ModelLike> page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize());
|
||||
if (StringUtils.isBlank(pageDomain.getOrderByColumn())) {
|
||||
|
@ -136,4 +168,6 @@ public class ModelLikeServiceImpl extends ServiceImpl<ModelLikeMapper, ModelLike
|
|||
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,288 @@
|
|||
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.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
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.SysAdvice;
|
||||
import com.mcwl.resource.domain.WorkFlow;
|
||||
import com.mcwl.resource.domain.vo.AdviceVo;
|
||||
import com.mcwl.resource.domain.vo.AttentionAdviceVo;
|
||||
import com.mcwl.resource.domain.vo.CommentAdviceVo;
|
||||
import com.mcwl.resource.domain.vo.LikeAdviceVo;
|
||||
import com.mcwl.resource.mapper.SysAdviceMapper;
|
||||
import com.mcwl.resource.service.ISysAdviceService;
|
||||
import com.mcwl.resource.service.ModelImageService;
|
||||
import com.mcwl.resource.service.ModelService;
|
||||
import com.mcwl.resource.service.WorkFlowService;
|
||||
import com.mcwl.system.domain.enums.AdviceEnum;
|
||||
import com.mcwl.system.service.ISysUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
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> getAllMsg() {
|
||||
|
||||
// 创建分页对象
|
||||
Page<SysAdvice> page = new Page<>(1, 20);
|
||||
|
||||
LambdaQueryWrapper<SysAdvice> lqw = new LambdaQueryWrapper<SysAdvice>()
|
||||
.and(wrapper -> wrapper
|
||||
.eq(SysAdvice::getReceiverId, SecurityUtils.getUserId())
|
||||
.or()
|
||||
.isNull(SysAdvice::getReceiverId)
|
||||
)
|
||||
.orderByDesc(SysAdvice::getCreateTime);
|
||||
|
||||
Page<SysAdvice> sysAdvicePage = baseMapper.selectPage(page, lqw);
|
||||
|
||||
|
||||
List<SysAdvice> sysAdvices = sysAdvicePage.getRecords();
|
||||
|
||||
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)
|
||||
.orderByDesc(SysAdvice::getCreateTime));
|
||||
|
||||
|
||||
List<Long> commentUserIdList = new ArrayList<>();
|
||||
for (SysAdvice sysAdvice : sysAdviceList) {
|
||||
commentUserIdList.add(sysAdvice.getSenderId());
|
||||
}
|
||||
List<SysUser> sysUsers = sysUserService.listByIds(commentUserIdList);
|
||||
|
||||
Map<Long, SysUser> commentUserMap = new HashMap<>();
|
||||
for (SysUser sysUser : sysUsers) {
|
||||
commentUserMap.put(sysUser.getUserId(), sysUser);
|
||||
}
|
||||
|
||||
List<CommentAdviceVo> commentAdviceVoList = new ArrayList<>();
|
||||
for (SysAdvice sysAdvice : sysAdviceList) {
|
||||
CommentAdviceVo commentAdviceVo = BeanUtil.copyProperties(sysAdvice, CommentAdviceVo.class);
|
||||
|
||||
Long senderId = sysAdvice.getSenderId();
|
||||
SysUser senderUser = commentUserMap.get(senderId);
|
||||
if (Objects.nonNull(senderUser)) {
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LikeAdviceVo> getLikeMsg(Integer productType) {
|
||||
this.postConstruct();
|
||||
List<SysAdvice> sysAdviceList;
|
||||
if (productType == 3) {
|
||||
sysAdviceList = baseMapper.selectList(new LambdaQueryWrapper<SysAdvice>()
|
||||
.eq(SysAdvice::getType, AdviceEnum.LIKE_REMIND)
|
||||
.eq(SysAdvice::getReceiverId, SecurityUtils.getUserId())
|
||||
.isNotNull(SysAdvice::getCommentId)
|
||||
.orderByDesc(SysAdvice::getCreateTime));
|
||||
} else {
|
||||
sysAdviceList = baseMapper.selectList(new LambdaQueryWrapper<SysAdvice>()
|
||||
.eq(SysAdvice::getType, AdviceEnum.LIKE_REMIND)
|
||||
.eq(SysAdvice::getReceiverId, SecurityUtils.getUserId())
|
||||
.eq(productType != 4, SysAdvice::getProductType, productType)
|
||||
.orderByDesc(SysAdvice::getCreateTime));
|
||||
}
|
||||
|
||||
List<Long> likeUserIdList = new ArrayList<>();
|
||||
for (SysAdvice sysAdvice : sysAdviceList) {
|
||||
likeUserIdList.add(sysAdvice.getSenderId());
|
||||
}
|
||||
List<SysUser> sysUsers = sysUserService.listByIds(likeUserIdList);
|
||||
|
||||
Map<Long, SysUser> likeUserMap = new HashMap<>();
|
||||
for (SysUser sysUser : sysUsers) {
|
||||
likeUserMap.put(sysUser.getUserId(), sysUser);
|
||||
}
|
||||
|
||||
|
||||
List<LikeAdviceVo> likeAdviceVoList = new ArrayList<>();
|
||||
for (SysAdvice sysAdvice : sysAdviceList) {
|
||||
LikeAdviceVo likeAdviceVo = BeanUtil.copyProperties(sysAdvice, LikeAdviceVo.class);
|
||||
|
||||
Long senderId = sysAdvice.getSenderId();
|
||||
SysUser senderUser = likeUserMap.get(senderId);
|
||||
if (Objects.nonNull(senderUser)) {
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AttentionAdviceVo> getAttentionMsg() {
|
||||
List<SysAdvice> sysAdviceList = baseMapper.selectList(new LambdaQueryWrapper<SysAdvice>()
|
||||
.eq(SysAdvice::getType, AdviceEnum.FANS_REMIND)
|
||||
.eq(SysAdvice::getReceiverId, SecurityUtils.getUserId())
|
||||
.orderByDesc(SysAdvice::getCreateTime));
|
||||
|
||||
List<AttentionAdviceVo> attentionAdviceVoList = new ArrayList<>();
|
||||
List<Long> atentUserIdList = new ArrayList<>();
|
||||
|
||||
// 通知表中获取所有关注我的用户id
|
||||
for (SysAdvice sysAdvice : sysAdviceList) {
|
||||
atentUserIdList.add(sysAdvice.getSenderId());
|
||||
}
|
||||
|
||||
// 构建map, key为用户id,value为用户信息
|
||||
Map<Long, SysUser> attentionUserMap = new HashMap<>();
|
||||
|
||||
// 批量查询用户信息, 并构建映射关系
|
||||
List<SysUser> atentUserList = sysUserService.listByIds(atentUserIdList);
|
||||
for (SysUser sysUser : atentUserList) {
|
||||
attentionUserMap.put(sysUser.getUserId(), sysUser);
|
||||
}
|
||||
|
||||
for (SysAdvice sysAdvice : sysAdviceList) {
|
||||
AttentionAdviceVo attentionAdviceVo = BeanUtil.copyProperties(sysAdvice, AttentionAdviceVo.class);
|
||||
Long senderId = sysAdvice.getSenderId();
|
||||
SysUser attentionUser = attentionUserMap.get(senderId);
|
||||
if (Objects.nonNull(attentionUser)) {
|
||||
attentionAdviceVo.setUserAvatar(attentionUser.getAvatar());
|
||||
}
|
||||
attentionAdviceVoList.add(attentionAdviceVo);
|
||||
}
|
||||
|
||||
return attentionAdviceVoList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(Long adviceId) {
|
||||
SysAdvice sysAdvice = baseMapper.selectById(adviceId);
|
||||
|
||||
if (Objects.isNull(sysAdvice)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Long receiverId = sysAdvice.getReceiverId();
|
||||
if (!Objects.equals(SecurityUtils.getUserId(), receiverId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
sysAdvice.setIsRead(1);
|
||||
baseMapper.updateById(sysAdvice);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readAll() {
|
||||
List<SysAdvice> sysAdviceList = baseMapper.selectList(new LambdaQueryWrapper<SysAdvice>()
|
||||
.eq(SysAdvice::getIsRead, 0)
|
||||
.eq(SysAdvice::getReceiverId, SecurityUtils.getUserId()));
|
||||
for (SysAdvice sysAdvice : sysAdviceList) {
|
||||
sysAdvice.setIsRead(1);
|
||||
baseMapper.updateById(sysAdvice);
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -2,10 +2,11 @@ package com.mcwl.resource.service.impl;
|
|||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.mcwl.common.core.domain.AjaxResult;
|
||||
import com.mcwl.common.core.domain.R;
|
||||
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.SysAdvice;
|
||||
import com.mcwl.resource.domain.SysUserAttention;
|
||||
import com.mcwl.resource.domain.SysUserInfo;
|
||||
import com.mcwl.resource.domain.vo.PageVo;
|
||||
|
@ -14,6 +15,7 @@ import com.mcwl.resource.mapper.ModelImageMapper;
|
|||
import com.mcwl.resource.mapper.ModelMapper;
|
||||
import com.mcwl.resource.mapper.SysUserAttentionMapper;
|
||||
import com.mcwl.resource.service.SysUserAttentionService;
|
||||
import com.mcwl.system.domain.enums.AdviceEnum;
|
||||
import com.mcwl.system.mapper.SysUserMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -53,7 +55,7 @@ public class SysUserAttentionServiceImpl implements SysUserAttentionService {
|
|||
|
||||
//查看是否已关注
|
||||
Boolean aBoolean = selectAttention(userId);
|
||||
if (aBoolean == true) {
|
||||
if (aBoolean) {
|
||||
//取关
|
||||
sysUserAttentionMapper.deleteByUserId(SecurityUtils.getUserId(), userId);
|
||||
return R.ok(false);
|
||||
|
@ -66,6 +68,18 @@ public class SysUserAttentionServiceImpl implements SysUserAttentionService {
|
|||
.createTime(new Date())
|
||||
.build();
|
||||
sysUserAttentionMapper.insert(sysUserAttention);
|
||||
|
||||
|
||||
// 添加通知
|
||||
String content = StringUtils.format("{}关注了您,快去看看吧!", SecurityUtils.getUsername());
|
||||
SysAdvice sysAdvice = new SysAdvice();
|
||||
sysAdvice.setSenderId(SecurityUtils.getUserId());
|
||||
sysAdvice.setReceiverId(userId);
|
||||
sysAdvice.setContent(content);
|
||||
sysAdvice.setIsRead(0);
|
||||
sysAdvice.setType(AdviceEnum.FANS_REMIND);
|
||||
|
||||
|
||||
return R.ok(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<WorkFlowCommentL
|
|||
} else {
|
||||
workFlowCommentLike.setDelFlag("0");
|
||||
workFlowComment.setLikeNum(workFlowComment.getLikeNum() + 1);
|
||||
this.addLikeAdvice(workFlowComment);
|
||||
}
|
||||
// 更新点赞记录
|
||||
baseMapper.updateDelFlagById(workFlowCommentLike);
|
||||
|
@ -67,6 +71,34 @@ public class WorkFlowCommentLikeServiceImpl extends ServiceImpl<WorkFlowCommentL
|
|||
// 更新模型点赞数
|
||||
workFlowComment.setLikeNum(workFlowComment.getLikeNum() + 1);
|
||||
workFlowCommentMapper.updateById(workFlowComment);
|
||||
|
||||
this.addLikeAdvice(workFlowComment);
|
||||
}
|
||||
|
||||
|
||||
private void addLikeAdvice(WorkFlowComment workFlowComment) {
|
||||
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
Long receiverUserId = workFlowComment.getUserId();
|
||||
|
||||
if (Objects.equals(userId, receiverUserId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String content = StringUtils.format("恭喜!{}点赞了您的评论",
|
||||
SecurityUtils.getUsername());
|
||||
|
||||
SysAdvice sysAdvice = new SysAdvice();
|
||||
sysAdvice.setSenderId(userId);
|
||||
sysAdvice.setReceiverId(receiverUserId);
|
||||
sysAdvice.setContent(content);
|
||||
sysAdvice.setProductId(workFlowComment.getWorkFlowId());
|
||||
sysAdvice.setProductType(1);
|
||||
sysAdvice.setCommentId(workFlowComment.getId());
|
||||
sysAdvice.setIsRead(0);
|
||||
sysAdvice.setType(AdviceEnum.LIKE_REMIND);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -12,12 +12,14 @@ import com.mcwl.common.core.page.TableDataInfo;
|
|||
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.WorkFlow;
|
||||
import com.mcwl.resource.domain.WorkFlowLike;
|
||||
import com.mcwl.resource.domain.vo.WorkFlowLikeVo;
|
||||
import com.mcwl.resource.mapper.WorkFlowLikeMapper;
|
||||
import com.mcwl.resource.mapper.WorkFlowMapper;
|
||||
import com.mcwl.resource.service.WorkFlowLikeService;
|
||||
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;
|
||||
|
@ -65,6 +67,7 @@ public class WorkFlowLikeServiceImpl extends ServiceImpl<WorkFlowLikeMapper, Wor
|
|||
} else {
|
||||
workFlowLike.setDelFlag("0");
|
||||
workFlow.setLikeCount(workFlow.getLikeCount() + 1);
|
||||
this.addLikeAdvice(workFlow);
|
||||
}
|
||||
// 更新点赞记录
|
||||
baseMapper.updateStatus(workFlowLike);
|
||||
|
@ -85,6 +88,8 @@ public class WorkFlowLikeServiceImpl extends ServiceImpl<WorkFlowLikeMapper, Wor
|
|||
// 更新图片点赞数
|
||||
workFlow.setLikeCount(workFlow.getLikeCount() + 1);
|
||||
workFlowMapper.updateById(workFlow);
|
||||
|
||||
this.addLikeAdvice(workFlow);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -143,6 +148,31 @@ public class WorkFlowLikeServiceImpl extends ServiceImpl<WorkFlowLikeMapper, Wor
|
|||
}
|
||||
|
||||
|
||||
private void addLikeAdvice(WorkFlow workFlow) {
|
||||
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
Long receiverUserId = workFlow.getUserId();
|
||||
|
||||
if (Objects.equals(userId, receiverUserId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String content = StringUtils.format("恭喜!{}点赞了您的工作流:{}",
|
||||
SecurityUtils.getUsername(), workFlow.getWorkflowName());
|
||||
|
||||
SysAdvice sysAdvice = new SysAdvice();
|
||||
sysAdvice.setSenderId(userId);
|
||||
sysAdvice.setReceiverId(receiverUserId);
|
||||
sysAdvice.setContent(content);
|
||||
sysAdvice.setProductId(workFlow.getId());
|
||||
sysAdvice.setProductType(1);
|
||||
sysAdvice.setIsRead(0);
|
||||
sysAdvice.setType(AdviceEnum.LIKE_REMIND);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private Page<WorkFlowLike> initPage(PageDomain pageDomain) {
|
||||
Page<WorkFlowLike> page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize());
|
||||
if (StringUtils.isBlank(pageDomain.getOrderByColumn())) {
|
||||
|
|
|
@ -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,29 +0,0 @@
|
|||
package com.mcwl.system.domain.vo;
|
||||
|
||||
import com.mcwl.system.domain.enums.AdviceEnum;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AdviceVo {
|
||||
|
||||
/**
|
||||
* 消息类型 表示新消息提醒,系统公告等
|
||||
*/
|
||||
private AdviceEnum type;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 是否已读 0 是 1 否
|
||||
*/
|
||||
private String isRead;
|
||||
|
||||
}
|
|
@ -138,8 +138,6 @@ public interface SysUserMapper
|
|||
|
||||
List<SysUser> listByIds(List<Long> userIdList);
|
||||
|
||||
List<SysUser> selectUserByIds(@Param("userIds") List<Long> userIds);
|
||||
|
||||
List<SysUser> selectUserPage(@Param("userId") Long userId);
|
||||
|
||||
List<SysUser> selectToUserPage(@Param("userId") Long userId);
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
package com.mcwl.system.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 java.util.List;
|
||||
|
||||
/**
|
||||
* 消息通知 服务层
|
||||
*
|
||||
* @author mcwl
|
||||
*/
|
||||
public interface ISysAdviceService extends IService<SysAdvice> {
|
||||
|
||||
List<AdviceVo> getUserNewMsg();
|
||||
|
||||
List<AdviceVo> getUserSystemNotice();
|
||||
|
||||
List<AdviceVo> getUserAllMsg();
|
||||
|
||||
List<AdviceVo> getAllMsg();
|
||||
}
|
|
@ -217,6 +217,4 @@ public interface ISysUserService
|
|||
AjaxResult updateIdCard(SysUser sysUser);
|
||||
|
||||
List<SysUser> listByIds(List<Long> userIdList);
|
||||
|
||||
List<SysUser> selectUserByIds(List<Long> userIds);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -653,6 +653,9 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
|
||||
@Override
|
||||
public List<SysUser> listByIds(List<Long> userIdList) {
|
||||
if (userIdList == null || userIdList.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return userMapper.listByIds(userIdList);
|
||||
}
|
||||
|
||||
|
@ -675,9 +678,4 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUser> selectUserByIds(List<Long> userIds) {
|
||||
return userMapper.selectUserByIds(userIds);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -167,14 +167,6 @@
|
|||
|
||||
</select>
|
||||
|
||||
<select id="selectUserByIds" resultType="com.mcwl.common.core.domain.entity.SysUser">
|
||||
<include refid="selectUserVo"/>
|
||||
where u.user_id in
|
||||
<foreach collection="userIds" item="userId" open="(" separator="," close=")">
|
||||
#{userId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="selectUserPage" resultType="com.mcwl.common.core.domain.entity.SysUser">
|
||||
select u.user_id,nick_name,avatar FROM sys_user_attention as a
|
||||
LEFT JOIN sys_user as u
|
||||
|
|
Loading…
Reference in New Issue