Browse Source

单点登录代码逻辑开发

zhangqiankun 3 years ago
parent
commit
46d846c60f

+ 18 - 8
saas-account/src/main/java/com/persagy/account/controller/SaasAccountController.java

@@ -2,8 +2,6 @@ package com.persagy.account.controller;
 
 import java.util.List;
 
-import com.persagy.account.pojo.vo.account.*;
-import com.persagy.security.util.BouncycastleCipher;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
@@ -17,18 +15,24 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
-import com.persagy.common.constant.SaasCommonConstant;
-import com.persagy.common.enums.ResponseCode;
-import com.persagy.common.model.BaseGroupModel;
-import com.persagy.common.utils.ResponseResult;
-import com.persagy.common.utils.ResponseResultUtil;
-import com.persagy.common.utils.StringUtil;
 import com.persagy.account.config.ApplicationProperties;
 import com.persagy.account.manage.SaasAccountHandler;
 import com.persagy.account.pojo.dto.SaasAccount;
 import com.persagy.account.pojo.dto.SaasRole;
+import com.persagy.account.pojo.vo.account.SaasAccountCreateVO;
+import com.persagy.account.pojo.vo.account.SaasAccountGroupVO;
+import com.persagy.account.pojo.vo.account.SaasAccountPageVO;
+import com.persagy.account.pojo.vo.account.SaasAccountQueryByNameVO;
+import com.persagy.account.pojo.vo.account.SaasAccountQueryVO;
 import com.persagy.account.service.ISaasAccountService;
 import com.persagy.account.service.ISaasRoleService;
+import com.persagy.common.constant.SaasCommonConstant;
+import com.persagy.common.enums.ResponseCode;
+import com.persagy.common.model.BaseGroupModel;
+import com.persagy.common.utils.ResponseResult;
+import com.persagy.common.utils.ResponseResultUtil;
+import com.persagy.common.utils.StringUtil;
+import com.persagy.security.util.BouncycastleCipher;
 
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.BooleanUtil;
@@ -70,6 +74,9 @@ public class SaasAccountController {
     @ApiOperation(value = "账号信息查询")
     @RequestMapping(value = "querySaasAccountList")
     public ResponseResult querySaasAccountList(@RequestBody @Validated SaasAccountQueryVO queryVO) {
+    	if (CollectionUtil.isNotEmpty(queryVO.getAccountIds()) && queryVO.getAccountIds().size() > 100) {
+    		return ResponseResultUtil.errorResult(ResponseCode.A0400.getCode(), "账号ID集合数量过多,请分批查询");
+		}
     	SaasAccount saasAccount = new SaasAccount();
 		BeanUtils.copyProperties(queryVO, saasAccount);
 		saasAccount.setId(queryVO.getAccountId());
@@ -92,6 +99,9 @@ public class SaasAccountController {
     @ApiOperation(value = "账号分页信息查询")
     @RequestMapping(value = "queryAccountPageList")
     public ResponseResult queryAccountPageList(@RequestBody @Validated SaasAccountPageVO pageVO) {
+    	if (CollectionUtil.isNotEmpty(pageVO.getAccountIds()) && pageVO.getAccountIds().size() > 100) {
+    		return ResponseResultUtil.errorResult(ResponseCode.A0400.getCode(), "账号ID集合数量过多,请分批查询");
+		}
     	SaasAccount saasAccount = new SaasAccount();
 		BeanUtils.copyProperties(pageVO, saasAccount);
 		saasAccount.setId(pageVO.getAccountId());

+ 7 - 8
saas-account/src/main/java/com/persagy/account/controller/SaasAccountRoleController.java

@@ -12,15 +12,13 @@ import org.springframework.web.bind.annotation.RestController;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.google.common.collect.Lists;
-import com.persagy.common.enums.ResponseCode;
-import com.persagy.common.utils.ResponseResult;
-import com.persagy.common.utils.ResponseResultUtil;
-import com.persagy.common.utils.StringUtil;
 import com.persagy.account.pojo.dto.SaasAccountRole;
 import com.persagy.account.pojo.vo.auth.SaasAccountRoleBatchVO;
 import com.persagy.account.pojo.vo.auth.SaasAccountRoleCreateVO;
 import com.persagy.account.pojo.vo.auth.SaasAccountRoleQueryVO;
 import com.persagy.account.service.ISaasAccountRoleService;
+import com.persagy.common.utils.ResponseResult;
+import com.persagy.common.utils.ResponseResultUtil;
 
 import cn.hutool.core.collection.CollectionUtil;
 import io.swagger.annotations.Api;
@@ -49,11 +47,12 @@ public class SaasAccountRoleController {
     @ApiOperation(value = "查询账号-角色关联信息")
     @RequestMapping(value = "querySaasRoleMenuList")
     public ResponseResult querySaasRoleMenuList(@RequestBody @Validated SaasAccountRoleQueryVO queryVO) {
-    	if (StringUtil.isBlank(queryVO.getAccountId()) && CollectionUtil.isEmpty(queryVO.getAccountIds())) {
+    	/*if (StringUtil.isBlank(queryVO.getAccountId()) && CollectionUtil.isEmpty(queryVO.getAccountIds())) {
 			return ResponseResultUtil.errorResult(ResponseCode.A0402.getDesc(), "账号ID与账号ID集合参数必须存在其一");
-		}
-    	LambdaQueryWrapper<SaasAccountRole> queryWrapper = new SaasAccountRole.Builder().createQueryWrapper().accountIdEq(queryVO.getAccountId())
-				.accountIdIn(queryVO.getAccountIds()).groupCodeEq(queryVO.getGroupCode()).roleIdEq(queryVO.getRoleId()).builderQueryWrapper();
+		}*/
+    	LambdaQueryWrapper<SaasAccountRole> queryWrapper = new SaasAccountRole.Builder().createQueryWrapper()
+    			.accountIdEq(queryVO.getAccountId()).accountIdIn(queryVO.getAccountIds()).groupCodeEq(queryVO.getGroupCode())
+    			.roleIdEq(queryVO.getRoleId()).roleIdIn(queryVO.getRoleIds()).builderQueryWrapper();
     	List<SaasAccountRole> list = this.saasAccountRoleService.list(queryWrapper);
     	if (CollectionUtil.isEmpty(list)) {
 			return ResponseResultUtil.successResult(Lists.newArrayList(), 0L);

+ 59 - 20
saas-account/src/main/java/com/persagy/account/controller/SaasAuthCenterController.java

@@ -22,11 +22,14 @@ import com.persagy.common.constant.SaasCommonConstant;
 import com.persagy.common.enums.ResponseCode;
 import com.persagy.common.utils.ResponseResult;
 import com.persagy.common.utils.ResponseResultUtil;
+import com.persagy.common.utils.StringUtil;
 import com.persagy.security.util.BouncycastleCipher;
 import com.persagy.security.util.SecureAES;
 
 import cn.hutool.core.util.BooleanUtil;
+import cn.hutool.core.util.IdUtil;
 import cn.hutool.crypto.digest.DigestAlgorithm;
+import cn.hutool.crypto.digest.MD5;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 
@@ -42,12 +45,17 @@ import io.swagger.annotations.ApiOperation;
 @RequestMapping(value = "/authCenter", method = RequestMethod.POST)
 public class SaasAuthCenterController {
 	
+	private static MD5 md5 = MD5.create();
+	
 	@Autowired
 	private SaasAuthHandler saasAuthHandler;
 	
 	@Autowired
 	private ApplicationProperties properties;
 	
+    //@Autowired
+    //private ISaasAccountService saasAccountService;
+    
     @Autowired
     private BouncycastleCipher bouncycastleCipher;
     
@@ -60,7 +68,7 @@ public class SaasAuthCenterController {
     @ApiOperation(value = "申请授权码")
     @RequestMapping(value = "code")
     public ResponseResult getCode(@RequestBody @Validated SaasCodeVO model) {
-    	String code = this.saasAuthHandler.getCode(model.getClientId(), model.getRedirectUrl());
+    	String code = this.saasAuthHandler.getCode(model.getClientId(), model.getRedirectUrl(), null, null, null);
     	Map<String, String> result = new HashedMap<String, String>(1);
     	result.put("code", code);
     	return ResponseResultUtil.successResult(result);
@@ -79,50 +87,81 @@ public class SaasAuthCenterController {
     		return ResponseResultUtil.errorResult(ResponseCode.A0001.getCode(), ResponseCode.A0001.getDesc());
 		}
     	// 验证是否授权码存在
-    	Object object = this.redisTemplate.opsForValue().get(model.getClientId() + "_CODE");
-    	if (object == null) {
-    		return ResponseResultUtil.errorResult(ResponseCode.A0311.getCode(), ResponseCode.A0311.getDesc());
+    	String code = (String) this.redisTemplate.opsForHash().get(model.getClientId(), SaasCommonConstant.CODE_REDIS_HASH_KEY);
+    	if (StringUtil.isBlank(code)) {
+    		return ResponseResultUtil.errorResult(ResponseCode.A0301.getCode(), ResponseCode.A0301.getDesc());
 		}
-    	String code = (String) object;
     	if (!model.getCode().equals(code)) {
     		return ResponseResultUtil.errorResult(ResponseCode.A0303.getCode(), ResponseCode.A0303.getDesc());
 		}
-    	// 生成token
-    	String key = model.getClientId() + "_TOKEN";
+    	// 判断token是否已存在
     	long expire = Long.parseLong(this.properties.getTokenExpire());
-    	String sign = this.bouncycastleCipher.encrypt(this.tokenInfo(model.getClientId(), code), key, DigestAlgorithm.MD5, expire, TimeUnit.MINUTES);
+    	String accountId = (String) this.redisTemplate.opsForHash().get(model.getClientId(), SaasCommonConstant.ACCOUNT_ID_REDIS_HASH_KEY);
+    	if (StringUtil.isBlank(accountId)) {
+    		return ResponseResultUtil.errorResult(ResponseCode.A0402.getCode(), ResponseCode.A0402.getDesc());
+		}
+    	// token放入redis,key-accountId
+    	String token = (String) this.redisTemplate.opsForValue().get(accountId);
+    	if (StringUtil.isBlank(token)) {
+    		token = this.bouncycastleCipher.encrypt(this.getAccessToken(code), DigestAlgorithm.MD5);
+    		this.redisTemplate.opsForValue().set(accountId, token, expire, TimeUnit.SECONDS);
+		} else {
+			this.redisTemplate.expire(accountId, expire, TimeUnit.SECONDS);
+		}
+    	// MD5生成 refreshToken,放进hash存储
+    	String refreshToken = md5.digestHex(this.getRefreshToken());
+    	this.redisTemplate.opsForHash().put(model.getClientId(), SaasCommonConstant.REFRESH_TOKEN_REDIS_HASH_KEY, refreshToken);
+    	
+    	// AES加密出账号信息所需字段,组合为token
     	SecureAES aes = new SecureAES(properties.getAesKey(), properties.getAesIv());
-    	String data = aes.encryptAccount(this.tokenAuthInfo(key));
-    	String token = data + SaasCommonConstant.POINT_JOIN_SYMBOL + sign;
+    	String tokenPrefix = aes.encrypt(this.getTokenPrefix(model.getClientId(), accountId));
+    	token = tokenPrefix + SaasCommonConstant.POINT_JOIN_SYMBOL + token;
+    	
     	Map<String, Object> map = new HashedMap<String, Object>();
-    	map.put("token", token);
+    	map.put("refreshToken", refreshToken);
+    	map.put("accessToken", token);
     	map.put("expire", expire);
     	return ResponseResultUtil.successResult(map);
     }
     
     /**
+     * 这里的数据,均为登录时指定,为登录时指定的
      * 
-     * @param loginApp
+     * @param clientId
+     * @param accountId
      * @return
      */
-    private JSONObject tokenAuthInfo(String key) {
-		JSONObject object = new JSONObject();
-		object.put(SaasCommonConstant.ACCOUNT_ID, key);
-		return object;
+    private String getTokenPrefix(String clientId, String accountId) {
+    	String appId = (String) this.redisTemplate.opsForHash().get(clientId, SaasCommonConstant.APP_ID_REDIS_HASH_KEY);
+    	String groupCode = (String) this.redisTemplate.opsForHash().get(clientId, SaasCommonConstant.GROUP_CODE_REDIS_HASH_KEY);
+		JSONObject result = new JSONObject();
+		result.put(SaasCommonConstant.ACCOUNT_ID, accountId);
+		result.put(SaasCommonConstant.GROUP_CODE, groupCode);
+		result.put(SaasCommonConstant.APP_ID, appId);
+		return result.toJSONString();
 	}
     
     /**
      * 根据授权码组合token原信息
-     * @param clientId
      * @param code
      * @return
      */
-    private String tokenInfo(String clientId, String code) {
+    private String getAccessToken(String code) {
 		JSONObject object = new JSONObject();
-		object.put("clientId", clientId);
-		object.put("date", System.currentTimeMillis());
 		object.put("code", code);
 		return object.toJSONString();
 	}
     
+    /**
+     * 获取refreshToken
+     * @param code
+     * @return
+     */
+    private String getRefreshToken() {
+		JSONObject object = new JSONObject();
+		object.put("time", System.currentTimeMillis());
+		object.put("state", IdUtil.fastSimpleUUID());
+		return object.toJSONString();
+	}
+    
 }

+ 3 - 3
saas-account/src/main/java/com/persagy/account/controller/SaasLoginController.java

@@ -152,7 +152,7 @@ public class SaasLoginController {
     	String token = this.setRedisToken(account, loginVO.getAppId(), loginVO.isRemember(), false);
     	// 判断是否需要重定向
     	if (StringUtil.isNotBlank(redirectUrl)) {
-    		String code = this.saasAuthHandler.getCode(loginVO.getClientId(), loginVO.getRedirectUrl());
+    		String code = this.saasAuthHandler.getCode(loginVO.getClientId(), loginVO.getRedirectUrl(), account.getId(), account.getGroupCode(), loginVO.getAppId());
 			redirectUrl = redirectUrl + "&code=" + code;
 			Map<String, String> temp = new HashMap<String, String>();
 			temp.put("redirectUrl", redirectUrl);
@@ -315,10 +315,10 @@ public class SaasLoginController {
 	        		throw new BusinessException(ResponseCode.A0301.getCode(), ResponseCode.A0301.getDesc());
 	    		}
 			}
-			this.redisTemplate.expire(account.getId(), Long.parseLong(this.properties.getTokenExpire()), TimeUnit.MINUTES);
+			this.redisTemplate.expire(account.getId(), Long.parseLong(this.properties.getTokenExpire()), TimeUnit.SECONDS);
 		} else {
 			// 加密串MD5加密转为sign,redis:key-账号ID,value-sign(data-MD5加密后)
-	    	sign = this.bouncycastleCipher.encrypt(this.tokenInfo(data, loginApp), account.getId(), DigestAlgorithm.MD5, Long.parseLong(this.properties.getTokenExpire()), TimeUnit.MINUTES);
+	    	sign = this.bouncycastleCipher.encrypt(this.tokenInfo(data, loginApp), account.getId(), DigestAlgorithm.MD5, Long.parseLong(this.properties.getTokenExpire()), TimeUnit.SECONDS);
 		}
         // token=data.sign
     	String token = data + SaasCommonConstant.POINT_JOIN_SYMBOL + sign;

+ 39 - 14
saas-account/src/main/java/com/persagy/account/manage/SaasAuthHandler.java

@@ -3,7 +3,6 @@ package com.persagy.account.manage;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.TimeUnit;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
@@ -208,38 +207,64 @@ public class SaasAuthHandler {
     
     
     /**
-     * 申请授权码
+     * 申请授权码,每次重新生成
+     * 
+     * @param clientId
+     * @param redirectUrl
+     * @param accountId
+     * @param groupCode
+     * @param appId
+     * @return
      */
-    public String getCode(String clientId, String redirectUrl) {
+    public String getCode(String clientId, String redirectUrl, String accountId, String groupCode, String appId) {
     	// 验证客户端ID是否存在
     	Boolean member = this.redisTemplate.opsForSet().isMember(SaasCommonConstant.SAAS_CLIENT_ID_REDIS_KEY, clientId);
     	if (!BooleanUtil.isTrue(member)) {
     		throw new BusinessException(ResponseCode.A0001.getCode(), "非法客户端");
 		}
+    	// 如果redirectUrl存在,验证是否为可用值
+    	if (!this.validRedirectUrl(clientId, redirectUrl)) {
+    		throw new BusinessException(ResponseCode.A0001.getCode(), "非法客户端");
+		}
+    	// 设置账号相关信息
+		this.redisTemplate.opsForHash().put(clientId, SaasCommonConstant.APP_ID_REDIS_HASH_KEY, appId);
+		this.redisTemplate.opsForHash().put(clientId, SaasCommonConstant.ACCOUNT_ID_REDIS_HASH_KEY, accountId);
+		this.redisTemplate.opsForHash().put(clientId, SaasCommonConstant.GROUP_CODE_REDIS_HASH_KEY, groupCode);
+		
     	// 生成新的授权码,并验证授权码是否已存在
-    	String redisKey = this.getCodeRediskey(clientId, redirectUrl);
     	JSONObject temp = new JSONObject();
     	temp.put("time", System.currentTimeMillis());
     	temp.put("redirectUrl", redirectUrl);
+    	temp.put("clientId", clientId);
     	String code = md5.digestHex(temp.toJSONString());
-    	Boolean setIfAbsent = this.redisTemplate.opsForValue().setIfAbsent(redisKey, code, 300000L, TimeUnit.MILLISECONDS);
-    	if (!BooleanUtil.isTrue(setIfAbsent)) {
-    		throw new BusinessException(ResponseCode.A0302.getCode(), ResponseCode.A0302.getDesc());
-		}
+    	this.redisTemplate.opsForHash().put(clientId, SaasCommonConstant.CODE_REDIS_HASH_KEY, code);
     	return code;
     }
     
     /**
-     * 客户端ID
-     * @param clientId 不可为空
-     * @param redirectUrl 可为空
+     * 验证redirectUrl的有效性,此方法默认空的redirectUrl,校验为true
+     * 
+     * @param clientId
+     * @param redirectUrl
      * @return
      */
-    public String getCodeRediskey(String clientId, String redirectUrl) {
+    public boolean validRedirectUrl(String clientId, String redirectUrl) {
     	if (StringUtil.isBlank(redirectUrl)) {
-    		redirectUrl = "";
+			return true;
+		}
+		Object object = this.redisTemplate.opsForHash().get(clientId, SaasCommonConstant.REDIRECT_URL_REDIS_HASH_KEY);
+		if(object == null) {
+			return false;
+		}
+		String allowUrl = (String) object;
+		if (StringUtil.isBlank(allowUrl)) {
+			return false;
+		}
+		if (allowUrl.equals(allowUrl)) {
+			return true;
 		}
-    	return clientId + SaasCommonConstant.UNDERLINE_JOIN_SYMBOL + md5.digestHex(redirectUrl);
+    	
+    	return false;
     }
     
 }

+ 3 - 0
saas-account/src/main/java/com/persagy/account/pojo/dto/SaasAccount.java

@@ -120,6 +120,9 @@ public class SaasAccount extends BaseEntity<SaasAccount> {
 	@TableField(exist = false)
 	private List<SaasMenu> auths;	//菜单权限树集合
 	
+	@TableField(exist = false)
+	private Set<String> accountIds;
+	
 	public static class Builder {
 
 		private LambdaQueryWrapper<SaasAccount> queryWrapper = null;

+ 11 - 0
saas-account/src/main/java/com/persagy/account/pojo/dto/SaasAccountRole.java

@@ -111,6 +111,17 @@ public class SaasAccountRole extends Model<SaasAccountRole> {
 			return this;
 		}
 		
+		public Builder roleIdIn(Set<String> roleIds) {
+			if (CollectionUtil.isNotEmpty(roleIds)) {
+				if (updateWrapper != null) {
+					updateWrapper.in(SaasAccountRole::getRoleId, roleIds);
+				} else {
+					queryWrapper.in(SaasAccountRole::getRoleId, roleIds);
+				}
+			}
+			return this;
+		}
+		
 		public Builder casTypeEq(String casType) {
 			if (StringUtil.isNotBlank(casType)) {
 				if (updateWrapper != null) {

+ 5 - 0
saas-account/src/main/java/com/persagy/account/pojo/vo/account/SaasAccountQueryVO.java

@@ -1,5 +1,7 @@
 package com.persagy.account.pojo.vo.account;
 
+import java.util.Set;
+
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
@@ -29,6 +31,9 @@ public class SaasAccountQueryVO {
 	
 	@ApiModelProperty(value = "账号ID", example = "RY56122123152")
 	private String accountId; 	// 当前账号ID
+	
+	@ApiModelProperty(value = "账号ID集合", example = "RY56122123152")
+	private Set<String> accountIds; 	// 当前账号ID集合
 
 	@ApiModelProperty(value = "角色ID", example = "RY56122123152")
 	private String roleId; 	// 角色ID

+ 3 - 0
saas-account/src/main/java/com/persagy/account/pojo/vo/auth/SaasAccountRoleQueryVO.java

@@ -43,6 +43,9 @@ public class SaasAccountRoleQueryVO{
 	@ApiModelProperty(value = "角色ID", example = "123")
 	private String roleId; // 角色ID
 	
+	@ApiModelProperty(value = "角色ID集合", example = "123")
+	private Set<String> roleIds; // 角色ID集合
+	
 	@ApiModelProperty(value = "关联类型,0-主岗,1-副岗,2-业务超管默认角色", example = "0")
 	private String casType; 	// 关联类型,0-主岗,1-副岗,2-业务超管默认角色,这里的关联类型,会作为重置的条件,先进行删除
 	

+ 1 - 1
saas-account/src/main/java/com/persagy/account/service/ISaasAccountService.java

@@ -4,8 +4,8 @@ import java.util.List;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.persagy.common.service.ISuperService;
 import com.persagy.account.pojo.dto.SaasAccount;
+import com.persagy.common.service.ISuperService;
 
 /**
  * 账号信息

+ 5 - 5
saas-account/src/main/java/com/persagy/account/service/impl/SaasAccountServiceImpl.java

@@ -7,12 +7,12 @@ import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.google.common.collect.Lists;
-import com.persagy.common.constant.SaasCommonConstant;
-import com.persagy.common.service.impl.SuperServiceImpl;
-import com.persagy.common.utils.StringUtil;
 import com.persagy.account.mapper.SaasAccountMapper;
 import com.persagy.account.pojo.dto.SaasAccount;
 import com.persagy.account.service.ISaasAccountService;
+import com.persagy.common.constant.SaasCommonConstant;
+import com.persagy.common.service.impl.SuperServiceImpl;
+import com.persagy.common.utils.StringUtil;
 
 import cn.hutool.core.collection.CollectionUtil;
 
@@ -59,7 +59,7 @@ public class SaasAccountServiceImpl extends SuperServiceImpl<SaasAccountMapper,
 		}
 		// 查询出总记录数大小
 		LambdaQueryWrapper<SaasAccount> queryWrapper = new SaasAccount.Builder().createQueryWrapper()
-    			.idEq(saasAccount.getId()).updateUserEq(saasAccount.getUpdateUser())
+    			.idEq(saasAccount.getId()).idIn(saasAccount.getAccountIds()).updateUserEq(saasAccount.getUpdateUser())
     			.groupCodeEq(saasAccount.getGroupCode()).usernameLike(saasAccount.getUsername()).accountTypeEq(saasAccount.getAccountType())
     			.accountSourceEq(saasAccount.getAccountSource()).phoneNumEq(saasAccount.getPhoneNum()).mailEq(saasAccount.getMail())
     			.accountBelongEq(saasAccount.getAccountBelong()).validEq(saasAccount.getValid()).builderQueryWrapper();
@@ -73,7 +73,7 @@ public class SaasAccountServiceImpl extends SuperServiceImpl<SaasAccountMapper,
 	@Override
 	public LambdaQueryWrapper<SaasAccount> getQueryWrapper(SaasAccount saasAccount) {
 		LambdaQueryWrapper<SaasAccount> queryWrapper = new SaasAccount.Builder().createQueryWrapper()
-    			.idEq(saasAccount.getId()).updateUserEq(saasAccount.getUpdateUser())
+    			.idEq(saasAccount.getId()).idIn(saasAccount.getAccountIds()).updateUserEq(saasAccount.getUpdateUser())
     			.groupCodeEq(saasAccount.getGroupCode()).usernameLike(saasAccount.getUsername()).accountTypeEq(saasAccount.getAccountType())
     			.accountSourceEq(saasAccount.getAccountSource()).phoneNumEq(saasAccount.getPhoneNum()).mailEq(saasAccount.getMail())
     			.accountBelongEq(saasAccount.getAccountBelong()).validEq(saasAccount.getValid()).builderQueryWrapper();

+ 3 - 0
saas-account/src/main/resources/mapper/SaasAccountMapper.xml

@@ -40,6 +40,9 @@
 		SELECT M.*, N.GROUP_NAME FROM (SELECT <include refid="Base_Sql_Columns"></include> FROM saas_account
 		<where>
 			<if test="account.id != null and account.id.trim().length() != 0">AND ID = #{account.id}</if>
+			<if test="account.accountIds != null">AND ID IN
+				<foreach collection="account.accountIds" index="index" item="accountId" open="(" close=")" separator="," >#{project}</foreach>
+			</if>
 			<if test="account.groupCode != null and account.groupCode.trim().length() != 0">AND GROUP_CODE = #{account.groupCode}</if>
 			<if test="account.appId != null and account.appId.trim().length() != 0">AND TERMINAL LIKE CONCAT('%', #{account.appId}, '%')</if>
 			<if test="account.phoneNum != null and account.phoneNum.trim().length() != 0">AND PHONE_NUM = #{account.phoneNum}</if>

+ 6 - 0
saas-common/src/main/java/com/persagy/common/constant/SaasCommonConstant.java

@@ -66,5 +66,11 @@ public interface SaasCommonConstant {
 	String ACCOUNT_SOURCE_PERSAGE = "100";	// 100-saas
 
 	String SAAS_CLIENT_ID_REDIS_KEY = "SAAS_PLATFORM_CLIENT_ID_KEY";
+	String CODE_REDIS_HASH_KEY = "CODE";
+	String APP_ID_REDIS_HASH_KEY = "APP_ID";
+	String GROUP_CODE_REDIS_HASH_KEY = "GROUP_CODE";
+	String ACCOUNT_ID_REDIS_HASH_KEY = "ACCOUNT_ID";
+	String REDIRECT_URL_REDIS_HASH_KEY = "REDIRECT_URL";
+	String REFRESH_TOKEN_REDIS_HASH_KEY = "REFRESH_TOKEN";
 	
 }

BIN
saas-doc/doc/运维平台单点登录授权文档.docx


+ 1 - 1
saas-gateway/src/main/java/com/persagy/gateway/filter/CustomExceptionHandlerGlobalFilter.java

@@ -49,7 +49,7 @@ public class CustomExceptionHandlerGlobalFilter extends DefaultErrorWebException
     protected Map<String, Object> getErrorAttributes(ServerRequest request, boolean includeStackTrace) {
         Throwable error = super.getError(request);
         Map<String, Object> result = new HashMap<String, Object>(1);
-        result.put(ResponseCode.B0001.getCode(), ResponseCode.B0001.getDesc() + ": " + error.getMessage());
+        result.put(ResponseCode.Z9999.getCode(), ResponseCode.Z9999.getDesc() + ": " + error.getMessage());
         return result;
     }