6c
2025-12-02 216b43c84804b2ce5b1e1b7b808942078f73ee69
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
package com.product.integration.controller;
 
import com.product.admin.config.SystemCode;
import com.product.common.lang.StringUtils;
import com.product.core.config.CoreConst;
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.integration.config.CmnConst;
import com.product.integration.config.IntegrationCode;
import com.product.integration.service.InterfaceIntegrationService;
import com.product.integration.service.idel.IInterfaceIntegrationService;
import com.product.module.sys.version.ApiVersion;
import com.product.util.BaseUtil;
import com.product.util.support.AbstractBaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.servlet.http.HttpServletRequest;
 
/**
 * 实现功能:
 *
 * @author 作者[夜丶光]
 * @version 1.0.00  2025-12-01 11:15
 */
@RestController
@RequestMapping("/api/interface-integration")
public class InterfaceIntegrationController extends AbstractBaseController {
 
    @Autowired
    private InterfaceIntegrationService interfaceIntegrationService;
 
    /**
     * 单个查询
     * @param request
     * @return
     */
    @RequestMapping(value = "/find/{version}")
    @ApiVersion(1)
    public String find(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) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
                return error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
            }
            if (fse.getTableName() == null || !CmnConst.PRODUCT_SYS_INTERFACE_INTEGRATION.equals(fse.getTableName()) || StringUtils.isEmpty(fse.getUUID())) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
                return error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
            }
            return BaseUtil.success(interfaceIntegrationService.find(fse));
        } catch (BaseException e) {
            e.printStackTrace();
            SpringMVCContextHolder.getSystemLogger().error(e);
            return error(e);
        } catch (Exception e) {
            e.printStackTrace();
            SpringMVCContextHolder.getSystemLogger().error(e);
            return error(IntegrationCode.FIND_FAIL);
        }
    }
 
    /**
     * 保存
     * @param request
     * @return
     */
    @RequestMapping(value = "/save/{version}")
    @ApiVersion(1)
    public String save(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) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
                return error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
            }
            if (fse.getTableName() == null || !CmnConst.PRODUCT_SYS_INTERFACE_INTEGRATION.equals(fse.getTableName())) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
                return error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
            }
            IInterfaceIntegrationService service = (IInterfaceIntegrationService) getProxyInstance(interfaceIntegrationService);
            return BaseUtil.success(service.save(fse));
        } catch (BaseException e) {
            e.printStackTrace();
            SpringMVCContextHolder.getSystemLogger().error(e);
            return error(e);
        } catch (Exception e) {
            e.printStackTrace();
            SpringMVCContextHolder.getSystemLogger().error(e);
            return error(IntegrationCode.SAVE_FAIL);
        }
    }
}