Commit b32ac09ddf025db82dcb3896749cab771b5f499e
1 parent
f958137d
code review 工作机的流程
Showing
4 changed files
with
15 additions
and
3 deletions
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; | @@ -3,6 +3,9 @@ package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model; | ||
| 3 | import io.swagger.annotations.ApiModelProperty; | 3 | import io.swagger.annotations.ApiModelProperty; |
| 4 | import lombok.Data; | 4 | import lombok.Data; |
| 5 | 5 | ||
| 6 | +// TODO @Li:新增和更新 ModelVO 最好分开哈。 | ||
| 7 | +// TODO @Li:swagger 的 example 属性,还有参数校验要加一下哈。 | ||
| 8 | +// TODO @Li:前缀要加 Bpm 。因为是单体工程,不拆分,很容易重复类名 | ||
| 6 | /** | 9 | /** |
| 7 | * 新增模型 VO | 10 | * 新增模型 VO |
| 8 | * @author yunlongn | 11 | * @author yunlongn |
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; | @@ -13,20 +13,23 @@ import org.activiti.engine.repository.Model; | ||
| 13 | */ | 13 | */ |
| 14 | public interface BpmModelService { | 14 | public interface BpmModelService { |
| 15 | 15 | ||
| 16 | - | ||
| 17 | /** | 16 | /** |
| 18 | * 模型数据分页返回 | 17 | * 模型数据分页返回 |
| 19 | * @param modelPageReqVo 分页入参 | 18 | * @param modelPageReqVo 分页入参 |
| 20 | * @return 分页model | 19 | * @return 分页model |
| 21 | */ | 20 | */ |
| 21 | + // TODO @Li:getBpmModelPage。命名上,项目是 动词 + 完整实体; | ||
| 22 | PageResult<Model> pageList(ModelPageReqVo modelPageReqVo); | 22 | PageResult<Model> pageList(ModelPageReqVo modelPageReqVo); |
| 23 | 23 | ||
| 24 | + // TODO @Li:不用返回 CommonResult | ||
| 25 | + // TODO @Li:createBpmModal。 | ||
| 24 | /** | 26 | /** |
| 25 | * 新增一个模型 | 27 | * 新增一个模型 |
| 26 | * @param modelVO 模型对象 | 28 | * @param modelVO 模型对象 |
| 27 | * @return 返回成功 | 29 | * @return 返回成功 |
| 28 | */ | 30 | */ |
| 29 | CommonResult<String> newModel(ModelVO modelVO); | 31 | CommonResult<String> newModel(ModelVO modelVO); |
| 32 | + | ||
| 30 | /** | 33 | /** |
| 31 | * 修改模型属性,填充bpmn数据 | 34 | * 修改模型属性,填充bpmn数据 |
| 32 | * @param modelVO 模型对象 | 35 | * @param modelVO 模型对象 |
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; | @@ -32,6 +32,7 @@ import java.util.Optional; | ||
| 32 | 32 | ||
| 33 | /** | 33 | /** |
| 34 | * 工作流模型实现 | 34 | * 工作流模型实现 |
| 35 | + * | ||
| 35 | * @author yunlongn | 36 | * @author yunlongn |
| 36 | */ | 37 | */ |
| 37 | @Slf4j | 38 | @Slf4j |
| @@ -41,7 +42,6 @@ public class BpmModelServiceImpl implements BpmModelService { | @@ -41,7 +42,6 @@ public class BpmModelServiceImpl implements BpmModelService { | ||
| 41 | 42 | ||
| 42 | private final RepositoryService repositoryService; | 43 | private final RepositoryService repositoryService; |
| 43 | 44 | ||
| 44 | - | ||
| 45 | @Override | 45 | @Override |
| 46 | public PageResult<Model> pageList(ModelPageReqVo modelPageReqVo) { | 46 | public PageResult<Model> pageList(ModelPageReqVo modelPageReqVo) { |
| 47 | ModelQuery modelQuery = repositoryService.createModelQuery(); | 47 | ModelQuery modelQuery = repositoryService.createModelQuery(); |
| @@ -59,6 +59,7 @@ public class BpmModelServiceImpl implements BpmModelService { | @@ -59,6 +59,7 @@ public class BpmModelServiceImpl implements BpmModelService { | ||
| 59 | try { | 59 | try { |
| 60 | //初始化一个空模型 | 60 | //初始化一个空模型 |
| 61 | Model model = repositoryService.newModel(); | 61 | Model model = repositoryService.newModel(); |
| 62 | + // TODO @Li:name 可以直接赋值过去哈,不用声明一个变量 | ||
| 62 | String name = Optional.ofNullable(modelVO.getName()).orElse("new-process"); | 63 | String name = Optional.ofNullable(modelVO.getName()).orElse("new-process"); |
| 63 | //设置一些默认信息 | 64 | //设置一些默认信息 |
| 64 | model.setName(name); | 65 | model.setName(name); |
| @@ -70,10 +71,11 @@ public class BpmModelServiceImpl implements BpmModelService { | @@ -70,10 +71,11 @@ public class BpmModelServiceImpl implements BpmModelService { | ||
| 70 | } | 71 | } |
| 71 | return CommonResult.success(model.getId()); | 72 | return CommonResult.success(model.getId()); |
| 72 | }catch (Exception e){ | 73 | }catch (Exception e){ |
| 74 | + // TODO @Li:这里可以捕获,交给全局么? | ||
| 75 | + // TODO @Li:异常,是不是 error 比较合适,然后堆栈使用 e 直接打印即可 | ||
| 73 | log.info("模型创建失败!modelVO = {} e = {} ", modelVO, ExceptionUtils.getStackTrace(e)); | 76 | log.info("模型创建失败!modelVO = {} e = {} ", modelVO, ExceptionUtils.getStackTrace(e)); |
| 74 | throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_ERROR); | 77 | throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_ERROR); |
| 75 | } | 78 | } |
| 76 | - | ||
| 77 | } | 79 | } |
| 78 | 80 | ||
| 79 | @Override | 81 | @Override |
| @@ -117,6 +119,7 @@ public class BpmModelServiceImpl implements BpmModelService { | @@ -117,6 +119,7 @@ public class BpmModelServiceImpl implements BpmModelService { | ||
| 117 | throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS); | 119 | throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS); |
| 118 | } | 120 | } |
| 119 | // 将xml转换为流 | 121 | // 将xml转换为流 |
| 122 | + // TODO @Li:这里是标准逻辑,看看 hutool 有没工具类提供。如果没有,咱自己封装一个 | ||
| 120 | ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes); | 123 | ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes); |
| 121 | XMLInputFactory xif = XMLInputFactory.newInstance(); | 124 | XMLInputFactory xif = XMLInputFactory.newInstance(); |
| 122 | InputStreamReader in = new InputStreamReader(inputStream, StandardCharsets.UTF_8); | 125 | InputStreamReader in = new InputStreamReader(inputStream, StandardCharsets.UTF_8); |
| @@ -161,7 +164,9 @@ public class BpmModelServiceImpl implements BpmModelService { | @@ -161,7 +164,9 @@ public class BpmModelServiceImpl implements BpmModelService { | ||
| 161 | 164 | ||
| 162 | @Override | 165 | @Override |
| 163 | public CommonResult<String> deleteModel(String modelId) { | 166 | public CommonResult<String> deleteModel(String modelId) { |
| 167 | + // TODO @Li:activitie 是逻辑删除么? | ||
| 164 | repositoryService.deleteModel(modelId); | 168 | repositoryService.deleteModel(modelId); |
| 165 | return CommonResult.success("删除成功"); | 169 | return CommonResult.success("删除成功"); |
| 166 | } | 170 | } |
| 171 | + | ||
| 167 | } | 172 | } |
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/JsonUtils.java
| @@ -93,6 +93,7 @@ public class JsonUtils { | @@ -93,6 +93,7 @@ public class JsonUtils { | ||
| 93 | } | 93 | } |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | + // TODO @Li:和上面的风格保持一致哈。parseTree | ||
| 96 | public static JsonNode readTree(String text) { | 97 | public static JsonNode readTree(String text) { |
| 97 | try { | 98 | try { |
| 98 | return objectMapper.readTree(text); | 99 | return objectMapper.readTree(text); |