From ee1870802f84f4d9d94f0238ed0a87580d94c5f8 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Thu, 18 Jan 2024 19:07:01 +0800 Subject: [PATCH] =?UTF-8?q?=20BPM=EF=BC=9A=E6=8A=84=E9=80=81=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E7=9A=84=20code=20review?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../task/BpmProcessInstanceController.java | 18 +++++----- .../BpmProcessInstanceCCMyPageReqVO.java | 3 +- .../BpmProcessInstanceCCPageItemRespVO.java | 2 ++ .../instance/BpmProcessInstanceCCReqVO.java | 9 +++-- .../cc/BpmProcessInstanceCopyConvert.java | 14 ++++++-- .../cc/BpmProcessInstanceCopyDO.java | 14 +++++--- .../cc/BpmProcessInstanceCopyMapper.java | 2 +- .../BpmCandidateProcessorConfiguration.java | 3 +- .../cc/BpmProcessInstanceCopyService.java | 15 ++++++--- .../cc/BpmProcessInstanceCopyServiceImpl.java | 33 ++++++++++++++----- .../service/cc/BpmProcessInstanceCopyVO.java | 4 +-- .../yudao/module/bpm/util/FlowableUtils.java | 2 ++ .../controller/admin/ip/AreaController.java | 4 +-- .../socail/vo/user/SocialUserBindReqVO.java | 3 -- .../controller/app/ip/AppAreaController.java | 4 +-- .../module/system/convert/ip/AreaConvert.java | 28 ---------------- 16 files changed, 84 insertions(+), 74 deletions(-) delete mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/ip/AreaConvert.java diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java index aab10348b4..0cba2b35f6 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java @@ -2,20 +2,18 @@ package cn.iocoder.yudao.module.bpm.controller.admin.task; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.*; import cn.iocoder.yudao.module.bpm.service.cc.BpmProcessInstanceCopyService; import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import jakarta.validation.Valid; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; @@ -62,19 +60,21 @@ public class BpmProcessInstanceController { return success(true); } + // TODO @kyle:抄送要不单独 controller? @PostMapping("/cc/create") @Operation(summary = "抄送流程") @PreAuthorize("@ss.hasPermission('bpm:process-instance-cc:create')") public CommonResult createProcessInstanceCC(@Valid @RequestBody BpmProcessInstanceCCReqVO createReqVO) { - return success(processInstanceCopyService.ccProcessInstance(SecurityFrameworkUtils.getLoginUserId(), createReqVO)); + return success(processInstanceCopyService.ccProcessInstance(getLoginUserId(), createReqVO)); } @GetMapping("/cc/my-page") @Operation(summary = "获得抄送流程分页列表") @PreAuthorize("@ss.hasPermission('bpm:process-instance-cc:query')") - public CommonResult> getProcessInstanceCCPage(@Valid BpmProcessInstanceCCMyPageReqVO pageReqVO) { - return success(processInstanceCopyService.getMyProcessInstanceCCPage(SecurityFrameworkUtils.getLoginUserId(), pageReqVO)); + public CommonResult> getProcessInstanceCCPage( + @Valid BpmProcessInstanceCCMyPageReqVO pageReqVO) { + return success(processInstanceCopyService.getMyProcessInstanceCCPage(getLoginUserId(), pageReqVO)); } } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCCMyPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCCMyPageReqVO.java index 44de17d385..928ea8d975 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCCMyPageReqVO.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCCMyPageReqVO.java @@ -11,7 +11,8 @@ import java.time.LocalDateTime; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -@Schema(description = "管理后台 - 流程实例抄送的分页 Item Response VO") +// TODO @kyle:建议改成 BpmProcessInstanceCopyMyPageReqVO;cc 缩写不容易理解,所以改成 copy,虽然会长一点,但是可读性更重要; +@Schema(description = "管理后台 - 流程实例抄送的分页 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCCPageItemRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCCPageItemRespVO.java index 2315730ff3..176350c248 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCCPageItemRespVO.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCCPageItemRespVO.java @@ -9,6 +9,7 @@ import java.time.LocalDateTime; @Data public class BpmProcessInstanceCCPageItemRespVO { + // TODO @kyle:如果已经写了 swagger 注解,可以不用写 java 注释哈; /** * 编号 */ @@ -52,4 +53,5 @@ public class BpmProcessInstanceCCPageItemRespVO { @Schema(description = "抄送时间") private LocalDateTime createTime; + } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCCReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCCReqVO.java index c1a73fb24e..a07fd15141 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCCReqVO.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCCReqVO.java @@ -9,8 +9,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -import java.util.Set; - +// TODO @kyle:这个 VO 可以改成 BpmProcessInstanceCopyCreateReqVO @Schema(description = "管理后台 - 流程实例的抄送 Request VO") @Data @EqualsAndHashCode(callSuper = true) @@ -33,7 +32,6 @@ public class BpmProcessInstanceCCReqVO extends BpmTaskCandidateRuleVO { @NotNull(message = "发起流程的用户的编号不能为空") private Long startUserId; - @Schema(description = "任务实例名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @NotEmpty(message = "任务实例名称不能为空") private String processInstanceName; @@ -41,4 +39,9 @@ public class BpmProcessInstanceCCReqVO extends BpmTaskCandidateRuleVO { @Schema(description = "抄送原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "请帮忙审查下!") @NotBlank(message = "抄送原因不能为空") private String reason; + + // TODO @kyle:看了下字段有点多,尽量不传递可推导的字段; + // 需要传递:taskId(任务编号)、reason、userIds(被抄送的人) + // 不需要传递:taskKey、taskName、processInstanceKey、startUserId、processInstanceName 因为这些可以后端查询到 + } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/cc/BpmProcessInstanceCopyConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/cc/BpmProcessInstanceCopyConvert.java index 49327a1344..3be0c131fd 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/cc/BpmProcessInstanceCopyConvert.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/cc/BpmProcessInstanceCopyConvert.java @@ -11,6 +11,7 @@ import org.mapstruct.factory.Mappers; import java.util.List; import java.util.Map; +// TODO kyle:类注释不太对 /** * 动态表单 Convert * @@ -21,14 +22,14 @@ public interface BpmProcessInstanceCopyConvert { BpmProcessInstanceCopyConvert INSTANCE = Mappers.getMapper(BpmProcessInstanceCopyConvert.class); + // TODO @kyle:可以使用 BeanUtils copy 替代这些简单的哈; BpmProcessInstanceCopyDO copy(BpmProcessInstanceCopyDO bean); BpmProcessInstanceCopyVO convert(BpmProcessInstanceCopyDO bean); - List convertList2(List list); - List convertList(List list); + // TODO @kyle:/* taskId */ 这种注释一般不用写,可以一眼看明白的;避免变量看着略微不清晰哈 default PageResult convertPage(PageResult page , Map taskMap , Map processInstaneMap @@ -45,6 +46,15 @@ public interface BpmProcessInstanceCopyConvert { MapUtils.findAndThen(processInstaneMap, vo.getProcessInstanceId(), vo::setProcessInstanceName); } + // TODO @kyle:可以精简成下面的哈; +// List list2 = BeanUtils.toBean(page.getList(), +// BpmProcessInstanceCCPageItemRespVO.class, +// copy -> { +// MapUtils.findAndThen(userMap, Long.valueOf(copy.getCreator()), copy::setCreatorNickname); +// MapUtils.findAndThen(userMap, copy.getStartUserId(), copy::setStartUserNickname); +// MapUtils.findAndThen(taskMap, copy.getTaskId(), copy::setTaskName); +// MapUtils.findAndThen(processInstaneMap, copy.getProcessInstanceId(), copy::setProcessInstanceName); +// }); return new PageResult<>(list, page.getTotal()); } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/cc/BpmProcessInstanceCopyDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/cc/BpmProcessInstanceCopyDO.java index 1735f021e1..3bd2874094 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/cc/BpmProcessInstanceCopyDO.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/cc/BpmProcessInstanceCopyDO.java @@ -6,10 +6,10 @@ import com.baomidou.mybatisplus.annotation.TableName; import lombok.*; /** - * 流程抄送对象 + * 流程抄送 DO * * @author kyle - * @date 2022-05-19 + * @date 2022-05-19 TODO @kyle:@date 不是标准 java doc,可以使用 @since 替代,然后日期是不是不对 */ @TableName(value = "bpm_process_instance_copy", autoResultMap = true) @Data @@ -26,8 +26,9 @@ public class BpmProcessInstanceCopyDO extends BaseDO { @TableId private Long id; + // TODO @kyle:字段如果是关联或者冗余,要写下注释。以 processInstanceId 举例子。 /** - * 发起人Id + * 发起人 Id */ private Long startUserId; /** @@ -35,7 +36,9 @@ public class BpmProcessInstanceCopyDO extends BaseDO { */ private String processInstanceName; /** - * 流程主键 + * 流程实例的编号 + * + * 关联 ProcessInstance 的 id 属性 */ private String processInstanceId; @@ -50,7 +53,7 @@ public class BpmProcessInstanceCopyDO extends BaseDO { private String taskName; /** - * 用户主键 + * 用户编号 */ private Long userId; @@ -59,6 +62,7 @@ public class BpmProcessInstanceCopyDO extends BaseDO { */ private String reason; + // TODO @kyle:这个字段,可以用 category 简化点 /** * 流程分类 */ diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/cc/BpmProcessInstanceCopyMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/cc/BpmProcessInstanceCopyMapper.java index af697f4e75..3b8848428b 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/cc/BpmProcessInstanceCopyMapper.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/cc/BpmProcessInstanceCopyMapper.java @@ -8,7 +8,7 @@ import cn.iocoder.yudao.module.bpm.dal.dataobject.cc.BpmProcessInstanceCopyDO; import org.apache.ibatis.annotations.Mapper; @Mapper -public interface BpmProcessInstanceCopyMapper extends BaseMapperX { +public interface BpmProcessInstanceCopyMapper extends BaseMapperX { // TODO @kyle:方法和类之间要空行下; default PageResult selectPage(Long loginUserId, BpmProcessInstanceCCMyPageReqVO reqVO){ return selectPage(reqVO, new LambdaQueryWrapperX() .eqIfPresent(BpmProcessInstanceCopyDO::getUserId, loginUserId) diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/config/BpmCandidateProcessorConfiguration.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/config/BpmCandidateProcessorConfiguration.java index 293a935d61..cff03488b2 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/config/BpmCandidateProcessorConfiguration.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/config/BpmCandidateProcessorConfiguration.java @@ -6,8 +6,7 @@ import org.springframework.beans.factory.ObjectProvider; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import java.util.List; - +// TODO @芋艿:Candidate 相关还在完善中,用户可以暂时忽略,仅 yudao 开发的同学需要关注~计划是把 Candidate 和 Assign 融合成一套 /** * BPM 通用的 Configuration 配置类,提供给 Activiti 和 Flowable * @author kyle diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/cc/BpmProcessInstanceCopyService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/cc/BpmProcessInstanceCopyService.java index 20285639d0..799656fdeb 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/cc/BpmProcessInstanceCopyService.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/cc/BpmProcessInstanceCopyService.java @@ -6,6 +6,8 @@ import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessI import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCCReqVO; import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo; +// TODO @kyle:这个 Service 要不挪到 task 包下;保持统一,task 下有流程、任务、抄送等; +// TODO @kyle:中文和英文之间,有个空格,会更清晰点;例如说;流程抄送 Service 接口;中文写作习惯~ /** * 流程抄送Service接口 * @@ -13,6 +15,7 @@ import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo; */ public interface BpmProcessInstanceCopyService { + // TODO @kyle:无用的方法,可以去掉哈;另外,考虑到避免过多的 VO,这里就可以返回 BpmProcessInstanceCopyDO /** * 查询流程抄送 * @@ -21,6 +24,7 @@ public interface BpmProcessInstanceCopyService { */ BpmProcessInstanceCopyVO queryById(Long copyId); + // TODO 芋艿:这块要 review 下;思考下~~ /** * 抄送 * @param sourceInfo 抄送源信息,方便抄送处理 @@ -28,13 +32,15 @@ public interface BpmProcessInstanceCopyService { */ boolean makeCopy(BpmCandidateSourceInfo sourceInfo); + // TODO @kyle:可以方法名改成 createProcessInstanceCopy;现在项目一般新增都用 create 为主; /** * 流程实例的抄送 - * @param loginUserId 当前登录用户 + * + * @param userId 当前登录用户 * @param createReqVO 创建的抄送请求 - * @return 是否抄送成功,抄送成功则返回true + * @return 是否抄送成功,抄送成功则返回true TODO @kyle:这里可以不用返回哈;目前一般是失败,就抛出业务异常; */ - boolean ccProcessInstance(Long loginUserId, BpmProcessInstanceCCReqVO createReqVO); + boolean ccProcessInstance(Long userId, BpmProcessInstanceCCReqVO createReqVO); /** * 抄送的流程 @@ -42,5 +48,6 @@ public interface BpmProcessInstanceCopyService { * @param pageReqVO 分页请求 * @return 抄送的分页结果 */ - PageResult getMyProcessInstanceCCPage(Long loginUserId, BpmProcessInstanceCCMyPageReqVO pageReqVO); + PageResult getMyProcessInstanceCCPage(Long loginUserId, + BpmProcessInstanceCCMyPageReqVO pageReqVO); } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/cc/BpmProcessInstanceCopyServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/cc/BpmProcessInstanceCopyServiceImpl.java index 865a6f6996..edc5f7f0af 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/cc/BpmProcessInstanceCopyServiceImpl.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/cc/BpmProcessInstanceCopyServiceImpl.java @@ -11,10 +11,12 @@ import cn.iocoder.yudao.module.bpm.dal.mysql.cc.BpmProcessInstanceCopyMapper; import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo; import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessorChain; import cn.iocoder.yudao.module.bpm.service.cc.dto.BpmDelegateExecutionDTO; +import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService; import cn.iocoder.yudao.module.bpm.util.FlowableUtils; import cn.iocoder.yudao.module.system.api.user.AdminUserApi; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; +import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.flowable.engine.RuntimeService; import org.flowable.engine.delegate.DelegateExecution; @@ -24,33 +26,37 @@ import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; -import jakarta.annotation.Resource; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; -@Slf4j +// TODO @kyle:类注释要写下 +@Slf4j // TODO @kyle:按照 @Service、@Validated、@Slf4j,从重要到不重要的顺序; @Service @Validated public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopyService { - @Resource + @Resource // TODO @kyle:第一个变量,和类之间要有空行; private BpmProcessInstanceCopyMapper processInstanceCopyMapper; /** - * 和flowable有关的,查询流程名用的 + * 和flowable有关的,查询流程名用的 TODO @kyle:可以不写哈注释; */ @Resource private RuntimeService runtimeService; /** - * 找抄送人用的 + * 找抄送人用的 TODO @kyle:可以不写哈注释; */ @Resource private BpmCandidateSourceInfoProcessorChain processorChain; + // TODO @kyle:多余的变量,可以去掉哈 @Resource @Lazy // 解决循环依赖 - private BpmTaskService taskService; + private BpmTaskService bpmTaskService; + @Resource + @Lazy // 解决循环依赖 + private BpmProcessInstanceService bpmProcessInstanceService; @Resource private AdminUserApi adminUserApi; @@ -60,6 +66,10 @@ public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopy return BpmProcessInstanceCopyConvert.INSTANCE.convert(bpmProcessInstanceCopyDO); } + // TODO @kyle:makeCopy 和 ccProcessInstance 的调用关系,感受上反了; + // makeCopy 有点像基于规则,查找抄送人,然后创建; + // ccProcessInstance 是已经有了抄送人,然后创建; + // 建议的改造:独立基于 processInstanceCopyMapper 做 insert @Override public boolean makeCopy(BpmCandidateSourceInfo sourceInfo) { if (null == sourceInfo) { @@ -103,13 +113,13 @@ public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopy } @Override - public boolean ccProcessInstance(Long loginUserId, BpmProcessInstanceCCReqVO reqVO) { + public boolean ccProcessInstance(Long userId, BpmProcessInstanceCCReqVO reqVO) { // 在能正常审批的情况下抄送流程 BpmCandidateSourceInfo sourceInfo = new BpmCandidateSourceInfo(); sourceInfo.setTaskId(reqVO.getTaskKey()); sourceInfo.setProcessInstanceId(reqVO.getProcessInstanceKey()); sourceInfo.addRule(reqVO); - sourceInfo.setCreator(String.valueOf(loginUserId)); + sourceInfo.setCreator(String.valueOf(userId)); sourceInfo.setReason(reqVO.getReason()); if (!makeCopy(sourceInfo)) { throw new RuntimeException("抄送任务失败"); @@ -117,15 +127,20 @@ public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopy return false; } - //获取流程抄送分页 + //获取流程抄送分页 TODO @kyle:接口已经注释,这里不用注释了哈; @Override public PageResult getMyProcessInstanceCCPage(Long loginUserId, BpmProcessInstanceCCMyPageReqVO pageReqVO) { // 通过 BpmProcessInstanceExtDO 表,先查询到对应的分页 + // TODO @kyle:一般读逻辑,Service 返回 PageResult 即可。关联数据的查询和拼接,交给 Controller;目的是:保证 Service 聚焦写逻辑,清晰简洁; PageResult pageResult = processInstanceCopyMapper.selectPage(loginUserId, pageReqVO); if (CollUtil.isEmpty(pageResult.getList())) { return new PageResult<>(pageResult.getTotal()); } + // TODO @kyle:这种可以简洁点;参考如下 +// Map processInstanceMap = bpmProcessInstanceService.getProcessInstanceMap( +// convertSet(pageResult.getList(), BpmProcessInstanceCopyDO::getProcessInstanceId)); + Set taskIds = new HashSet<>(); Set processInstaneIds = new HashSet<>(); Set userIds = new HashSet<>(); diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/cc/BpmProcessInstanceCopyVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/cc/BpmProcessInstanceCopyVO.java index 773335837c..881ec6fd3d 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/cc/BpmProcessInstanceCopyVO.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/cc/BpmProcessInstanceCopyVO.java @@ -1,13 +1,11 @@ package cn.iocoder.yudao.module.bpm.service.cc; -import com.baomidou.mybatisplus.annotation.TableId; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import java.time.LocalDateTime; -import java.util.Date; - +// TODO @kyle:看看是不是要删除 /** * 流程抄送视图对象 wf_copy * diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/util/FlowableUtils.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/util/FlowableUtils.java index 94dabcd8e7..0217ea382f 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/util/FlowableUtils.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/util/FlowableUtils.java @@ -88,6 +88,7 @@ public class FlowableUtils { return task.getName(); } + // TODO @kyle:Utils 里不做查询;可以封装到 bpmTaskService 里 public static Map getTaskNameByTaskIds(Collection taskIds) { TaskService taskService = SpringUtil.getBean(TaskService.class); List tasks = taskService.createTaskQuery().taskIds(taskIds).list(); @@ -109,6 +110,7 @@ public class FlowableUtils { return processInstance.getName(); } + // TODO @kyle:Utils 里不做查询;可以封装到 bpmTaskService 里 public static Map getProcessInstanceNameByTaskIds(Set taskIds) { RuntimeService runtimeService = SpringUtil.getBean(RuntimeService.class); List processInstances = runtimeService.createProcessInstanceQuery().processInstanceIds(taskIds).list(); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/ip/AreaController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/ip/AreaController.java index 2d5c766fdb..b2f95d69f0 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/ip/AreaController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/ip/AreaController.java @@ -2,11 +2,11 @@ package cn.iocoder.yudao.module.system.controller.admin.ip; import cn.hutool.core.lang.Assert; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.ip.core.Area; import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; import cn.iocoder.yudao.framework.ip.core.utils.IPUtils; import cn.iocoder.yudao.module.system.controller.admin.ip.vo.AreaNodeRespVO; -import cn.iocoder.yudao.module.system.convert.ip.AreaConvert; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; @@ -31,7 +31,7 @@ public class AreaController { public CommonResult> getAreaTree() { Area area = AreaUtils.getArea(Area.ID_CHINA); Assert.notNull(area, "获取不到中国"); - return success(AreaConvert.INSTANCE.convertList(area.getChildren())); + return success(BeanUtils.toBean(area.getChildren(), AreaNodeRespVO.class)); } @GetMapping("/get-by-ip") diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/user/SocialUserBindReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/user/SocialUserBindReqVO.java index 815f367fa8..5ed0042a85 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/user/SocialUserBindReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/user/SocialUserBindReqVO.java @@ -31,7 +31,4 @@ public class SocialUserBindReqVO { @NotEmpty(message = "state 不能为空") private String state; - public Integer getType() { - return type; - } } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/ip/AppAreaController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/ip/AppAreaController.java index 98260a34d6..54b0e87dbf 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/ip/AppAreaController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/ip/AppAreaController.java @@ -2,10 +2,10 @@ package cn.iocoder.yudao.module.system.controller.app.ip; import cn.hutool.core.lang.Assert; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.ip.core.Area; import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; import cn.iocoder.yudao.module.system.controller.app.ip.vo.AppAreaNodeRespVO; -import cn.iocoder.yudao.module.system.convert.ip.AreaConvert; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.validation.annotation.Validated; @@ -28,7 +28,7 @@ public class AppAreaController { public CommonResult> getAreaTree() { Area area = AreaUtils.getArea(Area.ID_CHINA); Assert.notNull(area, "获取不到中国"); - return success(AreaConvert.INSTANCE.convertList3(area.getChildren())); + return success(BeanUtils.toBean(area.getChildren(), AppAreaNodeRespVO.class)); } } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/ip/AreaConvert.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/ip/AreaConvert.java deleted file mode 100644 index 6ba76ef92d..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/ip/AreaConvert.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.system.convert.ip; - -import cn.iocoder.yudao.framework.ip.core.Area; -import cn.iocoder.yudao.module.system.controller.admin.ip.vo.AreaNodeRespVO; -import cn.iocoder.yudao.module.system.controller.app.ip.vo.AppAreaNodeRespVO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface AreaConvert { - - AreaConvert INSTANCE = Mappers.getMapper(AreaConvert.class); - - List convertList(List list); - - List convertList3(List list); - - /** - * 缺少单个转换 - * @param value - * @return - */ - AreaNodeRespVO map(Area value); - - AppAreaNodeRespVO map3(Area value); -}