Merge branch 'feature/admin' into preview
commit
5f6844dc29
|
@ -0,0 +1,87 @@
|
|||
package com.mcwl.web.controller.resource;
|
||||
|
||||
import com.mcwl.common.core.domain.AjaxResult;
|
||||
import com.mcwl.resource.domain.WorkFlowComment;
|
||||
import com.mcwl.resource.domain.vo.WorkFlowCommentVo;
|
||||
import com.mcwl.resource.service.WorkFlowCommentLikeService;
|
||||
import com.mcwl.resource.service.WorkFlowCommentService;
|
||||
import com.mcwl.resource.service.WorkFlowLikeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 工作流评论
|
||||
* @Author:ChenYan
|
||||
* @Project:McWl
|
||||
* @Package:com.mcwl.web.controller.resource
|
||||
* @Filename:ModelCommentcontroller
|
||||
* @Description TODO
|
||||
* @Date:2025/1/12 11:36
|
||||
*/
|
||||
@RequestMapping("/WorkFlowComment")
|
||||
@RestController
|
||||
public class WorkFlowCommentController {
|
||||
|
||||
@Autowired
|
||||
private WorkFlowLikeService workFlowLikeService;
|
||||
@Autowired
|
||||
private WorkFlowCommentService workFlowCommentService;
|
||||
@Autowired
|
||||
private WorkFlowCommentLikeService workFlowCommentLikeService;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 工作流点赞/取消
|
||||
*/
|
||||
@GetMapping("/like/{workFlowId}")
|
||||
public AjaxResult like(@PathVariable Long workFlowId) {
|
||||
workFlowLikeService.like(workFlowId);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 工作流评论发布
|
||||
*/
|
||||
@PostMapping("/comment")
|
||||
public AjaxResult comment(@RequestBody WorkFlowComment modelComment) {
|
||||
workFlowCommentService.comment(modelComment);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 工作流评论点赞/取消
|
||||
*/
|
||||
@GetMapping("/commentLike/{commentId}")
|
||||
public AjaxResult commentLike(@PathVariable Long commentId) {
|
||||
workFlowCommentLikeService.like(commentId);
|
||||
return AjaxResult.error();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取工作流评论
|
||||
*/
|
||||
@GetMapping("/comment/{modelId}")
|
||||
public AjaxResult getComment(@PathVariable @NotNull(message = "模型id不能为空") Long modelId) {
|
||||
List<WorkFlowCommentVo> modelCommentList = workFlowCommentService.getComment(modelId);
|
||||
return AjaxResult.success(modelCommentList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除工作流评论
|
||||
*/
|
||||
@GetMapping("/commentDelete/{commentId}")
|
||||
public AjaxResult commentDelete(@PathVariable @NotNull(message = "评论id不能为空") Long commentId) {
|
||||
workFlowCommentService.removeById(commentId);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.mcwl.resource.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.mcwl.common.core.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 工作流评论
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@TableName("work_flow_comment")
|
||||
public class WorkFlowComment extends BaseEntity {
|
||||
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 工作流id
|
||||
*/
|
||||
private Long workFlowId;
|
||||
|
||||
/**
|
||||
* 评论内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 父评论id
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 点赞数
|
||||
*/
|
||||
private Integer likeNum;
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.mcwl.resource.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.mcwl.common.core.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 工作流评论点赞
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@TableName("work_flow_comment_like")
|
||||
public class WorkFlowCommentLike extends BaseEntity {
|
||||
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 工作流评论id
|
||||
*/
|
||||
private Long workFlowCommentId;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.mcwl.resource.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.mcwl.common.core.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 模型点赞表
|
||||
*/
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@TableName("work_flow_like")
|
||||
public class WorkFlowLike extends BaseEntity {
|
||||
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 模型id
|
||||
*/
|
||||
private Long workFlowId;
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package com.mcwl.resource.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 工作流评论区评论
|
||||
*/
|
||||
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
public class WorkFlowCommentVo {
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 用户头像
|
||||
*/
|
||||
private String userAvatar;
|
||||
|
||||
/**
|
||||
* 评论id
|
||||
*/
|
||||
private Long commentId;
|
||||
|
||||
/**
|
||||
* 评论内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 子评论
|
||||
*/
|
||||
private List<WorkFlowCommentVo> contentList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 评论点赞数
|
||||
*/
|
||||
private Integer likeNum;
|
||||
|
||||
/**
|
||||
* 评论时间
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.mcwl.resource.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mcwl.resource.domain.WorkFlowCommentLike;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @Author:ChenYan
|
||||
* @Project:McWl
|
||||
* @Package:com.mcwl.resource.mapper
|
||||
* @Filename:ModelCommentLikeMapper
|
||||
* @Description TODO
|
||||
* @Date:2025/1/12 12:02
|
||||
*/
|
||||
@Mapper
|
||||
public interface WorkFlowCommentLikeMapper extends BaseMapper<WorkFlowCommentLike> {
|
||||
WorkFlowCommentLike getLikeComment(@Param("userId") Long userId, @Param("commentId") Long commentId);
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.mcwl.resource.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mcwl.resource.domain.WorkFlowComment;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @Author:ChenYan
|
||||
* @Project:McWl
|
||||
* @Package:com.mcwl.resource.mapper
|
||||
* @Filename:ModelCommentMapper
|
||||
* @Description TODO
|
||||
* @Date:2025/1/12 12:04
|
||||
*/
|
||||
@Mapper
|
||||
public interface WorkFlowCommentMapper extends BaseMapper<WorkFlowComment> {
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.mcwl.resource.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mcwl.resource.domain.WorkFlowLike;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @Author:ChenYan
|
||||
* @Project:McWl
|
||||
* @Package:com.mcwl.resource.mapper
|
||||
* @Filename:ModelLikeMapper
|
||||
* @Description TODO
|
||||
* @Date:2025/1/12 12:05
|
||||
*/
|
||||
@Mapper
|
||||
public interface WorkFlowLikeMapper extends BaseMapper<WorkFlowLike> {
|
||||
WorkFlowLike getLike(@Param("userId") Long userId, @Param("modelId") Long modelId);
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.mcwl.resource.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mcwl.resource.domain.WorkFlowCommentLike;
|
||||
|
||||
/**
|
||||
* 工作流评论点赞
|
||||
* @Author:ChenYan
|
||||
* @Project:McWl
|
||||
* @Package:com.mcwl.resource.service
|
||||
* @Filename:ModelCommentLikeService
|
||||
* @Description TODO
|
||||
* @Date:2025/1/12 11:58
|
||||
*/
|
||||
public interface WorkFlowCommentLikeService extends IService<WorkFlowCommentLike> {
|
||||
void like(Long commentId);
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.mcwl.resource.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mcwl.resource.domain.WorkFlowComment;
|
||||
import com.mcwl.resource.domain.vo.WorkFlowCommentVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 工作流评论 业务层
|
||||
* @Author:ChenYan
|
||||
* @Project:McWl
|
||||
* @Package:com.mcwl.resource.service
|
||||
* @Filename:ModelCommentService
|
||||
* @Description TODO
|
||||
* @Date:2025/1/12 11:58
|
||||
*/
|
||||
public interface WorkFlowCommentService extends IService<WorkFlowComment> {
|
||||
void comment(WorkFlowComment modelComment);
|
||||
|
||||
/**
|
||||
* 获取评论
|
||||
* @param imageId 图片id
|
||||
* @return 评论区
|
||||
*/
|
||||
List<WorkFlowCommentVo> getComment(Long imageId);
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.mcwl.resource.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mcwl.resource.domain.WorkFlowLike;
|
||||
|
||||
/**
|
||||
* 工作流点赞 业务层
|
||||
* @Author:ChenYan
|
||||
* @Project:McWl
|
||||
* @Package:com.mcwl.resource.service
|
||||
* @Filename:ModelLikeService
|
||||
* @Description TODO
|
||||
* @Date:2025/1/12 11:57
|
||||
*/
|
||||
public interface WorkFlowLikeService extends IService<WorkFlowLike> {
|
||||
|
||||
|
||||
void like(Long imageId);
|
||||
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
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.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 org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @Author:ChenYan
|
||||
* @Project:McWl
|
||||
* @Package:com.mcwl.resource.service.impl
|
||||
* @Filename:ModelCommentLikeServiceImpl
|
||||
* @Description TODO
|
||||
* @Date:2025/1/12 12:01
|
||||
*/
|
||||
@Service
|
||||
public class WorkFlowCommentLikeServiceImpl extends ServiceImpl<WorkFlowCommentLikeMapper, WorkFlowCommentLike> implements WorkFlowCommentLikeService {
|
||||
|
||||
@Autowired
|
||||
private WorkFlowCommentMapper workFlowCommentMapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void like(Long commentId) {
|
||||
WorkFlowComment workFlowComment = workFlowCommentMapper.selectById(commentId);
|
||||
if (Objects.isNull(workFlowComment)) {
|
||||
throw new ServiceException("该评论不存在");
|
||||
}
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
WorkFlowCommentLike workFlowCommentLike = baseMapper.getLikeComment(userId, commentId);
|
||||
if (Objects.nonNull(workFlowCommentLike)) {
|
||||
if (Objects.equals(workFlowComment.getDelFlag(), "0")) {
|
||||
workFlowCommentLike.setDelFlag("1");
|
||||
workFlowComment.setLikeNum(workFlowComment.getLikeNum() - 1);
|
||||
} else {
|
||||
workFlowCommentLike.setDelFlag("0");
|
||||
workFlowComment.setLikeNum(workFlowComment.getLikeNum() + 1);
|
||||
}
|
||||
// 更新点赞记录
|
||||
baseMapper.updateById(workFlowCommentLike);
|
||||
// 更新图片评论点赞数
|
||||
workFlowCommentMapper.updateById(workFlowComment);
|
||||
return;
|
||||
}
|
||||
|
||||
// 添加点赞记录
|
||||
workFlowCommentLike = new WorkFlowCommentLike();
|
||||
workFlowCommentLike.setUserId(userId);
|
||||
workFlowCommentLike.setWorkFlowCommentId(commentId);
|
||||
workFlowCommentLike.setCreateBy(SecurityUtils.getUsername());
|
||||
workFlowCommentLike.setUpdateBy(SecurityUtils.getUsername());
|
||||
workFlowCommentLike.setUpdateTime(new Date());
|
||||
baseMapper.insert(workFlowCommentLike);
|
||||
|
||||
// 更新模型点赞数
|
||||
workFlowComment.setLikeNum(workFlowComment.getLikeNum() + 1);
|
||||
workFlowCommentMapper.updateById(workFlowComment);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,140 @@
|
|||
package com.mcwl.resource.service.impl;
|
||||
|
||||
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.WorkFlowComment;
|
||||
import com.mcwl.resource.domain.vo.WorkFlowCommentVo;
|
||||
import com.mcwl.resource.mapper.WorkFlowCommentMapper;
|
||||
import com.mcwl.resource.service.WorkFlowCommentService;
|
||||
import com.mcwl.system.service.ISysUserService;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 工作流评论 实现层
|
||||
* @Author:ChenYan
|
||||
* @Project:McWl
|
||||
* @Package:com.mcwl.resource.service.impl
|
||||
* @Filename:ModelCommentServiceImpl
|
||||
* @Description TODO
|
||||
* @Date:2025/1/12 12:03
|
||||
*/
|
||||
@Service
|
||||
public class WorkFlowCommentServiceImpl extends ServiceImpl<WorkFlowCommentMapper, WorkFlowComment> implements WorkFlowCommentService {
|
||||
|
||||
@Autowired
|
||||
private ISysUserService sysUserService;
|
||||
|
||||
@Autowired
|
||||
private WorkFlowCommentMapper workFlowCommentMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public void comment(WorkFlowComment workFlowComment) {
|
||||
Long parentId = workFlowComment.getParentId();
|
||||
WorkFlowComment mic = workFlowCommentMapper.selectById(parentId);
|
||||
|
||||
if (Objects.nonNull(parentId) && Objects.isNull(mic)) {
|
||||
return;
|
||||
}
|
||||
workFlowComment.setUserId(SecurityUtils.getUserId());
|
||||
workFlowComment.setCreateBy(SecurityUtils.getUsername());
|
||||
workFlowComment.setUpdateBy(SecurityUtils.getUsername());
|
||||
workFlowComment.setUpdateTime(new Date());
|
||||
workFlowCommentMapper.insert(workFlowComment);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WorkFlowCommentVo> getComment(Long imageId) {
|
||||
List<WorkFlowCommentVo> workFlowCommentVos = new ArrayList<>();
|
||||
|
||||
// 查询所有父评论
|
||||
LambdaQueryWrapper<WorkFlowComment> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(WorkFlowComment::getWorkFlowId, imageId)
|
||||
.isNull(WorkFlowComment::getParentId)
|
||||
.orderByDesc(WorkFlowComment::getCreateTime);
|
||||
// 添加父评论
|
||||
List<WorkFlowComment> workFlowComments = workFlowCommentMapper.selectList(lqw);
|
||||
for (WorkFlowComment workFlowComment : workFlowComments) {
|
||||
WorkFlowCommentVo workFlowCommentVo = getModelCommentVo(workFlowComment);
|
||||
workFlowCommentVos.add(workFlowCommentVo);
|
||||
}
|
||||
|
||||
return workFlowCommentVos;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 构建ModelCommentVo对象
|
||||
*
|
||||
* @param workFlowComment 父评论对象
|
||||
* @return WorkFlowCommentVo
|
||||
*/
|
||||
@NotNull
|
||||
private WorkFlowCommentVo getModelCommentVo(WorkFlowComment workFlowComment) {
|
||||
Long userId = workFlowComment.getUserId();
|
||||
SysUser sysUser = sysUserService.selectUserById(userId);
|
||||
|
||||
// 构建WorkFlowCommentVo对象
|
||||
WorkFlowCommentVo workFlowCommentVo = new WorkFlowCommentVo();
|
||||
workFlowCommentVo.setUserId(userId);
|
||||
workFlowCommentVo.setUserName(sysUser.getUserName());
|
||||
workFlowCommentVo.setUserAvatar(sysUser.getAvatar());
|
||||
workFlowCommentVo.setCommentId(workFlowComment.getId());
|
||||
workFlowCommentVo.setContent(workFlowComment.getContent());
|
||||
// 查询子评论
|
||||
workFlowCommentVo.setContentList(getContentList(workFlowComment.getId()));
|
||||
workFlowCommentVo.setLikeNum(workFlowComment.getLikeNum());
|
||||
workFlowCommentVo.setCreateTime(workFlowComment.getCreateTime());
|
||||
return workFlowCommentVo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 递归查询子评论
|
||||
*
|
||||
* @param modelCommentId 父评论id
|
||||
* @return List<ModelCommentVo>
|
||||
*/
|
||||
private List<WorkFlowCommentVo> getContentList(Long modelCommentId) {
|
||||
List<WorkFlowCommentVo> modelCommentVoList = new ArrayList<>();
|
||||
if (Objects.isNull(modelCommentId)) {
|
||||
return modelCommentVoList;
|
||||
}
|
||||
|
||||
// 查询子评论
|
||||
LambdaQueryWrapper<WorkFlowComment> lqw = new LambdaQueryWrapper<WorkFlowComment>()
|
||||
.eq(WorkFlowComment::getParentId, modelCommentId)
|
||||
.orderByDesc(WorkFlowComment::getCreateTime);
|
||||
|
||||
List<WorkFlowComment> modelCommentList = workFlowCommentMapper.selectList(lqw);
|
||||
|
||||
for (WorkFlowComment modelComment : modelCommentList) {
|
||||
Long userId = modelComment.getUserId();
|
||||
SysUser sysUser = sysUserService.selectUserById(userId);
|
||||
WorkFlowCommentVo modelCommentVo = new WorkFlowCommentVo();
|
||||
modelCommentVo.setUserId(userId);
|
||||
modelCommentVo.setUserName(sysUser.getUserName());
|
||||
modelCommentVo.setUserAvatar(sysUser.getAvatar());
|
||||
modelCommentVo.setCommentId(modelComment.getId());
|
||||
modelCommentVo.setContent(modelComment.getContent());
|
||||
modelCommentVo.setLikeNum(modelComment.getLikeNum());
|
||||
modelCommentVo.setCreateTime(modelComment.getCreateTime());
|
||||
|
||||
|
||||
modelCommentVoList.add(modelCommentVo);
|
||||
}
|
||||
return modelCommentVoList;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
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.WorkFlow;
|
||||
import com.mcwl.resource.domain.WorkFlowLike;
|
||||
import com.mcwl.resource.mapper.WorkFlowLikeMapper;
|
||||
import com.mcwl.resource.mapper.WorkFlowMapper;
|
||||
import com.mcwl.resource.service.WorkFlowLikeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 工作流点赞
|
||||
* @Author:ChenYan
|
||||
* @Project:McWl
|
||||
* @Package:com.mcwl.resource.service.impl
|
||||
* @Filename:ModelLikeServiceImpl
|
||||
* @Description TODO
|
||||
* @Date:2025/1/12 12:05
|
||||
*/
|
||||
@Service
|
||||
public class WorkFlowLikeServiceImpl extends ServiceImpl<WorkFlowLikeMapper, WorkFlowLike> implements WorkFlowLikeService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private WorkFlowMapper workFlowMapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void like(Long modelId) {
|
||||
WorkFlow workFlow = workFlowMapper.selectById(modelId);
|
||||
if (Objects.isNull(workFlow)) {
|
||||
throw new ServiceException("该工作流不存在或已下架");
|
||||
}
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
WorkFlowLike workFlowLike = baseMapper.getLike(userId, modelId);
|
||||
if (Objects.nonNull(workFlowLike)) {
|
||||
if (Objects.equals(workFlowLike.getDelFlag(), "0")) {
|
||||
workFlowLike.setDelFlag("1");
|
||||
workFlow.setLikeCount(workFlow.getLikeCount() - 1);
|
||||
} else {
|
||||
workFlowLike.setDelFlag("0");
|
||||
workFlow.setLikeCount(workFlow.getLikeCount() + 1);
|
||||
}
|
||||
// 更新点赞记录
|
||||
baseMapper.updateById(workFlowLike);
|
||||
// 更新图片点赞数
|
||||
workFlowMapper.updateById(workFlow);
|
||||
return;
|
||||
}
|
||||
|
||||
// 添加点赞记录
|
||||
workFlowLike = new WorkFlowLike();
|
||||
workFlowLike.setUserId(userId);
|
||||
workFlowLike.setWorkFlowId(modelId);
|
||||
workFlowLike.setCreateBy(SecurityUtils.getUsername());
|
||||
workFlowLike.setUpdateBy(SecurityUtils.getUsername());
|
||||
workFlowLike.setUpdateTime(new Date());
|
||||
baseMapper.insert(workFlowLike);
|
||||
|
||||
// 更新图片点赞数
|
||||
workFlow.setLikeCount(workFlow.getLikeCount() + 1);
|
||||
workFlowMapper.updateById(workFlow);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.mcwl.resource.mapper.WorkFlowCommentLikeMapper">
|
||||
|
||||
|
||||
<select id="getLikeComment" resultType="com.mcwl.resource.domain.WorkFlowCommentLike">
|
||||
select id,
|
||||
user_id,
|
||||
work_flow_comment_id,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time,
|
||||
del_flag,
|
||||
remark
|
||||
from work_flow_comment_like
|
||||
where user_id = #{userId} and work_flow_comment_id = #{commentId}
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.mcwl.resource.mapper.WorkFlowLikeMapper">
|
||||
|
||||
|
||||
<select id="getLike" resultType="com.mcwl.resource.domain.WorkFlowLike">
|
||||
select id,
|
||||
user_id,
|
||||
model_comment_id,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time,
|
||||
del_flag,
|
||||
remark
|
||||
from work_flow_like
|
||||
where user_id = #{userId} and model_id = #{modelId}
|
||||
</select>
|
||||
</mapper>
|
|
@ -100,6 +100,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
/**
|
||||
* 根据条件分页查询已分配用户角色列表
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue