Browse Source

运营服务

yingp 7 years ago
parent
commit
d023f76727

+ 3 - 2
applications/operation/operation-auth-server/src/main/java/com/usoftchina/saas/operation/auth/controller/AuthController.java

@@ -77,9 +77,10 @@ public class AuthController {
             if (!companyDTO.isPresent()) {
                 return Result.error(ExceptionCode.USER_NOT_ENABLE);
             }
+            Long companyId = companyDTO.get().getId();
             String appId = "operation";
 
-            JwtInfo info = new JwtInfo(appId, companyDTO.get().getId(), accountDTO.getId(), accountDTO.getUsername(), accountDTO.getRealname());
+            JwtInfo info = new JwtInfo(appId, companyId, accountDTO.getId(), accountDTO.getUsername(), accountDTO.getRealname());
             JwtToken jwtToken = JwtHelper.generateToken(info, authConfig.getPrivateKey(), authConfig.getExpire());
             TokenDTO tokenDTO = BeanMapper.map(jwtToken, TokenDTO.class);
             // 登录成功记入redis
@@ -89,7 +90,7 @@ public class AuthController {
             authorizeLogService.save(AuthorizeLog.from(request)
                     .setAccountId(accountDTO.getId())
                     .setAppId(appId).build());
-            return Result.success(new AuthDTO(tokenDTO, accountDTO));
+            return Result.success(new AuthDTO(tokenDTO, accountDTO, companyId));
         } else {
             // 失败次数超过最大限制
             if (authorizeCountService.increaseAndGet(username) > authConfig.getMaxErrors()) {

+ 7 - 0
base-servers/auth/auth-dto/src/main/java/com/usoftchina/saas/auth/dto/AuthDTO.java

@@ -33,6 +33,12 @@ public class AuthDTO implements Serializable{
         this.account = account;
     }
 
+    public AuthDTO(TokenDTO token, AccountDTO account, Long companyId) {
+        this.token = token;
+        this.account = account;
+        this.companyId = companyId;
+    }
+
     public AccountDTO getAccount() {
         return account;
     }
@@ -54,6 +60,7 @@ public class AuthDTO implements Serializable{
         return "AuthDTO{" +
                 "token=" + token +
                 ", account=" + account +
+                ", companyId=" + companyId +
                 '}';
     }
 }