优化代码支持多用户类型扩展
This commit is contained in:
+18
@@ -4,6 +4,9 @@ package com.central.common.constant;
|
||||
* Security 权限常量
|
||||
*
|
||||
* @author zlt
|
||||
* <p>
|
||||
* Blog: https://zlt2000.gitee.io
|
||||
* Github: https://github.com/zlt2000
|
||||
*/
|
||||
public interface SecurityConstants {
|
||||
/**
|
||||
@@ -31,6 +34,11 @@ public interface SecurityConstants {
|
||||
*/
|
||||
String TENANT_HEADER = "x-tenant-header";
|
||||
|
||||
/**
|
||||
* 账号类型信息头
|
||||
*/
|
||||
String ACCOUNT_TYPE_HEADER = "x-account-type-header";
|
||||
|
||||
/**
|
||||
* 基础角色
|
||||
*/
|
||||
@@ -167,4 +175,14 @@ public interface SecurityConstants {
|
||||
* 令牌颁发者
|
||||
*/
|
||||
String ISS = "http://zlt2000.cn";
|
||||
|
||||
/**
|
||||
* 默认账号类型
|
||||
*/
|
||||
String DEF_ACCOUNT_TYPE = "admin";
|
||||
|
||||
/**
|
||||
* 账号类型参数名
|
||||
*/
|
||||
String ACCOUNT_TYPE_PARAM_NAME = "account_type";
|
||||
}
|
||||
|
||||
+5
@@ -23,6 +23,9 @@ import java.util.List;
|
||||
*
|
||||
* @author zlt
|
||||
* @date 2018/12/21
|
||||
* <p>
|
||||
* Blog: https://zlt2000.gitee.io
|
||||
* Github: https://github.com/zlt2000
|
||||
*/
|
||||
@Slf4j
|
||||
public class TokenArgumentResolver implements HandlerMethodArgumentResolver {
|
||||
@@ -61,6 +64,8 @@ public class TokenArgumentResolver implements HandlerMethodArgumentResolver {
|
||||
String userId = request.getHeader(SecurityConstants.USER_ID_HEADER);
|
||||
String username = request.getHeader(SecurityConstants.USER_HEADER);
|
||||
String roles = request.getHeader(SecurityConstants.ROLE_HEADER);
|
||||
//账号类型
|
||||
String accountType = request.getHeader(SecurityConstants.ACCOUNT_TYPE_HEADER);
|
||||
if (StrUtil.isBlank(username)) {
|
||||
log.warn("resolveArgument error username is empty");
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user