code review 工作机的流程

pull/2/head
YunaiV 2021-11-21 12:59:52 +08:00
parent f958137dd1
commit b32ac09ddf
4 changed files with 15 additions and 3 deletions

View File

@ -3,6 +3,9 @@ package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
// TODO @Li新增和更新 ModelVO 最好分开哈。
// TODO @Liswagger 的 example 属性,还有参数校验要加一下哈。
// TODO @Li前缀要加 Bpm 。因为是单体工程,不拆分,很容易重复类名
/** /**
* VO * VO
* @author yunlongn * @author yunlongn

View File

@ -13,20 +13,23 @@ import org.activiti.engine.repository.Model;
*/ */
public interface BpmModelService { public interface BpmModelService {
/** /**
* *
* @param modelPageReqVo * @param modelPageReqVo
* @return model * @return model
*/ */
// TODO @LigetBpmModelPage。命名上项目是 动词 + 完整实体;
PageResult<Model> pageList(ModelPageReqVo modelPageReqVo); PageResult<Model> pageList(ModelPageReqVo modelPageReqVo);
// TODO @Li不用返回 CommonResult
// TODO @LicreateBpmModal。
/** /**
* *
* @param modelVO * @param modelVO
* @return * @return
*/ */
CommonResult<String> newModel(ModelVO modelVO); CommonResult<String> newModel(ModelVO modelVO);
/** /**
* bpmn * bpmn
* @param modelVO * @param modelVO

View File

@ -32,6 +32,7 @@ import java.util.Optional;
/** /**
* *
*
* @author yunlongn * @author yunlongn
*/ */
@Slf4j @Slf4j
@ -41,7 +42,6 @@ public class BpmModelServiceImpl implements BpmModelService {
private final RepositoryService repositoryService; private final RepositoryService repositoryService;
@Override @Override
public PageResult<Model> pageList(ModelPageReqVo modelPageReqVo) { public PageResult<Model> pageList(ModelPageReqVo modelPageReqVo) {
ModelQuery modelQuery = repositoryService.createModelQuery(); ModelQuery modelQuery = repositoryService.createModelQuery();
@ -59,6 +59,7 @@ public class BpmModelServiceImpl implements BpmModelService {
try { try {
//初始化一个空模型 //初始化一个空模型
Model model = repositoryService.newModel(); Model model = repositoryService.newModel();
// TODO @Liname 可以直接赋值过去哈,不用声明一个变量
String name = Optional.ofNullable(modelVO.getName()).orElse("new-process"); String name = Optional.ofNullable(modelVO.getName()).orElse("new-process");
//设置一些默认信息 //设置一些默认信息
model.setName(name); model.setName(name);
@ -70,10 +71,11 @@ public class BpmModelServiceImpl implements BpmModelService {
} }
return CommonResult.success(model.getId()); return CommonResult.success(model.getId());
}catch (Exception e){ }catch (Exception e){
// TODO @Li这里可以捕获交给全局么
// TODO @Li异常是不是 error 比较合适,然后堆栈使用 e 直接打印即可
log.info("模型创建失败modelVO = {} e = {} ", modelVO, ExceptionUtils.getStackTrace(e)); log.info("模型创建失败modelVO = {} e = {} ", modelVO, ExceptionUtils.getStackTrace(e));
throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_ERROR); throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_ERROR);
} }
} }
@Override @Override
@ -117,6 +119,7 @@ public class BpmModelServiceImpl implements BpmModelService {
throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS); throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS);
} }
// 将xml转换为流 // 将xml转换为流
// TODO @Li这里是标准逻辑看看 hutool 有没工具类提供。如果没有,咱自己封装一个
ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes); ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
XMLInputFactory xif = XMLInputFactory.newInstance(); XMLInputFactory xif = XMLInputFactory.newInstance();
InputStreamReader in = new InputStreamReader(inputStream, StandardCharsets.UTF_8); InputStreamReader in = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
@ -161,7 +164,9 @@ public class BpmModelServiceImpl implements BpmModelService {
@Override @Override
public CommonResult<String> deleteModel(String modelId) { public CommonResult<String> deleteModel(String modelId) {
// TODO @Liactivitie 是逻辑删除么?
repositoryService.deleteModel(modelId); repositoryService.deleteModel(modelId);
return CommonResult.success("删除成功"); return CommonResult.success("删除成功");
} }
} }

View File

@ -93,6 +93,7 @@ public class JsonUtils {
} }
} }
// TODO @Li和上面的风格保持一致哈。parseTree
public static JsonNode readTree(String text) { public static JsonNode readTree(String text) {
try { try {
return objectMapper.readTree(text); return objectMapper.readTree(text);