From b32ac09ddf025db82dcb3896749cab771b5f499e Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 21 Nov 2021 12:59:52 +0800 Subject: [PATCH] =?UTF-8?q?code=20review=20=E5=B7=A5=E4=BD=9C=E6=9C=BA?= =?UTF-8?q?=E7=9A=84=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bpm/controller/workflow/vo/model/ModelVO.java | 3 +++ .../modules/bpm/service/workflow/BpmModelService.java | 5 ++++- .../bpm/service/workflow/impl/BpmModelServiceImpl.java | 9 +++++++-- .../yudao/framework/common/util/json/JsonUtils.java | 1 + 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/model/ModelVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/model/ModelVO.java index 9858b05ee..c914d9629 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/model/ModelVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/model/ModelVO.java @@ -3,6 +3,9 @@ package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +// TODO @Li:新增和更新 ModelVO 最好分开哈。 +// TODO @Li:swagger 的 example 属性,还有参数校验要加一下哈。 +// TODO @Li:前缀要加 Bpm 。因为是单体工程,不拆分,很容易重复类名 /** * 新增模型 VO * @author yunlongn diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/BpmModelService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/BpmModelService.java index 1c07ce5f9..c954c3404 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/BpmModelService.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/BpmModelService.java @@ -13,20 +13,23 @@ import org.activiti.engine.repository.Model; */ public interface BpmModelService { - /** * 模型数据分页返回 * @param modelPageReqVo 分页入参 * @return 分页model */ + // TODO @Li:getBpmModelPage。命名上,项目是 动词 + 完整实体; PageResult pageList(ModelPageReqVo modelPageReqVo); + // TODO @Li:不用返回 CommonResult + // TODO @Li:createBpmModal。 /** * 新增一个模型 * @param modelVO 模型对象 * @return 返回成功 */ CommonResult newModel(ModelVO modelVO); + /** * 修改模型属性,填充bpmn数据 * @param modelVO 模型对象 diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/impl/BpmModelServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/impl/BpmModelServiceImpl.java index b368d6baa..4f81ec141 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/impl/BpmModelServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/impl/BpmModelServiceImpl.java @@ -32,6 +32,7 @@ import java.util.Optional; /** * 工作流模型实现 + * * @author yunlongn */ @Slf4j @@ -41,7 +42,6 @@ public class BpmModelServiceImpl implements BpmModelService { private final RepositoryService repositoryService; - @Override public PageResult pageList(ModelPageReqVo modelPageReqVo) { ModelQuery modelQuery = repositoryService.createModelQuery(); @@ -59,6 +59,7 @@ public class BpmModelServiceImpl implements BpmModelService { try { //初始化一个空模型 Model model = repositoryService.newModel(); + // TODO @Li:name 可以直接赋值过去哈,不用声明一个变量 String name = Optional.ofNullable(modelVO.getName()).orElse("new-process"); //设置一些默认信息 model.setName(name); @@ -70,10 +71,11 @@ public class BpmModelServiceImpl implements BpmModelService { } return CommonResult.success(model.getId()); }catch (Exception e){ + // TODO @Li:这里可以捕获,交给全局么? + // TODO @Li:异常,是不是 error 比较合适,然后堆栈使用 e 直接打印即可 log.info("模型创建失败!modelVO = {} e = {} ", modelVO, ExceptionUtils.getStackTrace(e)); throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_ERROR); } - } @Override @@ -117,6 +119,7 @@ public class BpmModelServiceImpl implements BpmModelService { throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS); } // 将xml转换为流 + // TODO @Li:这里是标准逻辑,看看 hutool 有没工具类提供。如果没有,咱自己封装一个 ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes); XMLInputFactory xif = XMLInputFactory.newInstance(); InputStreamReader in = new InputStreamReader(inputStream, StandardCharsets.UTF_8); @@ -161,7 +164,9 @@ public class BpmModelServiceImpl implements BpmModelService { @Override public CommonResult deleteModel(String modelId) { + // TODO @Li:activitie 是逻辑删除么? repositoryService.deleteModel(modelId); return CommonResult.success("删除成功"); } + } diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/JsonUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/JsonUtils.java index 542af7768..be5b66a04 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/JsonUtils.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/JsonUtils.java @@ -93,6 +93,7 @@ public class JsonUtils { } } + // TODO @Li:和上面的风格保持一致哈。parseTree public static JsonNode readTree(String text) { try { return objectMapper.readTree(text);