feat(resource): 点赞消息

master
yang 2025-02-15 23:21:57 +08:00
parent 7e40833bb7
commit 5a5ab268dd
12 changed files with 307 additions and 33 deletions

View File

@ -3,6 +3,7 @@ package com.mcwl.web.controller.system;
import com.mcwl.common.core.domain.R; import com.mcwl.common.core.domain.R;
import com.mcwl.resource.domain.vo.AdviceVo; import com.mcwl.resource.domain.vo.AdviceVo;
import com.mcwl.resource.domain.vo.CommentAdviceVo; import com.mcwl.resource.domain.vo.CommentAdviceVo;
import com.mcwl.resource.domain.vo.LikeAdviceVo;
import com.mcwl.resource.service.ISysAdviceService; import com.mcwl.resource.service.ISysAdviceService;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -73,5 +74,17 @@ public class SysAdviceController {
return R.ok(adviceVo); return R.ok(adviceVo);
} }
/**
*
*/
@GetMapping("getLikeMsg")
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);
}
} }

View File

@ -48,6 +48,11 @@ public class SysAdvice extends BaseEntity {
*/ */
private Integer productType; private Integer productType;
/**
* id
*/
private Long commentId;
/** /**
* 0 1 * 0 1
*/ */

View File

@ -7,7 +7,7 @@ import lombok.Data;
import java.util.Date; import java.util.Date;
@Data @Data
@ApiModel(description = "评论回复消息") @ApiModel(description = "评论/点赞消息")
public class CommentAdviceVo { public class CommentAdviceVo {
/** /**
@ -17,9 +17,9 @@ public class CommentAdviceVo {
private Long id; private Long id;
/** /**
* * /
*/ */
@ApiModelProperty(value = "评论用户头像") @ApiModelProperty(value = "评论/点赞用户头像")
private String userAvatar; private String userAvatar;
/** /**
@ -30,21 +30,21 @@ public class CommentAdviceVo {
/** /**
* id * /id
*/ */
@ApiModelProperty(value = "评论的商品id") @ApiModelProperty(value = "评论/点赞的商品id")
private Long productId; private Long productId;
/** /**
* * /
*/ */
@ApiModelProperty(value = "商品图片") @ApiModelProperty(value = "商品图片")
private String productImag; private String productImag;
/** /**
* 0 1 2 * / 0 1 2
*/ */
@ApiModelProperty(value = "评论的商品类型 0模型 1工作流 2图片") @ApiModelProperty(value = "评论/点赞的商品类型 0模型 1工作流 2图片")
private Integer productType; private Integer productType;
/** /**

View File

@ -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;
}

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.mcwl.resource.domain.SysAdvice; import com.mcwl.resource.domain.SysAdvice;
import com.mcwl.resource.domain.vo.AdviceVo; import com.mcwl.resource.domain.vo.AdviceVo;
import com.mcwl.resource.domain.vo.CommentAdviceVo; import com.mcwl.resource.domain.vo.CommentAdviceVo;
import com.mcwl.resource.domain.vo.LikeAdviceVo;
import java.util.List; import java.util.List;
@ -23,4 +24,6 @@ public interface ISysAdviceService extends IService<SysAdvice> {
List<AdviceVo> getAllMsg(); List<AdviceVo> getAllMsg();
List<CommentAdviceVo> getCommentMsg(Integer productType); List<CommentAdviceVo> getCommentMsg(Integer productType);
List<LikeAdviceVo> getLikeMsg(Integer productType);
} }

View File

@ -1,27 +1,22 @@
package com.mcwl.resource.service.impl; 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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mcwl.common.exception.ServiceException; import com.mcwl.common.exception.ServiceException;
import com.mcwl.common.utils.SecurityUtils; import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.common.utils.StringUtils;
import com.mcwl.resource.domain.ModelComment; import com.mcwl.resource.domain.ModelComment;
import com.mcwl.resource.domain.ModelCommentLike; import com.mcwl.resource.domain.ModelCommentLike;
import com.mcwl.resource.domain.ModelImageComment; import com.mcwl.resource.domain.SysAdvice;
import com.mcwl.resource.domain.ModelImageCommentLike;
import com.mcwl.resource.mapper.ModelCommentLikeMapper; import com.mcwl.resource.mapper.ModelCommentLikeMapper;
import com.mcwl.resource.mapper.ModelCommentMapper; import com.mcwl.resource.mapper.ModelCommentMapper;
import com.mcwl.resource.mapper.ModelImageCommentMapper;
import com.mcwl.resource.service.ModelCommentLikeService; import com.mcwl.resource.service.ModelCommentLikeService;
import com.mcwl.system.domain.enums.AdviceEnum;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.function.Function;
/** /**
* *
@ -50,6 +45,7 @@ public class ModelCommentLikeServiceImpl extends ServiceImpl<ModelCommentLikeMap
} else { } else {
modelCommentLike.setDelFlag("0"); modelCommentLike.setDelFlag("0");
modelComment.setLikeNum(modelComment.getLikeNum() + 1); modelComment.setLikeNum(modelComment.getLikeNum() + 1);
this.addLikeAdvice(modelComment);
} }
// 更新点赞记录 // 更新点赞记录
baseMapper.updateDelFlagById(modelCommentLike); baseMapper.updateDelFlagById(modelCommentLike);
@ -70,6 +66,35 @@ public class ModelCommentLikeServiceImpl extends ServiceImpl<ModelCommentLikeMap
// 更新模型点赞数 // 更新模型点赞数
modelComment.setLikeNum(modelComment.getLikeNum() + 1); modelComment.setLikeNum(modelComment.getLikeNum() + 1);
modelCommentMapper.updateById(modelComment); 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);
}
} }

View File

@ -3,15 +3,14 @@ package com.mcwl.resource.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mcwl.common.exception.ServiceException; import com.mcwl.common.exception.ServiceException;
import com.mcwl.common.utils.SecurityUtils; 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.ModelImageComment;
import com.mcwl.resource.domain.ModelImageCommentLike; import com.mcwl.resource.domain.ModelImageCommentLike;
import com.mcwl.resource.domain.ModelImageLike; import com.mcwl.resource.domain.SysAdvice;
import com.mcwl.resource.domain.dto.ModelImageCommentRes;
import com.mcwl.resource.mapper.ModelImageCommentLikeMapper; import com.mcwl.resource.mapper.ModelImageCommentLikeMapper;
import com.mcwl.resource.mapper.ModelImageCommentMapper; import com.mcwl.resource.mapper.ModelImageCommentMapper;
import com.mcwl.resource.service.ModelImageCommentLikeService; import com.mcwl.resource.service.ModelImageCommentLikeService;
import com.mcwl.resource.service.ModelImageCommentService; import com.mcwl.system.domain.enums.AdviceEnum;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -46,6 +45,7 @@ public class ModelImageCommentLikeServiceImpl extends ServiceImpl<ModelImageComm
} else { } else {
modelImageCommentLike.setDelFlag("0"); modelImageCommentLike.setDelFlag("0");
modelImageComment.setLikeNum(modelImageComment.getLikeNum() + 1); modelImageComment.setLikeNum(modelImageComment.getLikeNum() + 1);
this.addLikeAdvice(modelImageComment);
} }
// 更新点赞记录 // 更新点赞记录
baseMapper.updateDelFlagById(modelImageCommentLike); baseMapper.updateDelFlagById(modelImageCommentLike);
@ -66,6 +66,36 @@ public class ModelImageCommentLikeServiceImpl extends ServiceImpl<ModelImageComm
// 更新图片点赞数 // 更新图片点赞数
modelImageComment.setLikeNum(modelImageComment.getLikeNum() + 1); modelImageComment.setLikeNum(modelImageComment.getLikeNum() + 1);
modelImageCommentMapper.updateById(modelImageComment); 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);
}
} }

View File

@ -16,18 +16,23 @@ import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.common.utils.StringUtils; import com.mcwl.common.utils.StringUtils;
import com.mcwl.resource.domain.ModelImage; import com.mcwl.resource.domain.ModelImage;
import com.mcwl.resource.domain.ModelImageLike; import com.mcwl.resource.domain.ModelImageLike;
import com.mcwl.resource.domain.SysAdvice;
import com.mcwl.resource.domain.response.ResponseModelImage; import com.mcwl.resource.domain.response.ResponseModelImage;
import com.mcwl.resource.domain.vo.ModelImageLikeVo; import com.mcwl.resource.domain.vo.ModelImageLikeVo;
import com.mcwl.resource.domain.vo.PageVo; import com.mcwl.resource.domain.vo.PageVo;
import com.mcwl.resource.mapper.ModelImageLikeMapper; import com.mcwl.resource.mapper.ModelImageLikeMapper;
import com.mcwl.resource.mapper.ModelImageMapper; import com.mcwl.resource.mapper.ModelImageMapper;
import com.mcwl.resource.service.ModelImageLikeService; import com.mcwl.resource.service.ModelImageLikeService;
import com.mcwl.system.domain.enums.AdviceEnum;
import com.mcwl.system.service.ISysUserService; import com.mcwl.system.service.ISysUserService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.*; import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/** /**
* *
@ -58,6 +63,7 @@ public class ModelImageLikeServiceImpl extends ServiceImpl<ModelImageLikeMapper,
} else { } else {
modelImageLike.setDelFlag("0"); modelImageLike.setDelFlag("0");
modelImage.setLikeNum(modelImage.getLikeNum() + 1); modelImage.setLikeNum(modelImage.getLikeNum() + 1);
this.addLikeAdvice(modelImage);
} }
// 更新点赞记录 // 更新点赞记录
baseMapper.updateDelFlagById(modelImageLike); baseMapper.updateDelFlagById(modelImageLike);
@ -78,6 +84,8 @@ public class ModelImageLikeServiceImpl extends ServiceImpl<ModelImageLikeMapper,
// 更新图片点赞数 // 更新图片点赞数
modelImage.setLikeNum(modelImage.getLikeNum() + 1); modelImage.setLikeNum(modelImage.getLikeNum() + 1);
modelImageMapper.updateById(modelImage); modelImageMapper.updateById(modelImage);
this.addLikeAdvice(modelImage);
} }
@Override @Override
@ -187,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);
}
} }

View File

@ -11,11 +11,14 @@ import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.common.exception.ServiceException; import com.mcwl.common.exception.ServiceException;
import com.mcwl.common.utils.SecurityUtils; import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.common.utils.StringUtils; 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.domain.vo.ModelLikeVo;
import com.mcwl.resource.mapper.ModelMapper;
import com.mcwl.resource.mapper.ModelLikeMapper; import com.mcwl.resource.mapper.ModelLikeMapper;
import com.mcwl.resource.mapper.ModelMapper;
import com.mcwl.resource.service.ModelLikeService; import com.mcwl.resource.service.ModelLikeService;
import com.mcwl.system.domain.enums.AdviceEnum;
import com.mcwl.system.service.ISysUserService; import com.mcwl.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -41,7 +44,7 @@ public class ModelLikeServiceImpl extends ServiceImpl<ModelLikeMapper, ModelLike
@Override @Override
@Transactional @Transactional(rollbackFor = Exception.class)
public void like(Long modelId) { public void like(Long modelId) {
ModelProduct model = modelMapper.selectById(modelId); ModelProduct model = modelMapper.selectById(modelId);
if (Objects.isNull(model)) { if (Objects.isNull(model)) {
@ -58,6 +61,7 @@ public class ModelLikeServiceImpl extends ServiceImpl<ModelLikeMapper, ModelLike
} else { } else {
modelLike.setDelFlag("0"); modelLike.setDelFlag("0");
model.setLikeNum(model.getLikeNum() + 1); model.setLikeNum(model.getLikeNum() + 1);
this.addLikeAdvice(model);
} }
// 更新点赞记录 // 更新点赞记录
baseMapper.updateDelFlagById(modelLike); baseMapper.updateDelFlagById(modelLike);
@ -78,6 +82,8 @@ public class ModelLikeServiceImpl extends ServiceImpl<ModelLikeMapper, ModelLike
// 更新图片点赞数 // 更新图片点赞数
model.setNumbers(model.getLikeNum() + 1); model.setNumbers(model.getLikeNum() + 1);
modelMapper.updateById(model); modelMapper.updateById(model);
this.addLikeAdvice(model);
} }
@Override @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) { private Page<ModelLike> initPage(PageDomain pageDomain) {
Page<ModelLike> page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize()); Page<ModelLike> page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize());
if (StringUtils.isBlank(pageDomain.getOrderByColumn())) { if (StringUtils.isBlank(pageDomain.getOrderByColumn())) {
@ -136,4 +168,6 @@ public class ModelLikeServiceImpl extends ServiceImpl<ModelLikeMapper, ModelLike
return page; return page;
} }
} }

View File

@ -7,23 +7,25 @@ import com.mcwl.common.core.domain.entity.SysUser;
import com.mcwl.common.utils.SecurityUtils; import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.resource.domain.ModelImage; import com.mcwl.resource.domain.ModelImage;
import com.mcwl.resource.domain.ModelProduct; import com.mcwl.resource.domain.ModelProduct;
import com.mcwl.resource.domain.SysAdvice;
import com.mcwl.resource.domain.WorkFlow; import com.mcwl.resource.domain.WorkFlow;
import com.mcwl.resource.domain.vo.AdviceVo;
import com.mcwl.resource.domain.vo.CommentAdviceVo;
import com.mcwl.resource.domain.vo.LikeAdviceVo;
import com.mcwl.resource.mapper.SysAdviceMapper;
import com.mcwl.resource.service.ISysAdviceService;
import com.mcwl.resource.service.ModelImageService; import com.mcwl.resource.service.ModelImageService;
import com.mcwl.resource.service.ModelService; import com.mcwl.resource.service.ModelService;
import com.mcwl.resource.service.WorkFlowService; import com.mcwl.resource.service.WorkFlowService;
import com.mcwl.resource.domain.SysAdvice;
import com.mcwl.system.domain.enums.AdviceEnum; 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 com.mcwl.system.service.ISysUserService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct; import java.util.ArrayList;
import java.util.*; import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -128,6 +130,52 @@ public class SysAdviceServiceImpl extends ServiceImpl<SysAdviceMapper, SysAdvice
return commentAdviceVoList; 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));
} else {
sysAdviceList = baseMapper.selectList(new LambdaQueryWrapper<SysAdvice>()
.eq(SysAdvice::getType, AdviceEnum.LIKE_REMIND)
.eq(SysAdvice::getReceiverId, SecurityUtils.getUserId())
.eq(productType != 4, SysAdvice::getProductType, productType));
}
List<LikeAdviceVo> likeAdviceVoList = new ArrayList<>();
for (SysAdvice sysAdvice : sysAdviceList) {
LikeAdviceVo likeAdviceVo = BeanUtil.copyProperties(sysAdvice, LikeAdviceVo.class);
Long senderId = sysAdvice.getSenderId();
SysUser senderUser = sysUserService.selectUserById(senderId);
likeAdviceVo.setUserAvatar(senderUser.getAvatar());
if (productType == 0) {
ModelProduct modelProduct = modelProductMap.get(sysAdvice.getProductId());
if (Objects.nonNull(modelProduct)) {
likeAdviceVo.setProductImag(modelProduct.getSurfaceUrl());
}
} else if (productType == 1) {
WorkFlow workFlow = workFlowMap.get(sysAdvice.getProductId());
if (Objects.nonNull(workFlow)) {
likeAdviceVo.setProductImag(workFlow.getCoverPath());
}
} else if (productType == 2) {
ModelImage modelImage = modelImageMap.get(sysAdvice.getProductId());
if (Objects.nonNull(modelImage)) {
likeAdviceVo.setProductImag(modelImage.getImagePaths().split(",")[0]);
}
}
likeAdviceVoList.add(likeAdviceVo);
}
return likeAdviceVoList;
}
public void postConstruct() { public void postConstruct() {
Long userId = SecurityUtils.getUserId(); Long userId = SecurityUtils.getUserId();

View File

@ -3,11 +3,14 @@ package com.mcwl.resource.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mcwl.common.exception.ServiceException; import com.mcwl.common.exception.ServiceException;
import com.mcwl.common.utils.SecurityUtils; 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.WorkFlowComment;
import com.mcwl.resource.domain.WorkFlowCommentLike; import com.mcwl.resource.domain.WorkFlowCommentLike;
import com.mcwl.resource.mapper.WorkFlowCommentLikeMapper; import com.mcwl.resource.mapper.WorkFlowCommentLikeMapper;
import com.mcwl.resource.mapper.WorkFlowCommentMapper; import com.mcwl.resource.mapper.WorkFlowCommentMapper;
import com.mcwl.resource.service.WorkFlowCommentLikeService; import com.mcwl.resource.service.WorkFlowCommentLikeService;
import com.mcwl.system.domain.enums.AdviceEnum;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -47,6 +50,7 @@ public class WorkFlowCommentLikeServiceImpl extends ServiceImpl<WorkFlowCommentL
} else { } else {
workFlowCommentLike.setDelFlag("0"); workFlowCommentLike.setDelFlag("0");
workFlowComment.setLikeNum(workFlowComment.getLikeNum() + 1); workFlowComment.setLikeNum(workFlowComment.getLikeNum() + 1);
this.addLikeAdvice(workFlowComment);
} }
// 更新点赞记录 // 更新点赞记录
baseMapper.updateDelFlagById(workFlowCommentLike); baseMapper.updateDelFlagById(workFlowCommentLike);
@ -67,6 +71,34 @@ public class WorkFlowCommentLikeServiceImpl extends ServiceImpl<WorkFlowCommentL
// 更新模型点赞数 // 更新模型点赞数
workFlowComment.setLikeNum(workFlowComment.getLikeNum() + 1); workFlowComment.setLikeNum(workFlowComment.getLikeNum() + 1);
workFlowCommentMapper.updateById(workFlowComment); 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);
} }
} }

View File

@ -12,12 +12,14 @@ import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.common.exception.ServiceException; import com.mcwl.common.exception.ServiceException;
import com.mcwl.common.utils.SecurityUtils; import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.common.utils.StringUtils; import com.mcwl.common.utils.StringUtils;
import com.mcwl.resource.domain.SysAdvice;
import com.mcwl.resource.domain.WorkFlow; import com.mcwl.resource.domain.WorkFlow;
import com.mcwl.resource.domain.WorkFlowLike; import com.mcwl.resource.domain.WorkFlowLike;
import com.mcwl.resource.domain.vo.WorkFlowLikeVo; import com.mcwl.resource.domain.vo.WorkFlowLikeVo;
import com.mcwl.resource.mapper.WorkFlowLikeMapper; import com.mcwl.resource.mapper.WorkFlowLikeMapper;
import com.mcwl.resource.mapper.WorkFlowMapper; import com.mcwl.resource.mapper.WorkFlowMapper;
import com.mcwl.resource.service.WorkFlowLikeService; import com.mcwl.resource.service.WorkFlowLikeService;
import com.mcwl.system.domain.enums.AdviceEnum;
import com.mcwl.system.service.ISysUserService; import com.mcwl.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -65,6 +67,7 @@ public class WorkFlowLikeServiceImpl extends ServiceImpl<WorkFlowLikeMapper, Wor
} else { } else {
workFlowLike.setDelFlag("0"); workFlowLike.setDelFlag("0");
workFlow.setLikeCount(workFlow.getLikeCount() + 1); workFlow.setLikeCount(workFlow.getLikeCount() + 1);
this.addLikeAdvice(workFlow);
} }
// 更新点赞记录 // 更新点赞记录
baseMapper.updateStatus(workFlowLike); baseMapper.updateStatus(workFlowLike);
@ -85,6 +88,8 @@ public class WorkFlowLikeServiceImpl extends ServiceImpl<WorkFlowLikeMapper, Wor
// 更新图片点赞数 // 更新图片点赞数
workFlow.setLikeCount(workFlow.getLikeCount() + 1); workFlow.setLikeCount(workFlow.getLikeCount() + 1);
workFlowMapper.updateById(workFlow); workFlowMapper.updateById(workFlow);
this.addLikeAdvice(workFlow);
} }
@Override @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) { private Page<WorkFlowLike> initPage(PageDomain pageDomain) {
Page<WorkFlowLike> page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize()); Page<WorkFlowLike> page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize());
if (StringUtils.isBlank(pageDomain.getOrderByColumn())) { if (StringUtils.isBlank(pageDomain.getOrderByColumn())) {