上下文添加差标

This commit is contained in:
lulz1 2024-02-23 13:37:49 +08:00
parent 258d27e9f9
commit 9608462308
4 changed files with 9 additions and 4 deletions

View File

@ -46,13 +46,14 @@ public class User {
this.employeeNo = employeeNo; this.employeeNo = employeeNo;
} }
public User(Long userId, Long employeeNo, Integer employeeLevel, String name, String email, String phoneNumber, UserLoginParam userLoginParam) { public User(Long userId, Long employeeNo, Integer employeeLevel, String name, String email, String phoneNumber, UserLoginParam userLoginParam, String standardLevel) {
this.userId = userId; this.userId = userId;
this.employeeNo = employeeNo; this.employeeNo = employeeNo;
this.employeeLevel = employeeLevel; this.employeeLevel = employeeLevel;
this.name = name; this.name = name;
this.email = email; this.email = email;
this.phoneNumber = phoneNumber; this.phoneNumber = phoneNumber;
this.standardLevel = standardLevel;
this.userLoginParam = userLoginParam; this.userLoginParam = userLoginParam;
} }
@ -78,12 +79,14 @@ public class User {
Claim name = claims.get(USER_NAME); Claim name = claims.get(USER_NAME);
Claim employeeLevel = claims.get(USER_EMPLOYEE_LEVEL); Claim employeeLevel = claims.get(USER_EMPLOYEE_LEVEL);
Claim loginParam = claims.get(USER_LOGIN_PARAM); Claim loginParam = claims.get(USER_LOGIN_PARAM);
Claim standardLevel = claims.get(USER_STANDARD_LEVEL);
return new User(userId.asLong(), return new User(userId.asLong(),
employeeNo.asLong(), employeeNo.asLong(),
employeeLevel.asInt(), employeeLevel.asInt(),
name.asString(), name.asString(),
email.asString(), email.asString(),
phoneNumber.asString(), phoneNumber.asString(),
UserLoginParam.of(loginParam.asString())); UserLoginParam.of(loginParam.asString()),
standardLevel.asString());
} }
} }

View File

@ -58,6 +58,7 @@ public class AuthenticateServiceImpl implements AuthenticateService {
claims.put(USER_RANK_CODE, user.getStandardLevel()); claims.put(USER_RANK_CODE, user.getStandardLevel());
claims.put(USER_COMPANY_CODE, user.getCompanyCode()); claims.put(USER_COMPANY_CODE, user.getCompanyCode());
claims.put(USER_LOGIN_PARAM, json.gson().toJson(userLoginParam)); claims.put(USER_LOGIN_PARAM, json.gson().toJson(userLoginParam));
claims.put(USER_STANDARD_LEVEL, user.getStandardLevel());
String jwt = JWTUtil.createJWT(claims); String jwt = JWTUtil.createJWT(claims);
//这里已经是完成的用户信息里 因此将用户信息保存到threadLocal当中 //这里已经是完成的用户信息里 因此将用户信息保存到threadLocal当中

View File

@ -174,6 +174,7 @@ public class Constant {
public static final String USER_RANK_CODE = "rankCode"; public static final String USER_RANK_CODE = "rankCode";
public static final String USER_COMPANY_CODE = "companyCode"; public static final String USER_COMPANY_CODE = "companyCode";
public static final String USER_LOGIN_PARAM = "userLoginParam"; public static final String USER_LOGIN_PARAM = "userLoginParam";
public static final String USER_STANDARD_LEVEL = "standardLevel";
// JWT // JWT
public static final String SECRET = "Superdandan"; // 替换为你自己的密钥 public static final String SECRET = "Superdandan"; // 替换为你自己的密钥

View File

@ -58,8 +58,8 @@ public class UserHttpRequestImpl implements UserHttpRequest {
} }
Ranks ranks = rankDomainService.queryRanks(rankName, user.getCompanyCode()); Ranks ranks = rankDomainService.queryRanks(rankName, user.getCompanyCode());
if (ranks != null) { if (ranks != null) {
// user.setStandardLevel(ranks.getStandardLevel()); user.setStandardLevel(ranks.getStandardLevel());
user.setStandardLevel("测试职级"); // user.setStandardLevel("测试职级");
} }
return user; return user;
} }