Skip to content

Commit

Permalink
feat/以下接口改造垮库调用queryAllLog、queryCommentLog、queryDeliverableLog、queryD…
Browse files Browse the repository at this point in the history
…eliverableLog
  • Loading branch information
freestylefly committed Jun 25, 2024
1 parent 987ebd4 commit de10392
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
package com.laigeoffer.pmhub.project.service.task;

import com.alibaba.fastjson2.JSON;
import com.laigeoffer.pmhub.api.system.UserFeignService;
import com.laigeoffer.pmhub.api.system.domain.dto.SysUserDTO;
import com.laigeoffer.pmhub.base.core.constant.SecurityConstants;
import com.laigeoffer.pmhub.base.core.core.domain.R;
import com.laigeoffer.pmhub.base.core.core.domain.vo.SysUserVO;
import com.laigeoffer.pmhub.base.core.enums.LogTypeEnum;
import com.laigeoffer.pmhub.base.core.exception.ServiceException;
import com.laigeoffer.pmhub.project.domain.vo.project.log.LogContentVO;
import com.laigeoffer.pmhub.project.domain.vo.project.log.ProjectLogVO;
import com.laigeoffer.pmhub.project.mapper.ProjectLogMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

/**
* @author canghe
Expand All @@ -19,15 +30,45 @@
public class QueryAllLogExecutor extends QueryLogAbstractExecutor {
@Autowired
private ProjectLogMapper projectLogMapper;
@Resource
private UserFeignService userFeignService;


@Override
public List<ProjectLogVO> query(String taskId) {
List<ProjectLogVO> list = projectLogMapper.queryAllLog(taskId);
if (CollectionUtils.isEmpty(list)) {
return Collections.emptyList();
}
// 拿到userids
List<Long> userIds = list.stream().map(ProjectLogVO::getUserId)
.distinct()
.collect(Collectors.toList());
SysUserDTO sysUserDTO = new SysUserDTO();
sysUserDTO.setUserIds(userIds);
R<List<SysUserVO>> userResult = userFeignService.listOfInner(sysUserDTO, SecurityConstants.INNER);

if (Objects.isNull(userResult) || CollectionUtils.isEmpty(userResult.getData())) {
throw new ServiceException("远程调用查询用户列表:" + userIds + " 失败");
}
List<SysUserVO> userVOList = userResult.getData();

// 匹配设置值
Map<Long, SysUserVO> userMap = userVOList.stream().collect(Collectors.toMap(SysUserVO::getUserId, a -> a));
list.forEach(projectLogVO -> {
if (Objects.equals(LogTypeEnum.TRENDS.getStatus(), projectLogVO.getLogType())) {
List<LogContentVO> contentVOList = JSON.parseArray(projectLogVO.getContent().toString(), LogContentVO.class);
projectLogVO.setContent(contentVOList);
}
projectLogVO.setLogTypeName(LogTypeEnum.getStatusNameByStatus(projectLogVO.getLogType()));

// 设置用户信息
SysUserVO sysUserVO = userMap.get(projectLogVO.getUserId());
if (Objects.nonNull(sysUserVO)) {
projectLogVO.setUserName(sysUserVO.getUserName());
projectLogVO.setNickName(sysUserVO.getNickName());
projectLogVO.setAvatar(sysUserVO.getAvatar());
}
});
return list;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
package com.laigeoffer.pmhub.project.service.task;

import com.laigeoffer.pmhub.api.system.UserFeignService;
import com.laigeoffer.pmhub.api.system.domain.dto.SysUserDTO;
import com.laigeoffer.pmhub.base.core.constant.SecurityConstants;
import com.laigeoffer.pmhub.base.core.core.domain.R;
import com.laigeoffer.pmhub.base.core.core.domain.vo.SysUserVO;
import com.laigeoffer.pmhub.base.core.enums.LogTypeEnum;
import com.laigeoffer.pmhub.base.core.exception.ServiceException;
import com.laigeoffer.pmhub.project.domain.vo.project.log.ProjectLogVO;
import com.laigeoffer.pmhub.project.mapper.ProjectLogMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

/**
* @author canghe
Expand All @@ -16,10 +28,42 @@
public class QueryCommentLogExecutor extends QueryLogAbstractExecutor {
@Autowired
private ProjectLogMapper projectLogMapper;
@Resource
private UserFeignService userFeignService;


@Override
public List<ProjectLogVO> query(String taskId) {
List<ProjectLogVO> list = projectLogMapper.queryCommentLog(taskId);
list.forEach(projectLogVO -> projectLogVO.setLogTypeName(LogTypeEnum.getStatusNameByStatus(projectLogVO.getLogType())));
if (CollectionUtils.isEmpty(list)) {
return Collections.emptyList();
}
// 拿到userids
List<Long> userIds = list.stream().map(ProjectLogVO::getUserId)
.distinct()
.collect(Collectors.toList());
SysUserDTO sysUserDTO = new SysUserDTO();
sysUserDTO.setUserIds(userIds);
R<List<SysUserVO>> userResult = userFeignService.listOfInner(sysUserDTO, SecurityConstants.INNER);

if (Objects.isNull(userResult) || CollectionUtils.isEmpty(userResult.getData())) {
throw new ServiceException("远程调用查询用户列表:" + userIds + " 失败");
}
List<SysUserVO> userVOList = userResult.getData();

// 匹配设置值
Map<Long, SysUserVO> userMap = userVOList.stream().collect(Collectors.toMap(SysUserVO::getUserId, a -> a));
list.forEach(projectLogVO -> {
projectLogVO.setLogTypeName(LogTypeEnum.getStatusNameByStatus(projectLogVO.getLogType()));

// 设置用户信息
SysUserVO sysUserVO = userMap.get(projectLogVO.getUserId());
if (Objects.nonNull(sysUserVO)) {
projectLogVO.setUserName(sysUserVO.getUserName());
projectLogVO.setNickName(sysUserVO.getNickName());
projectLogVO.setAvatar(sysUserVO.getAvatar());
}
});
return list;
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
package com.laigeoffer.pmhub.project.service.task;

import com.laigeoffer.pmhub.api.system.UserFeignService;
import com.laigeoffer.pmhub.api.system.domain.dto.SysUserDTO;
import com.laigeoffer.pmhub.base.core.constant.SecurityConstants;
import com.laigeoffer.pmhub.base.core.core.domain.R;
import com.laigeoffer.pmhub.base.core.core.domain.vo.SysUserVO;
import com.laigeoffer.pmhub.base.core.enums.LogTypeEnum;
import com.laigeoffer.pmhub.base.core.exception.ServiceException;
import com.laigeoffer.pmhub.project.domain.vo.project.log.ProjectLogVO;
import com.laigeoffer.pmhub.project.mapper.ProjectLogMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

/**
* @author canghe
Expand All @@ -16,10 +28,41 @@
public class QueryDeliverableLogExecutor extends QueryLogAbstractExecutor {
@Autowired
private ProjectLogMapper projectLogMapper;
@Resource
private UserFeignService userFeignService;

@Override
public List<ProjectLogVO> query(String taskId) {
List<ProjectLogVO> list = projectLogMapper.queryDeliverableLog(taskId);
list.forEach(projectLogVO -> projectLogVO.setLogTypeName(LogTypeEnum.getStatusNameByStatus(projectLogVO.getLogType())));
if (CollectionUtils.isEmpty(list)) {
return Collections.emptyList();
}
// 拿到userids
List<Long> userIds = list.stream().map(ProjectLogVO::getUserId)
.distinct()
.collect(Collectors.toList());
SysUserDTO sysUserDTO = new SysUserDTO();
sysUserDTO.setUserIds(userIds);
R<List<SysUserVO>> userResult = userFeignService.listOfInner(sysUserDTO, SecurityConstants.INNER);

if (Objects.isNull(userResult) || CollectionUtils.isEmpty(userResult.getData())) {
throw new ServiceException("远程调用查询用户列表:" + userIds + " 失败");
}
List<SysUserVO> userVOList = userResult.getData();

// 匹配设置值
Map<Long, SysUserVO> userMap = userVOList.stream().collect(Collectors.toMap(SysUserVO::getUserId, a -> a));
list.forEach(projectLogVO -> {
projectLogVO.setLogTypeName(LogTypeEnum.getStatusNameByStatus(projectLogVO.getLogType()));

// 设置用户信息
SysUserVO sysUserVO = userMap.get(projectLogVO.getUserId());
if (Objects.nonNull(sysUserVO)) {
projectLogVO.setUserName(sysUserVO.getUserName());
projectLogVO.setNickName(sysUserVO.getNickName());
projectLogVO.setAvatar(sysUserVO.getAvatar());
}
});
return list;
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
package com.laigeoffer.pmhub.project.service.task;

import com.alibaba.fastjson2.JSON;
import com.laigeoffer.pmhub.api.system.UserFeignService;
import com.laigeoffer.pmhub.api.system.domain.dto.SysUserDTO;
import com.laigeoffer.pmhub.base.core.constant.SecurityConstants;
import com.laigeoffer.pmhub.base.core.core.domain.R;
import com.laigeoffer.pmhub.base.core.core.domain.vo.SysUserVO;
import com.laigeoffer.pmhub.base.core.enums.LogTypeEnum;
import com.laigeoffer.pmhub.base.core.exception.ServiceException;
import com.laigeoffer.pmhub.project.domain.vo.project.log.LogContentVO;
import com.laigeoffer.pmhub.project.domain.vo.project.log.ProjectLogVO;
import com.laigeoffer.pmhub.project.mapper.ProjectLogMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

/**
* @author canghe
Expand All @@ -18,14 +30,42 @@
public class QueryTrendsLogExecutor extends QueryLogAbstractExecutor {
@Autowired
private ProjectLogMapper projectLogMapper;
@Resource
private UserFeignService userFeignService;

@Override
public List<ProjectLogVO> query(String taskId) {
List<ProjectLogVO> list = projectLogMapper.queryTrendsLog(taskId);
if (CollectionUtils.isEmpty(list)) {
return Collections.emptyList();
}
// 拿到userids
List<Long> userIds = list.stream().map(ProjectLogVO::getUserId)
.distinct()
.collect(Collectors.toList());
SysUserDTO sysUserDTO = new SysUserDTO();
sysUserDTO.setUserIds(userIds);
R<List<SysUserVO>> userResult = userFeignService.listOfInner(sysUserDTO, SecurityConstants.INNER);

if (Objects.isNull(userResult) || CollectionUtils.isEmpty(userResult.getData())) {
throw new ServiceException("远程调用查询用户列表:" + userIds + " 失败");
}
List<SysUserVO> userVOList = userResult.getData();

// 匹配设置值
Map<Long, SysUserVO> userMap = userVOList.stream().collect(Collectors.toMap(SysUserVO::getUserId, a -> a));
list.forEach(projectLogVO -> {
List<LogContentVO> contentVOList = JSON.parseArray(projectLogVO.getContent().toString(), LogContentVO.class);
projectLogVO.setContent(contentVOList);
projectLogVO.setLogTypeName(LogTypeEnum.getStatusNameByStatus(projectLogVO.getLogType()));

// 设置用户信息
SysUserVO sysUserVO = userMap.get(projectLogVO.getUserId());
if (Objects.nonNull(sysUserVO)) {
projectLogVO.setUserName(sysUserVO.getUserName());
projectLogVO.setNickName(sysUserVO.getNickName());
projectLogVO.setAvatar(sysUserVO.getAvatar());
}
});
return list;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,34 @@
</select>
<select id="queryAllLog" resultType="com.laigeoffer.pmhub.project.domain.vo.project.log.ProjectLogVO">
select pl.pt_id,pl.type, pl.id as projectLogId, pl.operate_type,pl.remark,pl.content,p.id as project_id,pt.id as taskId,p.project_name,pt.task_name,pl.created_time
,su.user_id,su.user_name,su.nick_name,su.avatar,p.id as projectId, p.project_name,pl.log_type
,pl.user_id,p.id as projectId, p.project_name,pl.log_type
from pmhub_project_log pl
left join pmhub_project p on p.id = pl.project_id
left join pmhub_project_task pt on pt.id = pl.pt_id
left join sys_user su on pl.user_id = su.user_id
where pl.pt_id = #{taskId} and pl.type = 'task' and (pl.log_type = 1 and pl.operate_type = 'editTask' or pl.log_type = 2 or pl.log_type = 3) order by pl.created_time desc
</select>
<select id="queryCommentLog" resultType="com.laigeoffer.pmhub.project.domain.vo.project.log.ProjectLogVO">
select pl.pt_id,pl.type, pl.id as projectLogId, pl.operate_type,pl.remark,pl.content,p.id as project_id,pt.id as taskId,p.project_name,pt.task_name,pl.created_time
,su.user_id,su.user_name,su.nick_name,su.avatar,p.id as projectId, p.project_name,pl.log_type
,pl.user_id,p.id as projectId, p.project_name,pl.log_type
from pmhub_project_log pl
left join pmhub_project p on p.id = pl.project_id
left join pmhub_project_task pt on pt.id = pl.pt_id
left join sys_user su on pl.user_id = su.user_id
where pl.pt_id = #{taskId} and pl.type = 'task' and pl.log_type = 3 order by pl.created_time desc
</select>
<select id="queryDeliverableLog" resultType="com.laigeoffer.pmhub.project.domain.vo.project.log.ProjectLogVO">
select pl.pt_id,pl.type, pl.id as projectLogId, pl.operate_type,pl.remark,pl.content,p.id as project_id,pt.id as taskId,p.project_name,pt.task_name,pl.created_time
,su.user_id,su.user_name,su.nick_name,su.avatar,p.id as projectId, p.project_name,pl.log_type
,pl.user_id,p.id as projectId, p.project_name,pl.log_type
from pmhub_project_log pl
left join pmhub_project p on p.id = pl.project_id
left join pmhub_project_task pt on pt.id = pl.pt_id
left join sys_user su on pl.user_id = su.user_id
where pl.pt_id = #{taskId} and pl.type = 'task' and pl.log_type = 2 order by pl.created_time desc
</select>
<select id="queryTrendsLog" resultType="com.laigeoffer.pmhub.project.domain.vo.project.log.ProjectLogVO">
select pl.pt_id,pl.type, pl.id as projectLogId, pl.operate_type,pl.remark,pl.content,p.id as project_id,pt.id as taskId,p.project_name,pt.task_name,pl.created_time
,su.user_id,su.user_name,su.nick_name,su.avatar,p.id as projectId, p.project_name,pl.log_type
,pl.user_id,p.id as projectId, p.project_name,pl.log_type
from pmhub_project_log pl
left join pmhub_project p on p.id = pl.project_id
left join pmhub_project_task pt on pt.id = pl.pt_id
left join sys_user su on pl.user_id = su.user_id
where pl.pt_id = #{taskId} and pl.type = 'task' and pl.log_type = 1 and pl.operate_type = 'editTask' order by pl.created_time desc
</select>
</mapper>

0 comments on commit de10392

Please sign in to comment.