354798ggg
2023-05-16 68aae14c5c33b525effd4fe18a6ce14ea6ec90ae
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
package com.product.print.controller;
 
import com.product.common.lang.StringUtils;
import com.product.core.config.CoreConst;
import com.product.core.entity.FieldMetaEntity;
import com.product.core.entity.FieldSetEntity;
import com.product.core.entity.RequestParameterEntity;
import com.product.core.exception.BaseException;
import com.product.core.spring.context.SpringMVCContextHolder;
import com.product.core.util.JsonUtil;
import com.product.module.sys.version.ApiVersion;
import com.product.print.config.CmnCode;
import com.product.print.config.CmnConst;
import com.product.print.service.ide.IPrintConfigService;
import com.product.util.BaseUtil;
import com.product.util.support.AbstractBaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.servlet.http.HttpServletRequest;
 
/**
 * @ClassName PrintConfigContorller
 * @Description 打印配置 控制层
 * @Author cheng
 * @Date 2021/11/30 15:44
 */
@RequestMapping("api/print/config")
@RestController
public class PrintConfigController extends AbstractBaseController {
 
    @Autowired
    IPrintConfigService printConfigService;
 
 
    /**
     * 打印配置列表
     *
     * @param request
     * @return
     */
    @PostMapping("/list-print-config/{version}")
    @ApiVersion(1)
    public String listPrintConfig(HttpServletRequest request) {
        try {
            FieldSetEntity fse = null;
            Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
            if (bean != null) {
                RequestParameterEntity reqp = (RequestParameterEntity) bean;
                fse = reqp.getFormData();
            }
            if (bean == null || fse == null) {
                return this.error(CmnCode.SYSTEM_FORM_NODATA);
            }
            if (!CmnConst.TABLE_PRINT_CONFIG.equals(fse.getTableName())) {
                return error(CmnCode.SYSTEM_TABLE_NODATA);
            }
            if (!BaseUtil.pageParameterVerification(fse)) {
                return error(CmnCode.SYSTEM_PAGE_NOT_NULL);
            }
            return OK_List(this.printConfigService.getPublicService().listTable(fse));
        } catch (BaseException e) {
            return error(e);
        } catch (Exception e) {
            return error(CmnCode.GET_PRINT_CONFIG_LIST_FAIL, e);
        }
    }
 
    /**
     * 查询打印配置
     *
     * @param request
     * @return
     */
    @PostMapping("/find-print-config/{version}")
    @ApiVersion(1)
    public String findPrintConfig(HttpServletRequest request) {
        try {
            FieldSetEntity fse = null;
            Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
            if (bean != null) {
                RequestParameterEntity reqp = (RequestParameterEntity) bean;
                fse = reqp.getFormData();
            }
            if (bean == null || fse == null) {
                return this.error(CmnCode.SYSTEM_FORM_NODATA);
            }
            if (!CmnConst.TABLE_PRINT_CONFIG.equals(fse.getTableName())) {
                return error(CmnCode.SYSTEM_TABLE_NODATA);
            }
            if (StringUtils.isEmpty(fse.getString(CmnConst.UUID))) {
                return error(CmnCode.SYSTEM_FORM_COUNT);
            }
            return OK_List(printConfigService.getPublicService().getFieldSetEntity(fse, false));
        } catch (BaseException e) {
            return error(e);
        } catch (Exception e) {
            return error(CmnCode.GET_PRINT_CONFIG_LIST_FAIL, e);
        }
    }
 
    /**
     * 保存打印配置
     *
     * @param request
     * @return
     */
    @PostMapping("/save-print-config/{version}")
    @ApiVersion(1)
    public String savePrintConfig(HttpServletRequest request) {
        try {
            FieldSetEntity fse = null;
            Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
            if (bean != null) {
                RequestParameterEntity reqp = (RequestParameterEntity) bean;
                fse = reqp.getFormData();
            }
            if (bean == null || fse == null) {
                return this.error(CmnCode.SYSTEM_FORM_NODATA);
            }
            if (!CmnConst.TABLE_PRINT_CONFIG.equals(fse.getTableName())) {
                return error(CmnCode.SYSTEM_TABLE_NODATA);
            }
            printConfigService.getPublicService().saveFieldSetEntity(fse);
            return OK();
        } catch (BaseException e) {
            return error(e);
        } catch (Exception e) {
            return error(CmnCode.GET_PRINT_CONFIG_LIST_FAIL, e);
        }
    }
 
    /**
     * 删除打印配置
     *
     * @param request
     * @return
     */
    @PostMapping("/del-print-config/{version}")
    @ApiVersion(1)
    public String delPrintConfig(HttpServletRequest request) {
        try {
            FieldSetEntity fse = null;
            Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
            if (bean != null) {
                RequestParameterEntity reqp = (RequestParameterEntity) bean;
                fse = reqp.getFormData();
            }
            if (bean == null || fse == null) {
                return this.error(CmnCode.SYSTEM_FORM_NODATA);
            }
            if (!CmnConst.TABLE_PRINT_CONFIG.equals(fse.getTableName())) {
                return error(CmnCode.SYSTEM_TABLE_NODATA);
            }
            if (StringUtils.isEmpty(fse.getString(CmnConst.UUID))) {
                return error(CmnCode.SYSTEM_FORM_COUNT);
            }
            printConfigService.getPublicService().delete(fse);
            return OK();
        } catch (BaseException e) {
            return error(e);
        } catch (Exception e) {
            return error(CmnCode.GET_PRINT_CONFIG_LIST_FAIL, e);
        }
    }
 
 
}