Ver Fonte

补充初始化

ximinghao há 3 meses atrás
pai
commit
abfe571428

+ 26 - 2
src/main/java/com/skyversation/xjcy/service/AuthService.java

@@ -19,6 +19,10 @@ import org.springframework.util.StringUtils;
 import javax.annotation.PostConstruct;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.*;
 
 /**
@@ -71,6 +75,10 @@ public class AuthService {
      * 按TOKEN获取用户详情接口
      */
     private static final String USER_CONTENT_BY_TOKEN = "/user/getUserByToken";
+    /**
+     * 更新用户信息
+     */
+    private static final String UPDATE_USER_MESS_AGE="/user/UpdateUserMessAge";
 
     /**
      * 微信账号用户名前缀
@@ -121,8 +129,13 @@ public class AuthService {
      * 相应字段:用户角色Id
      */
     private static final String RESPONSE_FIELD_ROLE_ID = "roleId";
-    private final DMSService dMSService;
 
+    /**
+     * yyyy-MM-dd HH:mm:ss
+     */
+    private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+    private final DMSService dMSService;
 
     // ============================ 内部类定义 ============================
 
@@ -407,6 +420,16 @@ public class AuthService {
         String response = HttpUtil.requestPost(oauthPath + USER_REGISTER, params, header);
         return JSON.parseObject(response);
     }
+    private boolean updateUserMessAge(JSONObject userContent) {
+        String userId = userContent.getString(RESPONSE_FIELD_ID);
+        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
+        params.add("id", userId);
+        params.add("failureTime", LocalDateTime.now().plusYears(20).format(DATE_FORMAT));
+        Map<String, String> header = new HashMap<>();
+        header.put("token", getTokenOfServiceAccount());
+        String response = HttpUtil.requestPost(oauthPath+UPDATE_USER_MESS_AGE, params, header);
+        return isSuccess(JSONObject.parseObject(response));
+    }
 
     private boolean updateRole(JSONObject userContent, Collection<String> addRoleIds, Collection<String> removeRoleIds, String serviceId) {
         String userId = userContent.getString(RESPONSE_FIELD_ID);
@@ -445,6 +468,7 @@ public class AuthService {
         if (usercode == null || usercode.isEmpty()) {
             return false;
         }
+        updateUserMessAge(userContent);
         if (getUserDmsData(usercode) == null) {
             User user = new User();
             user.setCUsercode(usercode);
@@ -481,7 +505,7 @@ public class AuthService {
                         }
                         return login(account).toJSONString();
                     } else {
-                        return MessageManage.getInstance().getResultContent(-1, "未知异常", "未知异常");
+                        return result.toJSONString();
                     }
                 }
             });