Ver código fonte

更换验证码签名,绑定企业优化错误输出,一些代码层面优化

ximinghao 2 semanas atrás
pai
commit
e392b1ea40

+ 1 - 1
src/main/java/com/skyversation/xjcy/bean/Lcxm.java

@@ -20,7 +20,7 @@ public class Lcxm {
     * 服务大类枚举
     */
    @Getter
-   public static enum ServiceCategory {
+   public enum ServiceCategory {
 
       BUSINESS_STARTUP(1, "开办一件事"),
       OVERSEAS_SERVICE(2, "出海服务(联合国采购)"),

+ 30 - 26
src/main/java/com/skyversation/xjcy/controller/OtherController.java

@@ -57,36 +57,40 @@ public class OtherController {
 
     @RequestMapping(value = "/bindEnterprise")
     public String bindEnterprise(@RequestParam(required = false) String enterprise, @RequestParam(required = false) String token) {
-        if (enterprise != null && enterprise.isEmpty()) enterprise = null;
-        if (!authService.checkToken(token)) {
-            return MessageManage.error(-1, "请提供有效token");
-        }
-        JSONObject userContent = authService.getUserContentByToken(token);
-        String usercode = userContent.getString(RESPONSE_FIELD_USERNAME);
+        try {
+            if (enterprise != null && enterprise.isEmpty()) enterprise = null;
+            if (!authService.checkToken(token)) {
+                return MessageManage.error(-1, "请提供有效token");
+            }
+            JSONObject userContent = authService.getUserContentByToken(token);
+            String usercode = userContent.getString(RESPONSE_FIELD_USERNAME);
 
-        //更新dms记录
-        List<JSONObject> userJsons = dMSService.getUserJSONByCode(usercode, authService.getTokenOfServiceAccount());
-        if (!userJsons.isEmpty()) {
-            JSONObject userJSON = userJsons.get(0);
-            User user = JSONObject.toJavaObject(userJSON, User.class);
-            if (userJSON != null) {
-                user.setCGlGs(enterprise);
-                if ("4".equals(user.getCType())&&enterprise!=null) {
-                    user.setCType("3");
-                }
+            //更新dms记录
+            List<JSONObject> userJsons = dMSService.getUserJSONByCode(usercode, authService.getTokenOfServiceAccount());
+            if (!userJsons.isEmpty()) {
+                JSONObject userJSON = userJsons.get(0);
+                User user = JSONObject.toJavaObject(userJSON, User.class);
+                if (userJSON != null) {
+                    user.setCGlGs(enterprise);
+                    if ("4".equals(user.getCType())&&enterprise!=null) {
+                        user.setCType("3");
+                    }
 
-                if ("3".equals(user.getCType())&&enterprise==null) {
-                    user.setCType("4");
+                    if ("3".equals(user.getCType())&&enterprise==null) {
+                        user.setCType("4");
+                    }
+                    dMSService.updateToDms(Collections.singletonList(userJSON), authService.getTokenOfServiceAccount(), DMSColumn.USER);
                 }
-                dMSService.updateToDms(Collections.singletonList(userJSON), authService.getTokenOfServiceAccount(), DMSColumn.USER);
             }
-        }
-        if (enterprise == null) {
-            authService.deUpgradeRoleEnterprise(userContent);
-            return MessageManage.successWithNoData("成功解除此用户的相关绑定");
-        } else {
-            authService.upgradeRoleEnterprise(userContent);
-            return MessageManage.successWithNoData("成功绑定到对应企业");
+            if (enterprise == null) {
+                authService.deUpgradeRoleEnterprise(userContent);
+                return MessageManage.successWithNoData("成功解除此用户的相关绑定");
+            } else {
+                authService.upgradeRoleEnterprise(userContent);
+                return MessageManage.successWithNoData("成功绑定到对应企业");
+            }
+        } catch (RuntimeException e) {
+            return MessageManage.error(-1,e.getMessage());
         }
     }
 

+ 1 - 1
src/main/resources/application.yml

@@ -40,7 +40,7 @@ app:
     message:
       endpoint: ${ALIBABA_CLOUD_MESSAGE_ENDPOINT:dysmsapi.aliyuncs.com}
       code:
-        sign: ${XJCY_ALIBABA_SIGN:数智科技}
+        sign: ${XJCY_ALIBABA_SIGN:上海元以数智科技}
         template-code: ${XJCY_ALIBABA_CODE_TEMPLATE:SMS_496690245}
       notice:
         sign: ${XJCY_ALIBABA_SIGN:数智科技}