xiejun
2024-09-04 ac3f3629a261770f573f27e5e23f7ec19d096c2a
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
package com.vci.web.controller;
 
import com.vci.corba.common.PLException;
import com.vci.corba.portal.data.PLUILayout;
import com.vci.dto.OsBtmTypeDTO;
import com.vci.pagemodel.PLUILayoutCloneVO;
import com.vci.starter.web.annotation.log.VciBusinessLog;
import com.vci.starter.web.pagemodel.BaseQueryObject;
import com.vci.starter.web.pagemodel.BaseResult;
import com.vci.starter.web.pagemodel.Tree;
import com.vci.starter.web.util.VciBaseUtil;
import com.vci.web.service.OsBtmServiceI;
import com.vci.web.service.UIManagerServiceI;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.Arrays;
import java.util.List;
 
/**
 * UI定义控制层
 * @author ludc
 * @date 2024/8/28 17:09
 */
@RestController
@RequestMapping("/uiManagerController")
public class UIManagerController {
 
    /**
     * 日志
     */
    private Logger logger = LoggerFactory.getLogger(getClass());
 
    /**
     * 业务类型的服务
     */
    @Autowired
    private OsBtmServiceI btmService;
 
    /**
     * UI定义服务
     */
    @Autowired
    private UIManagerServiceI uiManagerService;
 
    /**
     * 业务类型列表查询,非树结构:用于UI定义左侧业务类型查询
     * @param btmName
     * @return
     * @throws PLException
     */
    @GetMapping( "/getBizTree")
    @VciBusinessLog(operateName = "业务类型列表(主要用于UI定义业务类型树查询使用)")
    public BaseResult getBizTree(String btmName){
        try {
            return BaseResult.success(btmService.getBizTree(btmName));
        }catch (Exception e) {
            e.printStackTrace();
            String exceptionMessage = "获取UI定义业务类型列表时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e);
            logger.error(exceptionMessage);
            return BaseResult.fail(exceptionMessage);
        }
    }
 
    /**
     * 通过业务类型name查询ui上下文,支持分页
     * @param baseQueryObject
     * @return
     * @throws PLException
     */
    @GetMapping( "/gridUIContextData")
    @VciBusinessLog(operateName = "通过业务类型name查询出ui上下文")
    public BaseResult gridUIContextData(BaseQueryObject baseQueryObject){
        try {
            return BaseResult.dataGrid(uiManagerService.gridUIContextData(baseQueryObject));
        }catch (Exception e) {
            e.printStackTrace();
            String exceptionMessage = "通过业务类型name查询出ui上下文时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e);
            logger.error(exceptionMessage);
            return BaseResult.fail(exceptionMessage);
        }
    }
 
    /**
     * 创建UI上下文
     * btmTypeDTO 链接类型的保存对象
     * @return 保存结果
     */
    @PostMapping("/saveUIContextData")
    public BaseResult saveUIContextData(@RequestBody PLUILayout pluiLayout){
        try {
            return uiManagerService.saveUIContextData(pluiLayout) ? BaseResult.success("UI上下文创建成功!"):BaseResult.fail("UI上下文创建失败!");
        } catch (Exception e) {
            e.printStackTrace();
            String exceptionMessage = "创建UI上下文时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e);
            logger.error(exceptionMessage);
            return BaseResult.fail(exceptionMessage);
        }
    }
 
    /**
     * 修改UI上下文
     * btmTypeDTO
     * @return 修改结果
     */
    @PutMapping("/updateUIContextData")
    public BaseResult updateUIContextData(@RequestBody PLUILayout pluiLayout){
        try {
            return uiManagerService.updateUIContextData(pluiLayout) ? BaseResult.success("UI上下文修改成功!"):BaseResult.fail("UI上下文修改失败!");
        } catch (Exception e) {
            e.printStackTrace();
            String exceptionMessage = "修改UI上下文时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e);
            logger.error(exceptionMessage);
            return BaseResult.fail(exceptionMessage);
        }
    }
 
    /**
     * 删除UI上下文数据
     * oids 删除的oid信息
     * @return 删除结果
     */
    @DeleteMapping("/delUIContextData")
    public BaseResult delUIContextData(String[] oids){
        try {
            return uiManagerService.delUIContextData(oids) ? BaseResult.success("UI上下文删除成功!"):BaseResult.fail("UI上下文删除失败!");
        } catch (PLException e) {
            e.printStackTrace();
            String exceptionMessage = "删除UI上下文时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e);
            logger.error(exceptionMessage);
            return BaseResult.fail(exceptionMessage);
        }
    }
 
    /**
     * UI上下文克隆
     * pluiLayoutCloneVO 克隆参数对象
     * @return 克隆结构
     */
    @PostMapping("/cloneUiContextData")
    public BaseResult cloneUiContextData(@RequestBody PLUILayoutCloneVO pluiLayoutCloneVO){
        try {
            return uiManagerService.cloneUiContextData(pluiLayoutCloneVO) ? BaseResult.success("UI上下文克隆成功!"):BaseResult.fail("UI上下文克隆失败!");
        } catch (PLException e) {
            e.printStackTrace();
            String exceptionMessage = "UI上下文克隆时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e);
            logger.error(exceptionMessage);
            return BaseResult.fail(exceptionMessage);
        }
    }
 
    /**
     * 根据角色获取UI/表单/按钮的权限.
     * @param baseQueryObject
     * @return
     */
    @GetMapping( "/getUIAuthor")
    @VciBusinessLog(operateName = "UI授权(树形结构)")
    public BaseResult getUIAuthor(BaseQueryObject baseQueryObject){
        try {
            return BaseResult.dataList( uiManagerService.getUIAuthor(baseQueryObject));
        }catch (Throwable e) {
            e.printStackTrace();
            String exceptionMessage = "UI授权加载出现错误,原因:" + VciBaseUtil.getExceptionMessage(e);
            logger.error(exceptionMessage);
            return BaseResult.fail(exceptionMessage);
        }
    }
 
}