YYC
2023-10-21 d48d966dfde7a0c31bd81466559e5e8d681dc200
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
package com.ld.igds.sh;
 
import com.ld.igds.sh.dto.ApiResponse;
import com.ld.igds.sh.param.ApiRequest;
import com.ld.igds.sh.util.RespCodeEnum;
import com.ld.igds.sh.util.RespUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
/**
 * 接口服务入口
 *
 * @author chen
 */
@Slf4j
@Controller
@RequestMapping("api/sh/v1")
public class ApiShServer {
 
    @Autowired
    private ApiShManager apiShManager;
 
    /**
     * 接口业务分发入口
     * @param request
     * @return
     */
    @SuppressWarnings("unchecked")
    @ResponseBody
    @RequestMapping("/gateway")
    public ApiResponse<Object> gateway(@RequestBody ApiRequest<Object> request) {
 
        ApiResponse<Object> result = RespUtil.error(RespCodeEnum.CODE_9999.getCode(), request.getOrderId());
 
        //判断请求参数
        if(request == null){
            log.warn("-----上海佑卓接口,请求参数为空-----");
            return result;
        }
 
        //判断接口编码是否为空,为空则直接返回
        if(StringUtils.isEmpty(request.getInterfaceId())){
            log.warn("-----上海佑卓接口,请求参数异常:接口编码或库区编码为空={}-----", request.toString());
            return result;
        }
        log.info("-----上海佑卓接口,请求参数={}-----", request.toString());
 
        try{
            result = apiShManager.execute(request);
 
        }catch (Exception e){
 
            log.error("-----上海佑卓接口,后端服务异常,原因={}-----", e);
            result = RespUtil.error(RespCodeEnum.CODE_9999.getCode(), e.getMessage());
        }
        return result;
    }
}