获取评论类型数量

This commit is contained in:
aikai 2024-04-12 15:05:17 +08:00
parent 080cc6bea5
commit fda0fb5027
7 changed files with 105 additions and 47 deletions

View File

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.controller.app.comment;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.system.controller.app.comment.dto.CommentDTO;
import cn.iocoder.yudao.module.system.controller.app.comment.vo.CommentPageListVO;
import cn.iocoder.yudao.module.system.controller.app.comment.vo.CommentTypeCountVO;
import cn.iocoder.yudao.module.system.controller.app.comment.vo.WorkLogCommentSaveReqVO;
import cn.iocoder.yudao.module.system.service.comment.WorkLogCommentService;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -40,5 +41,10 @@ public class WorkLogCommentController {
return success(workLogCommentService.createWorkLogComment(createReqVO));
}
@GetMapping("/queryCommentTypeCount")
@Operation(summary = "获取评论类型数量")
public CommonResult<CommentTypeCountVO> queryCommentTypeCount() {
return success(workLogCommentService.queryCommentTypeCount());
}
}

View File

@ -7,11 +7,17 @@ import lombok.Data;
@Data
public class CommentDTO {
@Schema(description = "工作日志id", required = true)
@Schema(description = "工作日志id")
@JsonSerialize(using = ToStringSerializer.class)
private Long workLogId;
@Schema(description = "评论类型0|评论1|回评")
private Integer type;
@Schema(description = "是否需要显示日志内容 0否 1是 默认否")
private Integer isShowWorkLogContent;
@Schema(description = "是否查看自己的评论记录 0否 1是")
private Integer checkMyselfFlag;
@Schema(description = "用户id")
private Long userId;
}

View File

@ -0,0 +1,16 @@
package cn.iocoder.yudao.module.system.controller.app.comment.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class CommentTypeCountVO {
@Schema(description = "全部数量")
private Integer allNum;
@Schema(description = "评论数量")
private Integer commentNum;
@Schema(description = "回复数量")
private Integer replyNum;
}

View File

@ -1,16 +1,17 @@
package cn.iocoder.yudao.module.system.service.comment;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.system.controller.app.comment.dto.CommentDTO;
import cn.iocoder.yudao.module.system.controller.app.comment.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.comment.WorkLogCommentDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.module.system.controller.app.comment.dto.CommentDTO;
import cn.iocoder.yudao.module.system.controller.app.comment.vo.CommentPageListVO;
import cn.iocoder.yudao.module.system.controller.app.comment.vo.CommentTypeCountVO;
import cn.iocoder.yudao.module.system.controller.app.comment.vo.WorkLogCommentPageReqVO;
import cn.iocoder.yudao.module.system.controller.app.comment.vo.WorkLogCommentSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.comment.WorkLogCommentDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import javax.validation.Valid;
/**
* 工作日志评论 Service 接口
*
@ -57,10 +58,16 @@ public interface WorkLogCommentService {
PageResult<WorkLogCommentDO> getWorkLogCommentPage(WorkLogCommentPageReqVO pageReqVO);
/**
*
* @param page
* @param dto
* @return
*/
IPage<CommentPageListVO> queryCommentPageList(Page<CommentPageListVO> page, CommentDTO dto);
/**
* 获取评论类型数量
*
* @return
*/
CommentTypeCountVO queryCommentTypeCount();
}

View File

@ -7,12 +7,14 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
import cn.iocoder.yudao.module.system.controller.app.comment.dto.CommentDTO;
import cn.iocoder.yudao.module.system.controller.app.comment.vo.CommentPageListVO;
import cn.iocoder.yudao.module.system.controller.app.comment.vo.CommentTypeCountVO;
import cn.iocoder.yudao.module.system.controller.app.comment.vo.WorkLogCommentPageReqVO;
import cn.iocoder.yudao.module.system.controller.app.comment.vo.WorkLogCommentSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.comment.WorkLogCommentDO;
import cn.iocoder.yudao.module.system.dal.dataobject.worklog.LogFormDO;
import cn.iocoder.yudao.module.system.dal.mysql.comment.WorkLogCommentMapper;
import cn.iocoder.yudao.module.system.service.worklog.LogFormService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;
@ -83,6 +85,10 @@ public class WorkLogCommentServiceImpl implements WorkLogCommentService {
@Override
public IPage<CommentPageListVO> queryCommentPageList(Page<CommentPageListVO> page, CommentDTO dto) {
if (dto.getCheckMyselfFlag() == 1) {
Long userId = WebFrameworkUtils.getLoginUserId();
dto.setUserId(userId);
}
IPage<CommentPageListVO> pageList = workLogCommentMapper.queryCommentPageList(page, dto);
List<CommentPageListVO> records = pageList.getRecords();
if (dto.getIsShowWorkLogContent() != null && dto.getIsShowWorkLogContent() == 1 && !records.isEmpty()) {
@ -111,4 +117,18 @@ public class WorkLogCommentServiceImpl implements WorkLogCommentService {
return pageList;
}
@Override
public CommentTypeCountVO queryCommentTypeCount() {
Long userId = WebFrameworkUtils.getLoginUserId();
CommentTypeCountVO vo = new CommentTypeCountVO();
Integer commentNum = Math.toIntExact(workLogCommentMapper.selectCount(new LambdaQueryWrapper<WorkLogCommentDO>()
.eq(WorkLogCommentDO::getUserId, userId)));
Integer replyNum = Math.toIntExact(workLogCommentMapper.selectCount(new LambdaQueryWrapper<WorkLogCommentDO>()
.eq(WorkLogCommentDO::getCommentUserId, userId)));
vo.setCommentNum(commentNum);
vo.setReplyNum(replyNum);
vo.setAllNum(commentNum + replyNum);
return vo;
}
}

View File

@ -74,44 +74,44 @@ public class LogInstanceServiceImpl implements LogInstanceService {
Set<Long> roleIds = permissionService.getMenuRoleIdListByMenuIdFromCache(menuIds.get(0));
List<RoleDO> roleDOS = roleService.getRoleList(roleIds);
for (RoleDO roleDo : roleDOS) {
if (Objects.equals(roleDo.getDataScope(), DataScopeEnum.ALL.getScope())) { //数据权限是全部时
roles.add(roleDo.getId());
}else if (Objects.equals(roleDo.getDataScope(), DataScopeEnum.DEPT_CUSTOM.getScope())) { //数据权限是指定部门
//指定部门组里存在 发起人的部门
if (roleDo.getDataScopeDeptIds().contains(createReqVO.getDeptId())) {
roles.add(roleDo.getId());
}
}else if (Objects.equals(roleDo.getDataScope(), DataScopeEnum.DEPT_ONLY.getScope())) { //数据权限是本部门
List<AdminUserDO> userDos = adminUserMapper.selectListByRoleId(roleDo.getId());
for (AdminUserDO userDO : userDos) {
//权限部门与发起人部门一致时
if (Objects.equals(userDO.getDeptId(), createReqVO.getDeptId())) {
readStatus.put(String.valueOf(userDO.getId()), "0");
}
}
}else if (Objects.equals(roleDo.getDataScope(), DataScopeEnum.DEPT_AND_CHILD.getScope())) { //数据权限是本部门及一下
//根据规则ID 查询用户信息
List<AdminUserDO> userDos = adminUserMapper.selectListByRoleId(roleDo.getId());
for (AdminUserDO userDO : userDos) {
Set<Long> deptIds = deptService.getChildDeptIdListFromCache(userDO.getDeptId());
//权限部门与发起人部门一致时
if (deptIds.contains(createReqVO.getDeptId())) {
readStatus.put(String.valueOf(userDO.getId()), "0");
}
}
}
}
// for (RoleDO roleDo : roleDOS) {
//
// if (Objects.equals(roleDo.getDataScope(), DataScopeEnum.ALL.getScope())) { //数据权限是全部时
//
// roles.add(roleDo.getId());
// }else if (Objects.equals(roleDo.getDataScope(), DataScopeEnum.DEPT_CUSTOM.getScope())) { //数据权限是指定部门
//
// //指定部门组里存在 发起人的部门
// if (roleDo.getDataScopeDeptIds().contains(createReqVO.getDeptId())) {
//
// roles.add(roleDo.getId());
// }
// }else if (Objects.equals(roleDo.getDataScope(), DataScopeEnum.DEPT_ONLY.getScope())) { //数据权限是本部门
//
// List<AdminUserDO> userDos = adminUserMapper.selectListByRoleId(roleDo.getId());
// for (AdminUserDO userDO : userDos) {
//
// //权限部门与发起人部门一致时
// if (Objects.equals(userDO.getDeptId(), createReqVO.getDeptId())) {
//
// readStatus.put(String.valueOf(userDO.getId()), "0");
// }
// }
// }else if (Objects.equals(roleDo.getDataScope(), DataScopeEnum.DEPT_AND_CHILD.getScope())) { //数据权限是本部门及一下
//
// //根据规则ID 查询用户信息
// List<AdminUserDO> userDos = adminUserMapper.selectListByRoleId(roleDo.getId());
// for (AdminUserDO userDO : userDos) {
//
// Set<Long> deptIds = deptService.getChildDeptIdListFromCache(userDO.getDeptId());
// //权限部门与发起人部门一致时
// if (deptIds.contains(createReqVO.getDeptId())) {
//
// readStatus.put(String.valueOf(userDO.getId()), "0");
// }
// }
// }
// }
//通过满足条件的roleId 查询所有用户信息
List<UserRoleDO> userRoleDOS = userRoleMapper.selectListByRoleIds(roles);

View File

@ -43,6 +43,9 @@
<if test="dto.type != null">
and a.type = #{dto.type}
</if>
<if test="dto.userId != null">
and (a.user_id = #{dto.userId} or a.comment_user_id = #{dto.userId})
</if>
</where>
ORDER BY a.create_time DESC
</select>