Commit 0896593146e8896359081f749484bf86901ac260
1 parent
a3416fc4
feat(bpm):新增流程模型操作导出模型json接口
Showing
4 changed files
with
34 additions
and
0 deletions
yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmModelController.java
| @@ -117,6 +117,14 @@ public class BpmModelController { | @@ -117,6 +117,14 @@ public class BpmModelController { | ||
| 117 | return success(BpmModelConvert.INSTANCE.buildModel(model, bpmnBytes, simpleModel)); | 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 | @PostMapping("/create") | 128 | @PostMapping("/create") |
| 121 | @Operation(summary = "新建模型") | 129 | @Operation(summary = "新建模型") |
| 122 | @PreAuthorize("@ss.hasPermission('bpm:model:create')") | 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,6 +111,18 @@ public interface BpmModelConvert { | ||
| 111 | model.setMetaInfo(JsonUtils.toJsonString(BeanUtils.toBean(reqVO, BpmModelMetaInfoVO.class))); | 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 | default BpmModelMetaInfoVO parseMetaInfo(Model model) { | 126 | default BpmModelMetaInfoVO parseMetaInfo(Model model) { |
| 115 | BpmModelMetaInfoVO vo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoVO.class); | 127 | BpmModelMetaInfoVO vo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoVO.class); |
| 116 | if (vo == null) { | 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,6 +49,14 @@ public interface BpmModelService { | ||
| 49 | String importModel(@Valid BpmModelSaveReqVO reqVO); | 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 | * @param id 编号 | 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,6 +143,12 @@ public class BpmModelServiceImpl implements BpmModelService { | ||
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | @Override | 145 | @Override |
| 146 | + public BpmModelSaveReqVO exportModel(String id) { | ||
| 147 | + Model model = validateModelExists(id); | ||
| 148 | + return BpmModelConvert.INSTANCE.convertToSaveReqVO(model); | ||
| 149 | + } | ||
| 150 | + | ||
| 151 | + @Override | ||
| 146 | @Transactional(rollbackFor = Exception.class) // 因为进行多个操作,所以开启事务 | 152 | @Transactional(rollbackFor = Exception.class) // 因为进行多个操作,所以开启事务 |
| 147 | public void updateModel(Long userId, BpmModelSaveReqVO updateReqVO) { | 153 | public void updateModel(Long userId, BpmModelSaveReqVO updateReqVO) { |
| 148 | // 1. 校验流程模型存在 | 154 | // 1. 校验流程模型存在 |