瀏覽代碼

add 保存接出api

GITZYY 8 月之前
父節點
當前提交
bf16d1f3d7

+ 78 - 0
egress-gateway-service-app/src/main/java/com/hrsk/cloud/eg/app/api/EgApiOperateServiceImpl.java

@@ -0,0 +1,78 @@
+package com.hrsk.cloud.eg.app.api;
+
+import com.hrsk.cloud.eg.app.business.EgOperateBusinessService;
+import com.hrsk.cloud.eg.app.request.api.EgApiEndpointReq;
+import com.hrsk.cloud.eg.app.request.api.EgApiLoanExtendReq;
+import com.hrsk.cloud.eg.app.request.api.EgApiProductExtendReq;
+import com.hrsk.cloud.eg.app.request.api.EgApiReq;
+import com.hrsk.cloud.eg.vo.response.DefaultResponseVo;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+/**
+ * @author zhangyy
+ * @version 1.0
+ * @description: EgApiOperateServiceImpl
+ * @date 2024/9/23 11:25
+ */
+@RequestMapping
+@RestController("eg")
+public class EgApiOperateServiceImpl {
+
+    @Resource
+    private EgOperateBusinessService egOperateBusinessService;
+
+
+    /**
+     * @description: 创建助贷api扩展
+     * @author zhangyy
+     * @date 2024/9/23 13:40
+     * @version 1.0
+     */
+    @RequestMapping("saveLoanApiExtend")
+    public DefaultResponseVo saveLoanApiExtend(@RequestBody EgApiLoanExtendReq req) {
+        egOperateBusinessService.saveLoanApiExtend(req);
+        return DefaultResponseVo.success();
+    }
+
+    /**
+     * @description: 创建助贷api扩展
+     * @author zhangyy
+     * @date 2024/9/23 13:40
+     * @version 1.0
+     */
+    @RequestMapping("saveInterbankApiExtend")
+    public DefaultResponseVo saveInterbankApiExtend(@RequestBody EgApiProductExtendReq req) {
+        egOperateBusinessService.saveInterbankApiExtend(req);
+        return DefaultResponseVo.success();
+    }
+
+    /**
+     * @description: 保存信息api配置信息
+     * @author zhangyy
+     * @date 2024/9/23 13:46
+     * @version 1.0
+     */
+    @RequestMapping("saveApiConfig")
+    public DefaultResponseVo saveApiConfig(@RequestBody EgApiEndpointReq req){
+
+        Long id = egOperateBusinessService.saveApiConfig(req);
+        return DefaultResponseVo.success(id);
+    }
+
+    /**
+     * @description: 保存信息api
+     * @author zhangyy
+     * @date 2024/9/23 13:46
+     * @version 1.0
+     */
+    @RequestMapping("saveApiInfo")
+    public DefaultResponseVo saveApiInfo(@RequestBody EgApiReq req){
+        Long id = egOperateBusinessService.saveApiInfo(req);
+        return DefaultResponseVo.success(id);
+    }
+
+}

+ 105 - 0
egress-gateway-service-app/src/main/java/com/hrsk/cloud/eg/app/business/EgOperateBusinessService.java

@@ -0,0 +1,105 @@
+package com.hrsk.cloud.eg.app.business;
+
+import com.alibaba.cola.exception.BizException;
+import com.hrsk.cloud.eg.app.request.api.EgApiEndpointReq;
+import com.hrsk.cloud.eg.app.request.api.EgApiLoanExtendReq;
+import com.hrsk.cloud.eg.app.request.api.EgApiProductExtendReq;
+import com.hrsk.cloud.eg.app.request.api.EgApiReq;
+import com.hrsk.cloud.eg.infrastructure.repository.database.entity.EgApiDo;
+import com.hrsk.cloud.eg.infrastructure.repository.database.entity.EgApiEndpointDo;
+import com.hrsk.cloud.eg.infrastructure.repository.database.entity.EgApiLoanExtendDo;
+import com.hrsk.cloud.eg.infrastructure.repository.database.entity.EgApiProductExtendDo;
+import com.hrsk.cloud.eg.infrastructure.service.EgApiEndpointService;
+import com.hrsk.cloud.eg.infrastructure.service.EgApiLoanExtendService;
+import com.hrsk.cloud.eg.infrastructure.service.EgApiProductExtendService;
+import com.hrsk.cloud.eg.infrastructure.service.EgApiService;
+import com.hrsk.cloud.eg.infrastructure.utils.BeanCopyUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.util.Objects;
+
+/**
+ * @author zhangyy
+ * @version 1.0
+ * @description: EgOperateBusinessService eg接出操作类
+ * @date 2024/9/23 13:49
+ */
+@Service
+public class EgOperateBusinessService {
+    @Resource
+    private EgApiService egApiService;
+
+    @Resource
+    private EgApiEndpointService egApiEndpointService;
+    @Resource
+    private EgApiProductExtendService egApiProductExtendService;
+
+    @Resource
+    private EgApiLoanExtendService egApiLoanExtendService;
+
+    /**
+     * @description:  保存接出api
+     * @author zhangyy
+     * @date 2024/9/23 14:08
+     * @version 1.0
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public Long saveApiInfo(EgApiReq req) {
+        EgApiDo copy = BeanCopyUtils.copy(req, EgApiDo.class);
+        egApiService.save(copy);
+        return copy.getId();
+
+    }
+
+    /**
+     * @description:  保存api的配置
+     * @author zhangyy
+     * @date 2024/9/23 14:18
+     * @version 1.0
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public Long saveApiConfig(EgApiEndpointReq req) {
+        EgApiEndpointDo copy = BeanCopyUtils.copy(req, EgApiEndpointDo.class);
+        EgApiDo apiDo = egApiService.getById(req.getApiId());
+        if (Objects.isNull(apiDo)) {
+           throw new BizException("主api信息为空");
+        }
+        copy.setApiName(apiDo.getApiName());
+        copy.setApiCode(apiDo.getApiCode());
+        egApiEndpointService.save(copy);
+        return copy.getId();
+    }
+
+    /** 
+     * @description: 保存api扩展信息
+     * @param:  
+     * @return:  
+     * @author zhangyy
+     * @date: 2024/9/23 14:26
+     */ 
+    @Transactional(rollbackFor = Exception.class)
+    public void saveLoanApiExtend(EgApiLoanExtendReq req) {
+        if (Objects.isNull(req)){
+            throw new BizException("信息不能为空");
+        }
+        EgApiLoanExtendDo copy = BeanCopyUtils.copy(req, EgApiLoanExtendDo.class);
+        egApiLoanExtendService.save(copy);
+    }
+    /**
+     * @description: 保存api扩展信息
+     * @param:
+     * @return:
+     * @author zhangyy
+     * @date: 2024/9/23 14:26
+     */
+    public void saveInterbankApiExtend(EgApiProductExtendReq req) {
+        if (Objects.isNull(req)){
+            throw new BizException("信息不能为空");
+        }
+        EgApiProductExtendDo copy = BeanCopyUtils.copy(req, EgApiProductExtendDo.class);
+        egApiProductExtendService.save(copy);
+    }
+
+}

+ 45 - 0
egress-gateway-service-app/src/main/java/com/hrsk/cloud/eg/app/constant/EgApiTypeEnum.java

@@ -0,0 +1,45 @@
+package com.hrsk.cloud.eg.app.constant;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author zhangyy
+ * @version 1.0
+ * @description: EgApiTypeEnum
+ * @date 2024/9/23 13:58
+ */
+@Getter
+@AllArgsConstructor
+public enum EgApiTypeEnum {
+    LOAN_API("LOAN_API","助贷api"),
+    INTERBANK_API("INTERBANK_API","同业api"),
+    FAST_LOAN("FAST_LOAN","极速贷api")
+
+    ;
+    static Map<String, EgApiTypeEnum> map = new HashMap();
+
+    static {
+        for (EgApiTypeEnum value : EgApiTypeEnum.values()) {
+            map.put(value.code, value);
+        }
+    }
+
+    public static EgApiTypeEnum getByCode(String code) {
+        return map.get(code);
+    }
+    private String code;
+
+    private String msg;
+
+    public String getCode() {
+        return code;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+}

+ 53 - 0
egress-gateway-service-app/src/main/java/com/hrsk/cloud/eg/app/request/api/EgApiEndpointReq.java

@@ -0,0 +1,53 @@
+package com.hrsk.cloud.eg.app.request.api;
+
+import com.hrsk.cloud.eg.infrastructure.repository.database.entity.BaseDo;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * @author: bianlanzhou
+ * @create: 2024-08-01 18:34
+ * @description: API通道数据对象
+ **/
+@Data
+public class EgApiEndpointReq extends BaseDo implements Serializable {
+    /**
+     * 数据API主键
+     */
+    @NotNull(message = "apiId不能为空")
+    private Long apiId;
+    /**
+     * 通道类型
+     */
+    private String apiCode;
+
+    /**
+     * api名称
+     */
+    private String apiName;
+    /**
+     * 通道配置
+     */
+    @NotBlank(message = "通道配置信息不能为空")
+    private byte[] apiConfig;
+
+    /**
+     * 请求配置
+     */
+    @NotBlank(message = "请求配置信息不能为空")
+    private String requestConfig;
+
+    /**
+     * 响应配置
+     */
+    @NotBlank(message = "响应配置信息不能为空")
+    private String responseConfig;
+
+    /**
+     * 备注
+     */
+    private String memo;
+}

+ 43 - 0
egress-gateway-service-app/src/main/java/com/hrsk/cloud/eg/app/request/api/EgApiLoanExtendReq.java

@@ -0,0 +1,43 @@
+package com.hrsk.cloud.eg.app.request.api;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 接出助贷api的详细描述
+ * 
+ * @author zhangyy
+ * @email @gmail.com
+ * @date 2024-09-23 11:07:01
+ */
+@Data
+public class EgApiLoanExtendReq  implements Serializable {
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * eg_api主键
+	 */
+	private Long apiId;
+	/**
+	 * 共享范围
+	 */
+	private String shareRange;
+	/**
+	 * 协议范围
+	 */
+	private String protocol;
+	/**
+	 * 共享目的
+	 */
+	private String sharePurpose;
+	/**
+	 * 是否需要撞库0:不需要;1:需要
+	 */
+	private Integer needCheck;
+	/**
+	 * 共享方式
+	 */
+	private String shareType;
+
+}

+ 46 - 0
egress-gateway-service-app/src/main/java/com/hrsk/cloud/eg/app/request/api/EgApiProductExtendReq.java

@@ -0,0 +1,46 @@
+package com.hrsk.cloud.eg.app.request.api;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * 接出产品api扩展表
+ * 
+ * @author zhangyy
+ * @email
+ * @date 2024-09-23 11:07:01
+ */
+@Data
+public class EgApiProductExtendReq  implements Serializable {
+	private static final long serialVersionUID = 1L;
+
+
+	/**
+	 * eg_api主键
+	 */
+	@NotNull(message = "apiId信息不能为空")
+	private Long apiId;
+	/**
+	 * 共享范围
+	 */
+	private String shareRange;
+	/**
+	 * 协议范围
+	 */
+	private String protocol;
+	/**
+	 * 共享目的
+	 */
+	private String sharePurpose;
+	/**
+	 * 共享方式
+	 */
+	private String shareType;
+	/**
+	 * 是否需要撞库0:不需要;1:需要
+	 */
+	private Integer needCheck;
+
+}

+ 33 - 0
egress-gateway-service-app/src/main/java/com/hrsk/cloud/eg/app/request/api/EgApiReq.java

@@ -0,0 +1,33 @@
+package com.hrsk.cloud.eg.app.request.api;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import java.io.Serializable;
+
+/**
+ * @author: bianlanzhou
+ * @create: 2024-08-02 08:14
+ * @description: 接出网关API表
+ **/
+@Data
+public class EgApiReq implements Serializable  {
+    /**
+     * API名称
+     */
+    @NotBlank(message = "API名称不能为空")
+    private String apiName;
+
+    /**
+     * API类型
+     */
+    @NotBlank(message = "API类型不能为空")
+    private String apiType;
+
+    /**
+     * APICode
+     */
+    @NotBlank(message = "API编码不能为空")
+    private String apiCode;
+
+}