Commit 0896593146e8896359081f749484bf86901ac260

Authored by gnomeshgh
1 parent a3416fc4

feat(bpm):新增流程模型操作导出模型json接口

yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmModelController.java
... ... @@ -117,6 +117,14 @@ public class BpmModelController {
117 117 return success(BpmModelConvert.INSTANCE.buildModel(model, bpmnBytes, simpleModel));
118 118 }
119 119  
  120 + @GetMapping("/export")
  121 + @Operation(summary = "导出模型")
  122 + @Parameter(name = "id", description = "编号", required = true, example = "1024")
  123 + @PreAuthorize("@ss.hasPermission('bpm:model:export')")
  124 + public CommonResult<BpmModelSaveReqVO> exportModel(@RequestParam("id") String id) {
  125 + return success(modelService.exportModel(id));
  126 + }
  127 +
120 128 @PostMapping("/create")
121 129 @Operation(summary = "新建模型")
122 130 @PreAuthorize("@ss.hasPermission('bpm:model:create')")
... ...
yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmModelConvert.java
... ... @@ -111,6 +111,18 @@ public interface BpmModelConvert {
111 111 model.setMetaInfo(JsonUtils.toJsonString(BeanUtils.toBean(reqVO, BpmModelMetaInfoVO.class)));
112 112 }
113 113  
  114 + default BpmModelSaveReqVO convertToSaveReqVO(Model model) {
  115 + BpmModelMetaInfoVO metaInfo = parseMetaInfo(model);
  116 + BpmModelSaveReqVO reqVO = new BpmModelSaveReqVO();
  117 + reqVO.setKey(model.getKey());
  118 + reqVO.setName(model.getName());
  119 + reqVO.setCategory(model.getCategory());
  120 + if (metaInfo != null) {
  121 + BeanUtils.copyProperties(metaInfo, reqVO);
  122 + }
  123 + return reqVO;
  124 + }
  125 +
114 126 default BpmModelMetaInfoVO parseMetaInfo(Model model) {
115 127 BpmModelMetaInfoVO vo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoVO.class);
116 128 if (vo == null) {
... ...
yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelService.java
... ... @@ -49,6 +49,14 @@ public interface BpmModelService {
49 49 String importModel(@Valid BpmModelSaveReqVO reqVO);
50 50  
51 51 /**
  52 + * 导出流程模型
  53 + *
  54 + * @param id 编号
  55 + * @return 导出的流程模型
  56 + */
  57 + BpmModelSaveReqVO exportModel(String id);
  58 +
  59 + /**
52 60 * 获得流程模块
53 61 *
54 62 * @param id 编号
... ...
yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java
... ... @@ -143,6 +143,12 @@ public class BpmModelServiceImpl implements BpmModelService {
143 143 }
144 144  
145 145 @Override
  146 + public BpmModelSaveReqVO exportModel(String id) {
  147 + Model model = validateModelExists(id);
  148 + return BpmModelConvert.INSTANCE.convertToSaveReqVO(model);
  149 + }
  150 +
  151 + @Override
146 152 @Transactional(rollbackFor = Exception.class) // 因为进行多个操作,所以开启事务
147 153 public void updateModel(Long userId, BpmModelSaveReqVO updateReqVO) {
148 154 // 1. 校验流程模型存在
... ...