瀏覽代碼

开通企业时增加accessKey

chenw 6 年之前
父節點
當前提交
e15c6387bd

+ 9 - 0
base-servers/account/account-dto/src/main/java/com/usoftchina/saas/account/dto/CompanyRegDTO.java

@@ -26,6 +26,15 @@ public class CompanyRegDTO implements Serializable{
     private String signet;      //电子章
     private String type;        //所属行业
     private String dcName;      //数据中心
+    private String accessKey;   //accessKey 企业秘钥,用于B2B数据对接
+
+    public String getAccessKey() {
+        return accessKey;
+    }
+
+    public void setAccessKey(String accessKey) {
+        this.accessKey = accessKey;
+    }
 
     public String getDcName() {
         return dcName;

+ 3 - 2
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/mapper/CompanyMapper.java

@@ -85,11 +85,12 @@ public interface CompanyMapper {
     int updateByPrimaryKeySelective(CompanyRegDTO companyRegDTO);
 
     /**
-     * 更新UU号
+     * 更新UU号,企业秘钥
      * @param companyId
      * @param uu
+     * @param accessKey
      */
-    void updateUUByPrimaryKey(@Param("companyId") Long companyId, @Param("uu") Long uu);
+    void updateB2BMsgByPrimaryKey(@Param("companyId") Long companyId, @Param("uu") Long uu, @Param("accessKey") String accessKey);
 
     /**
      * 按名称(模糊)查找企业,返回企业名称、管理员名称、管理员手机号

+ 2 - 2
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/service/CompanyService.java

@@ -101,11 +101,11 @@ public interface CompanyService {
     void update(CompanyRegDTO companyRegDTO);
 
     /**
-     * 更新公司UU号
+     * 更新公司UU号,企业秘钥
      * @param companyId
      * @param uu
      */
-    void updateUUByPrimaryKey(Long companyId, Long uu);
+    void updateB2BMsgByPrimaryKey(Long companyId, Long uu, String accessKey);
 
     /**
      * 按名称(模糊)查找企业,返回企业名称、管理员名称、管理员手机号

+ 7 - 2
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/service/impl/AccountCenterServiceImpl.java

@@ -18,6 +18,7 @@ import com.usoftchina.saas.utils.BeanMapper;
 import com.usoftchina.saas.utils.StringUtils;
 import com.usoftchina.sso.api.SsoUserApi;
 import com.usoftchina.sso.api.SsoUserSpaceApi;
+import com.usoftchina.sso.dto.SsoResult;
 import com.usoftchina.sso.dto.SsoUserSpace;
 import com.usoftchina.sso.dto.SsoUserSpaceList;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -78,7 +79,11 @@ public class AccountCenterServiceImpl implements AccountCenterService {
         companyService.bindApp(company.getId(), "trade-app");
         //b. 同步企业信息到优软云 ——>  创建企业
         if ("0".equals(type)) {
-            String result = ssoUserSpaceApi.registerLogin(company.getName(), company.getBusinessCode(), Long.parseLong(accountRegDTO.getUu()));
+            SsoResult<SsoUserSpace> result = ssoUserSpaceApi.registerLogin(company.getName(), company.getBusinessCode(), Long.parseLong(accountRegDTO.getUu()));
+            if (result.isSuccess()){
+                SsoUserSpace ssoUserSpace = result.getContent();
+                companyService.updateB2BMsgByPrimaryKey(company.getId(), ssoUserSpace.getSpaceUU(), ssoUserSpace.getAccessSecret());
+            }
         }
         //c.插入 账户公司 映射
         accountCompanyMapper.insert(accountId, company.getId());
@@ -145,7 +150,7 @@ public class AccountCenterServiceImpl implements AccountCenterService {
                 if (companyRspDTO.getName().equals(ssoUserSpaces.get(i).getSpaceName())){
                     //更新公司UU号
                     if (StringUtils.isEmpty(companyRspDTO.getUu())){
-                        companyService.updateUUByPrimaryKey(companyRspDTO.getId(), ssoUserSpaces.get(i).getSpaceUU());
+                        companyService.updateB2BMsgByPrimaryKey(companyRspDTO.getId(), ssoUserSpaces.get(i).getSpaceUU(), ssoUserSpaces.get(i).getAccessSecret());
                     }
                     ssoUserSpaces.remove(ssoUserSpaces.get(i));
                 }

+ 1 - 1
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/service/impl/AccountServiceImpl.java

@@ -312,7 +312,7 @@ public class AccountServiceImpl implements AccountService {
                 for (SsoUserSpace ssoUserspace : ssoUserSpaces) {
                     if (companyName.equals(ssoUserspace.getSpaceName())) {
                         company.setUu(ssoUserspace.getSpaceUU());
-                        companyService.updateUUByPrimaryKey(company.getId(), ssoUserspace.getSpaceUU());
+                        companyService.updateB2BMsgByPrimaryKey(company.getId(), ssoUserspace.getSpaceUU(), ssoUserspace.getAccessSecret());
                     }
                 }
             }

+ 2 - 2
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/service/impl/CompanyServiceImpl.java

@@ -56,8 +56,8 @@ public class CompanyServiceImpl implements CompanyService{
     }
 
     @Override
-    public void updateUUByPrimaryKey(Long companyId, Long uu) {
-        companyMapper.updateUUByPrimaryKey(companyId, uu);
+    public void updateB2BMsgByPrimaryKey(Long companyId, Long uu, String accessKey) {
+        companyMapper.updateB2BMsgByPrimaryKey(companyId, uu, accessKey);
     }
 
     @Override

+ 3 - 3
base-servers/account/account-server/src/main/resources/mapper/CompanyMapper.xml

@@ -173,7 +173,7 @@
                 signet = #{signet,jdbcType=VARCHAR},
             </if>
             <if test="type != null">
-                type = #{type,jdbcType=VARCHAR}
+                type = #{type,jdbcType=VARCHAR},
             </if>
             <if test="dcName != null">
                 dc_name = #{dcName,jdbcType=VARCHAR}
@@ -181,7 +181,7 @@
         </set>
         where id = #{id}
     </update>
-    <update id="updateUUByPrimaryKey">
-        UPDATE ac_company set uu = #{uu} where id = #{companyId}
+    <update id="updateB2BMsgByPrimaryKey">
+        UPDATE ac_company set uu = #{uu}, access_key = #{accessKey} where id = #{companyId}
     </update>
 </mapper>

+ 3 - 2
base-servers/auth/sso-api/src/main/java/com/usoftchina/sso/api/SsoUserSpaceApi.java

@@ -1,6 +1,7 @@
 package com.usoftchina.sso.api;
 
 import com.usoftchina.sso.dto.SsoResult;
+import com.usoftchina.sso.dto.SsoUserSpace;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.stereotype.Component;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -30,7 +31,7 @@ public interface SsoUserSpaceApi {
      * @return
      */
     @PostMapping("/sso/userspace/register/admin")
-    String registerLogin(@RequestParam("spaceName") String spaceName, @RequestParam("businessCode") String businessCode, @RequestParam("userUU") Long userUU);
+    SsoResult<SsoUserSpace> registerLogin(@RequestParam("spaceName") String spaceName, @RequestParam("businessCode") String businessCode, @RequestParam("userUU") Long userUU);
 
     @Component
     class DefaultFallback implements SsoUserSpaceApi{
@@ -41,7 +42,7 @@ public interface SsoUserSpaceApi {
         }
 
         @Override
-        public String registerLogin(String spaceName, String businessCode, Long userUU) {
+        public SsoResult<SsoUserSpace> registerLogin(String spaceName, String businessCode, Long userUU) {
             return null;
         }
     }

+ 5 - 3
base-servers/auth/sso-api/src/test/java/com/usoftchina/sso/test/SsoUserSpaceApiTeest.java

@@ -1,8 +1,10 @@
 package com.usoftchina.sso.test;
 
+import com.usoftchina.saas.utils.JsonUtils;
 import com.usoftchina.saas.utils.StringUtils;
 import com.usoftchina.sso.api.SsoUserSpaceApi;
 import com.usoftchina.sso.dto.SsoResult;
+import com.usoftchina.sso.dto.SsoUserSpace;
 import org.junit.FixMethodOrder;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -31,10 +33,10 @@ public class SsoUserSpaceApiTeest {
 
     @Test
     public void testB_registerLogin(){
-        String spaceName = "测试企业009";
+        String spaceName = "测试i企业注册11";
         String businessCode = StringUtils.createBusinessCode();
         Long userUU = 1000027276l;
-        String result = ssoUserSpaceApi.registerLogin(spaceName, businessCode, userUU);
-        System.out.println(result);
+        SsoResult<SsoUserSpace> result = ssoUserSpaceApi.registerLogin(spaceName, businessCode, userUU);
+        System.out.println(JsonUtils.toJsonString(result.getContent()));
     }
 }