kimi
2020-05-27 c007f0ca1785db093d48f4846cda82fe8e955765
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package com.highdatas.mdm.controller;
 
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.highdatas.mdm.pojo.CodeMsg;
import com.highdatas.mdm.pojo.Result;
import com.highdatas.mdm.service.ModelEditorService;
import com.highdatas.mdm.service.act.IdentityService;
import com.highdatas.mdm.service.act.RepositoryService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
 
/**
 * @author kimi
 * @description 流程设计器接口
 * @date 2019-12-11 11:00
 */
 
@RestController
@RequestMapping("/designer")
public class ActivitiDesignerController {
    @Autowired
    ModelEditorService modelEditorService;
    @Autowired
    RepositoryService repositoryService;
    @Autowired
    IdentityService identityService;
 
    /**
     *
     * @description:  创建一个新流程
     * @return: Result 返回创建的model id
     *
     */
    @RequestMapping(value = "/create", method = RequestMethod.GET)
    public String createModel() {
        String modelId = modelEditorService.createModel();
        return modelId;
    }
 
    /**
     *
     * @description:  返回带有model信息的编辑器界面
     * @param: modelId  model Id
     * @param: userId  用户id
     * @return:  流程编辑器页面
     *
     */
    @RequestMapping(value = "/edit", method = RequestMethod.GET)
    public String getModel(HttpServletResponse response, String modelId) throws IOException {
        if (StringUtils.isEmpty(modelId)) {
            modelId = modelEditorService.createModel();
        }
        return "./process/modeler.html?modelId=" + modelId;
    }
 
    /**
     *
     * @description:  保存model信息
     * @param: modelId  model Id
     * @return: Result 是否保存成功
     *
     */
    @RequestMapping(value="/model/{modelId}/save", method = RequestMethod.PUT)
 
    public Result saveModel(@PathVariable String modelId, HttpServletRequest request) {
        boolean saved = repositoryService.saveModel(modelId, request);
        if (saved) {
            return Result.success(null);
        } else {
            return Result.error(new CodeMsg(1000, "未检测到任一标签"));
        }
    }
    /**
     *
     * @description:  删除model信息
     * @param: modelId  model Id
     * @return: Result 是否删除model信息
     *
     */
    @RequestMapping(value="/model/{modelId}/delete", method = RequestMethod.PUT)
    @ResponseStatus(value = HttpStatus.OK)
    public void deleteModel(@PathVariable String modelId) {
        repositoryService.deleteModel(modelId);
    }
 
 
    /**
     *
     * @description:  通过model ID 获取流程编辑器使用的 Edit json信息
     * @param: modelId  model Id
     * @return: Result Edit json信息
     *
     */
    @RequestMapping(value="/model/{modelId}/json", method = RequestMethod.GET, produces = "application/json")
    public ObjectNode getEditorJson(@PathVariable String modelId) {
        return modelEditorService.getEditorJson(modelId);
    }
 
    /**
     *
     * @description:  获取stencilset.json 流程编辑器使用
     * @return:   返回stencilset.json
     *
     */
    @RequestMapping(value="/editor/stencilset", method = RequestMethod.GET, produces = "application/json;charset=utf-8")
    public @ResponseBody
    String getStencilset() {
        return modelEditorService.getStencilset();
    }
}