kimi
2020-03-31 74472c9d22dddcb41383794caf0011043b20f817
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
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;
 
 
    @RequestMapping(value = "/create", method = RequestMethod.GET)
    public String createModel() {
        String modelId = modelEditorService.createModel();
        return modelId;
    }
 
    @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;
    }
 
    @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, "未检测到任一标签"));
        }
    }
 
    @RequestMapping(value="/model/{modelId}/delete", method = RequestMethod.PUT)
    @ResponseStatus(value = HttpStatus.OK)
    public void deleteModel(@PathVariable String modelId) {
        repositoryService.deleteModel(modelId);
    }
 
 
        @RequestMapping(value="/model/{modelId}/json", method = RequestMethod.GET, produces = "application/json")
    public ObjectNode getEditorJson(@PathVariable String modelId) {
        return modelEditorService.getEditorJson(modelId);
    }
 
    @RequestMapping(value="/editor/stencilset", method = RequestMethod.GET, produces = "application/json;charset=utf-8")
    public @ResponseBody
    String getStencilset() {
        return modelEditorService.getStencilset();
    }
}