shichongfu
2023-04-25 ce0b49552668d3331055e2b1a1447a743dc54939
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
package com.product.admin.controller;
 
import com.alibaba.druid.util.StringUtils;
import com.product.admin.config.CmnConst;
import com.product.admin.config.SystemCode;
import com.product.admin.service.SystemInInterfaceService;
import com.product.core.config.CoreConst;
import com.product.core.controller.support.AbstractBaseController;
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.module.sys.version.ApiVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
 
import javax.servlet.http.HttpServletRequest;
 
/**
 * @Author cheng
 * @Description 系统接口
 * @Date 2021/3/25 19:41
 * @Version 1.0
 */
 
@RestController
@RequestMapping("api/interface/api")
public class SystemInInterfaceController extends AbstractBaseController {
 
    @Autowired
    SystemInInterfaceService systemInInterfaceService;
 
    /**
     * 列表
     * @param request
     * @return
     */
    @RequestMapping(value = "/list-api-info/{version}",method = RequestMethod.POST)
    @ApiVersion(1)
    public String getList(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 this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
            }
            // 判断表名是否正常
            if (fse.getTableName() == null || !CmnConst.PRODUCT_SYS_CLIENTS.equals(fse.getTableName())) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
                return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
            }
            // 判断分页参数是否正常
            if (StringUtils.isEmpty(fse.getString(CmnConst.PAGESIZE))
                    || StringUtils.isEmpty(fse.getString(CmnConst.CPAGE))) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText());
                return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText());
            }
            return OK_List(systemInInterfaceService.getList(fse));
        } catch (BaseException e) {
            SpringMVCContextHolder.getSystemLogger().error(e);
            e.printStackTrace();
            return error(e.getCode(), e.getMessageInfo());
        }catch (Exception e){
            SpringMVCContextHolder.getSystemLogger().error(e);
            e.printStackTrace();
            return error(SystemCode.SYSTEM_SELECT_CLIENT_LIST_FIAL.getValue(),SystemCode.SYSTEM_SELECT_CLIENT_LIST_FIAL.getText()+e.getMessage());
        }
    }
}