mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-23 07:41:53 +08:00
refactor: 调整代码分装层次
This commit is contained in:
parent
97d6aab41c
commit
b4150cafa7
@ -1,20 +1,34 @@
|
||||
package cn.iocoder.yudao.module.bpm.controller.admin.task;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCopyCreateReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCopyMyPageReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCopyPageItemRespVO;
|
||||
import cn.iocoder.yudao.module.bpm.convert.cc.BpmProcessInstanceCopyConvert;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.cc.BpmProcessInstanceCopyDO;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.cc.BpmProcessInstanceCopyService;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
@Tag(name = "管理后台 - 流程实例抄送")
|
||||
@ -25,6 +39,13 @@ public class BpmProcessInstanceCopyController {
|
||||
|
||||
@Resource
|
||||
private BpmProcessInstanceCopyService processInstanceCopyService;
|
||||
@Resource
|
||||
private BpmProcessInstanceService bpmProcessInstanceService;
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Resource
|
||||
private BpmTaskService bpmTaskService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "抄送流程")
|
||||
@ -38,7 +59,28 @@ public class BpmProcessInstanceCopyController {
|
||||
@PreAuthorize("@ss.hasPermission('bpm:process-instance-cc:query')")
|
||||
public CommonResult<PageResult<BpmProcessInstanceCopyPageItemRespVO>> getProcessInstanceCCPage(
|
||||
@Valid BpmProcessInstanceCopyMyPageReqVO pageReqVO) {
|
||||
return success(processInstanceCopyService.getMyProcessInstanceCopyPage(getLoginUserId(), pageReqVO));
|
||||
return success(getMyProcessInstanceCopyPage(getLoginUserId(), pageReqVO));
|
||||
}
|
||||
|
||||
public PageResult<BpmProcessInstanceCopyPageItemRespVO> getMyProcessInstanceCopyPage(Long loginUserId, BpmProcessInstanceCopyMyPageReqVO pageReqVO) {
|
||||
PageResult<BpmProcessInstanceCopyDO> pageResult = processInstanceCopyService.getMyProcessInstanceCopyPage(loginUserId, pageReqVO);
|
||||
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||
return new PageResult<>(pageResult.getTotal());
|
||||
}
|
||||
|
||||
Map<String, String> taskNameByTaskIds = bpmTaskService.getTaskNameByTaskIds(convertSet(pageResult.getList(), BpmProcessInstanceCopyDO::getTaskId));
|
||||
Map<String, String> processInstanceNameByProcessInstanceIds = bpmTaskService.getProcessInstanceNameByProcessInstanceIds(convertSet(pageResult.getList(), BpmProcessInstanceCopyDO::getProcessInstanceId));
|
||||
|
||||
Set<Long/* userId */> userIds = new HashSet<>();
|
||||
for (BpmProcessInstanceCopyDO doItem : pageResult.getList()) {
|
||||
userIds.add(doItem.getStartUserId());
|
||||
Long userId = Long.valueOf(doItem.getCreator());
|
||||
userIds.add(userId);
|
||||
}
|
||||
Map<Long, String> userMap = adminUserApi.getUserList(userIds).stream().collect(Collectors.toMap(
|
||||
AdminUserRespDTO::getId, AdminUserRespDTO::getNickname));
|
||||
|
||||
// 转换返回
|
||||
return BpmProcessInstanceCopyConvert.INSTANCE.convertPage(pageResult, taskNameByTaskIds, processInstanceNameByProcessInstanceIds, userMap);
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCopyCreateReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCopyMyPageReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCopyPageItemRespVO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.cc.BpmProcessInstanceCopyDO;
|
||||
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo;
|
||||
|
||||
/**
|
||||
@ -35,6 +36,6 @@ public interface BpmProcessInstanceCopyService {
|
||||
* @param pageReqVO 分页请求
|
||||
* @return 抄送的分页结果
|
||||
*/
|
||||
PageResult<BpmProcessInstanceCopyPageItemRespVO> getMyProcessInstanceCopyPage(Long loginUserId,
|
||||
BpmProcessInstanceCopyMyPageReqVO pageReqVO);
|
||||
PageResult<BpmProcessInstanceCopyDO> getMyProcessInstanceCopyPage(Long loginUserId,
|
||||
BpmProcessInstanceCopyMyPageReqVO pageReqVO);
|
||||
}
|
||||
|
@ -62,12 +62,6 @@ public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopy
|
||||
@Lazy
|
||||
private BpmTaskService bpmTaskService;
|
||||
|
||||
@Resource
|
||||
@Lazy // 解决循环依赖
|
||||
private BpmProcessInstanceService bpmProcessInstanceService;
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Override
|
||||
public boolean makeCopy(BpmCandidateSourceInfo sourceInfo) {
|
||||
if (null == sourceInfo) {
|
||||
@ -163,28 +157,9 @@ public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopy
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<BpmProcessInstanceCopyPageItemRespVO> getMyProcessInstanceCopyPage(Long loginUserId, BpmProcessInstanceCopyMyPageReqVO pageReqVO) {
|
||||
public PageResult<BpmProcessInstanceCopyDO> getMyProcessInstanceCopyPage(Long loginUserId, BpmProcessInstanceCopyMyPageReqVO pageReqVO) {
|
||||
// 通过 BpmProcessInstanceExtDO 表,先查询到对应的分页
|
||||
// TODO @kyle:一般读逻辑,Service 返回 PageResult<BpmProcessInstanceCopyDO> 即可。关联数据的查询和拼接,交给 Controller;目的是:保证 Service 聚焦写逻辑,清晰简洁;
|
||||
PageResult<BpmProcessInstanceCopyDO> pageResult = processInstanceCopyMapper.selectPage(loginUserId, pageReqVO);
|
||||
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||
return new PageResult<>(pageResult.getTotal());
|
||||
}
|
||||
|
||||
Map<String, String> taskNameByTaskIds = bpmTaskService.getTaskNameByTaskIds(convertSet(pageResult.getList(), BpmProcessInstanceCopyDO::getTaskId));
|
||||
Map<String, String> processInstanceNameByProcessInstanceIds = bpmTaskService.getProcessInstanceNameByProcessInstanceIds(convertSet(pageResult.getList(), BpmProcessInstanceCopyDO::getProcessInstanceId));
|
||||
|
||||
Set<Long/* userId */> userIds = new HashSet<>();
|
||||
for (BpmProcessInstanceCopyDO doItem : pageResult.getList()) {
|
||||
userIds.add(doItem.getStartUserId());
|
||||
Long userId = Long.valueOf(doItem.getCreator());
|
||||
userIds.add(userId);
|
||||
}
|
||||
Map<Long, String> userMap = adminUserApi.getUserList(userIds).stream().collect(Collectors.toMap(
|
||||
AdminUserRespDTO::getId, AdminUserRespDTO::getNickname));
|
||||
|
||||
// 转换返回
|
||||
return BpmProcessInstanceCopyConvert.INSTANCE.convertPage(pageResult, taskNameByTaskIds, processInstanceNameByProcessInstanceIds, userMap);
|
||||
return processInstanceCopyMapper.selectPage(loginUserId, pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user