Browse Source

b2b对接增加企业配置

chenw 7 years ago
parent
commit
b91191f90a

+ 31 - 0
applications/transfers/mall-api/src/main/java/com/usoftchina/saas/inquiry/api/EnConfigApi.java

@@ -0,0 +1,31 @@
+package com.usoftchina.saas.inquiry.api;
+
+import com.usoftchina.saas.inquiry.po.enConfig.AddOrUpdateEnterpriseRequest;
+import com.usoftchina.saas.inquiry.po.enConfig.ResponseHeader;
+import com.usoftchina.saas.inquiry.po.enConfig.RestAddOrUpdateEnterpriseResponse;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.*;
+
+@FeignClient(url = "${b2b.baseUrl.post}", name = "post-server")
+@RequestMapping("/api/saas/enterprise")
+public interface EnConfigApi {
+
+    /**
+     * 添加或修改企业
+     * @param addOrUpdateEnterpriseRequest
+     * @return
+     */
+    @PostMapping("/addOrUpdate")
+    String/*RestAddOrUpdateEnterpriseResponse*/ addOrUpdateEnterprise(@RequestBody AddOrUpdateEnterpriseRequest addOrUpdateEnterpriseRequest);
+
+    /**
+     * 查询企业列表
+     * @param count         每页条数
+     * @param page          当前页码
+     * @param keyword       搜索关键词,非必填
+     * @return  RestGetEnterpriseListResponse.class
+     */
+    @GetMapping("/get/pageList")
+    String/*RestGetEnterpriseListResponse*/ getEnterpriseList(@RequestParam("count") int count, @RequestParam("page") int page, @RequestParam("keyword") String keyword);
+
+}

+ 70 - 0
applications/transfers/mall-api/src/main/java/com/usoftchina/saas/inquiry/po/enConfig/AddOrUpdateEnterpriseRequest.java

@@ -0,0 +1,70 @@
+package com.usoftchina.saas.inquiry.po.enConfig;
+
+/**
+ * @Description 添加或修改企业请求对象
+ * @Author chenwei
+ * @Date 2019/01/24
+ */
+public class AddOrUpdateEnterpriseRequest {
+
+    /**
+     * 编号,编号不可以修改,编号已存在则做更新,编号不存在则插入
+     */
+    private Long enuu;
+    /**
+     * 名称
+     */
+    private String name;
+    /**
+     * 是否开启saas
+     */
+    private boolean saas;
+    /**
+     * 是否开启saas传输
+     */
+    private boolean saasPost;
+    /**
+     * 企业秘钥
+     */
+    private String accessSecret;
+
+    public Long getEnuu() {
+        return enuu;
+    }
+
+    public void setEnuu(Long enuu) {
+        this.enuu = enuu;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public boolean isSaas() {
+        return saas;
+    }
+
+    public void setSaas(boolean saas) {
+        this.saas = saas;
+    }
+
+    public boolean isSaasPost() {
+        return saasPost;
+    }
+
+    public void setSaasPost(boolean saasPost) {
+        this.saasPost = saasPost;
+    }
+
+    public String getAccessSecret() {
+        return accessSecret;
+    }
+
+    public void setAccessSecret(String accessSecret) {
+        this.accessSecret = accessSecret;
+    }
+}

+ 46 - 0
applications/transfers/mall-api/src/main/java/com/usoftchina/saas/inquiry/po/enConfig/PagingInfo.java

@@ -0,0 +1,46 @@
+package com.usoftchina.saas.inquiry.po.enConfig;
+
+/**
+ * @Description 分页对象
+ * @Author chenwei
+ * @Date 2019/01/24
+ */
+public class PagingInfo {
+
+    private Long totalPage; // 总页数
+    private Long totalCount; // 总条数
+    private Long pageSize; // 每页条数
+    private Long pageNumber; // 当前页码
+
+    public Long getTotalPage() {
+        return totalPage;
+    }
+
+    public void setTotalPage(Long totalPage) {
+        this.totalPage = totalPage;
+    }
+
+    public Long getTotalCount() {
+        return totalCount;
+    }
+
+    public void setTotalCount(Long totalCount) {
+        this.totalCount = totalCount;
+    }
+
+    public Long getPageSize() {
+        return pageSize;
+    }
+
+    public void setPageSize(Long pageSize) {
+        this.pageSize = pageSize;
+    }
+
+    public Long getPageNumber() {
+        return pageNumber;
+    }
+
+    public void setPageNumber(Long pageNumber) {
+        this.pageNumber = pageNumber;
+    }
+}

+ 28 - 0
applications/transfers/mall-api/src/main/java/com/usoftchina/saas/inquiry/po/enConfig/ResponseHeader.java

@@ -0,0 +1,28 @@
+package com.usoftchina.saas.inquiry.po.enConfig;
+
+/**
+ * 响应信息
+ * @Author chenwei
+ * @Date 2019/01/24
+ */
+public class ResponseHeader {
+
+    private int code;   // 状态码 0.正常 非0.异常
+    private String msg; // 错误信息 code!=0时,有值
+
+    public int getCode() {
+        return code;
+    }
+
+    public void setCode(int code) {
+        this.code = code;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
+}

+ 18 - 0
applications/transfers/mall-api/src/main/java/com/usoftchina/saas/inquiry/po/enConfig/RestAddOrUpdateEnterpriseResponse.java

@@ -0,0 +1,18 @@
+package com.usoftchina.saas.inquiry.po.enConfig;
+
+/**
+ * @Author chenwei
+ * @Date 2019/01/24
+ */
+public class RestAddOrUpdateEnterpriseResponse {
+
+    private ResponseHeader responseHeader;
+
+    public ResponseHeader getResponseHeader() {
+        return responseHeader;
+    }
+
+    public void setResponseHeader(ResponseHeader responseHeader) {
+        this.responseHeader = responseHeader;
+    }
+}

+ 41 - 0
applications/transfers/mall-api/src/main/java/com/usoftchina/saas/inquiry/po/enConfig/RestGetEnterpriseListResponse.java

@@ -0,0 +1,41 @@
+package com.usoftchina.saas.inquiry.po.enConfig;
+
+import java.util.List;
+
+/**
+ * @Description 查询企业列表
+ * @Author chenwei
+ * @Date 2019/01/24
+ */
+public class RestGetEnterpriseListResponse {
+
+    private ResponseHeader responseHeader;
+
+    private PagingInfo pagingInfo;
+
+    private List<SaasEnterprise> content;
+
+    public ResponseHeader getResponseHeader() {
+        return responseHeader;
+    }
+
+    public void setResponseHeader(ResponseHeader responseHeader) {
+        this.responseHeader = responseHeader;
+    }
+
+    public PagingInfo getPagingInfo() {
+        return pagingInfo;
+    }
+
+    public void setPagingInfo(PagingInfo pagingInfo) {
+        this.pagingInfo = pagingInfo;
+    }
+
+    public List<SaasEnterprise> getContent() {
+        return content;
+    }
+
+    public void setContent(List<SaasEnterprise> content) {
+        this.content = content;
+    }
+}

+ 55 - 0
applications/transfers/mall-api/src/main/java/com/usoftchina/saas/inquiry/po/enConfig/SaasEnterprise.java

@@ -0,0 +1,55 @@
+package com.usoftchina.saas.inquiry.po.enConfig;
+
+/**
+ * @Description saas企业信息
+ * @Author chenwei
+ * @Date 2019/01/24
+ */
+public class SaasEnterprise {
+
+    private Long enuu;                  // uu号
+    private String enname;              // 企业名称
+    private boolean saas;               // 是否启用saas
+    private boolean saasPost;           // 是否启用saas数据传输
+    private String accessSecret;        // 企业秘钥
+
+    public Long getEnuu() {
+        return enuu;
+    }
+
+    public void setEnuu(Long enuu) {
+        this.enuu = enuu;
+    }
+
+    public String getEnname() {
+        return enname;
+    }
+
+    public void setEnname(String enname) {
+        this.enname = enname;
+    }
+
+    public boolean isSaas() {
+        return saas;
+    }
+
+    public void setSaas(boolean saas) {
+        this.saas = saas;
+    }
+
+    public boolean isSaasPost() {
+        return saasPost;
+    }
+
+    public void setSaasPost(boolean saasPost) {
+        this.saasPost = saasPost;
+    }
+
+    public String getAccessSecret() {
+        return accessSecret;
+    }
+
+    public void setAccessSecret(String accessSecret) {
+        this.accessSecret = accessSecret;
+    }
+}

+ 48 - 0
applications/transfers/mall-api/src/test/java/com/usoftchina/saas/inquiry/test/EnConfigTest.java

@@ -0,0 +1,48 @@
+package com.usoftchina.saas.inquiry.test;
+
+import com.usoftchina.saas.inquiry.api.EnConfigApi;
+import com.usoftchina.saas.inquiry.po.enConfig.AddOrUpdateEnterpriseRequest;
+import com.usoftchina.saas.inquiry.po.enConfig.RestGetEnterpriseListResponse;
+import com.usoftchina.saas.inquiry.po.enConfig.ResponseHeader;
+import com.usoftchina.saas.utils.JsonUtils;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.MethodSorters;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+/**
+ * @Description 企业设置接口测试
+ * @Author chenwei
+ * @Date 2019/01/24
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class EnConfigTest {
+
+    @Autowired
+    private EnConfigApi enConfigApi;
+
+    @Test
+    public void testA_addOrUpdateEnterprise(){
+        AddOrUpdateEnterpriseRequest addOrUpdateEnterpriseRequest = new AddOrUpdateEnterpriseRequest();
+        addOrUpdateEnterpriseRequest.setEnuu(10050748L);
+        addOrUpdateEnterpriseRequest.setName("李剑辉8");
+        addOrUpdateEnterpriseRequest.setSaas(true);
+        addOrUpdateEnterpriseRequest.setSaasPost(true);
+        addOrUpdateEnterpriseRequest.setAccessSecret("b0c0320f457149a0bac7d115a55d9f9f");
+        String responseHeader = enConfigApi.addOrUpdateEnterprise(addOrUpdateEnterpriseRequest);
+        System.out.println(JsonUtils.fromJsonString(responseHeader, ResponseHeader.class));
+    }
+
+    @Test
+    public void testB_getEnterpriseList(){
+        String/*RestGetEnterpriseListResponse*/ response = enConfigApi.getEnterpriseList(10, 1, null);
+        RestGetEnterpriseListResponse getEnterpriseListResponse = JsonUtils.fromJsonString(response, RestGetEnterpriseListResponse.class);
+        System.out.println(JsonUtils.toJsonString(getEnterpriseListResponse));
+    }
+
+}

+ 11 - 1
applications/transfers/mall-api/src/test/resources/application.yml

@@ -1,6 +1,16 @@
+# 测试环境
 b2b:
   baseUrl:
     inquiry: https://test-inquiry.uuzcc.cn
     Component: https://test-mall.uuzcc.cn
     product: http://test-product.uuzcc.cn
-    common: http://test-b2b.uuzcc.cn
+    common: http://test-b2b.uuzcc.cn
+    post: https://test-b2b-post.uuzcc.cn
+# 正式环境
+#b2b:
+#  baseUrl:
+#    inquiry: https://api-inquiry.usoftchina.com
+#    Component: https://mall.usoftchina.com
+#    product: http://api-product.usoftchina.com
+#    common: https://b2b-api.usoftchina.com
+#    post: https://b2b-post.usoftchina.com