厨房后场人员登录
This commit is contained in:
parent
5270de1267
commit
f85497ce6b
|
|
@ -158,7 +158,11 @@ public class TokenController {
|
|||
|
||||
LoginUser login = strategy.login(username, password);
|
||||
logService.saveLogin(username, "登录", "登录成功", null, "成功");
|
||||
return R.ok(tokenService.createToken(login));
|
||||
if (LoginType.KITCHEN_PHONE_PASSWORD.equals(form.getLoginType())) {
|
||||
return R.ok(tokenService.createKitchenStaffToken(login));
|
||||
} else {
|
||||
return R.ok(tokenService.createToken(login));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ public class CacheConstants {
|
|||
* 权限缓存前缀
|
||||
*/
|
||||
public static final String LOGIN_USER_KEY = "login_users:";
|
||||
|
||||
public static final String LOGIN_STAFF_KEY = "login_staffs:";
|
||||
/**
|
||||
* 权限缓存前缀
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -58,6 +58,8 @@ public class TokenService {
|
|||
|
||||
private final static String LOGIN_USER_KEY = CacheConstants.LOGIN_USER_KEY;
|
||||
|
||||
private final static String LOGIN_STAFF_KEY = CacheConstants.LOGIN_STAFF_KEY;
|
||||
|
||||
private final static Long MILLIS_MINUTE_TEN = CacheConstants.REFRESH_TIME * MILLIS_MINUTE;
|
||||
|
||||
/**
|
||||
|
|
@ -94,6 +96,34 @@ public class TokenService {
|
|||
return rspMap;
|
||||
}
|
||||
|
||||
public Map<String, Object> createKitchenStaffToken(LoginUser loginUser) {
|
||||
// 检查并删除已有的token
|
||||
//delExistingToken(loginUser.getSysUser().getUserId());
|
||||
String token = IdUtils.fastUUID();
|
||||
Long userId = loginUser.getSysUser().getUserId();
|
||||
String userName = loginUser.getSysUser().getUserName();
|
||||
loginUser.setToken(token);
|
||||
loginUser.setUserid(userId);
|
||||
loginUser.setUsername(userName);
|
||||
loginUser.setIpaddr(IpUtils.getIpAddr());
|
||||
refreshToken(loginUser);
|
||||
// Jwt存储信息
|
||||
Map<String, Object> claimsMap = new HashMap<String, Object>(16);
|
||||
claimsMap.put(SecurityConstants.USER_KEY, token);
|
||||
claimsMap.put(SecurityConstants.DETAILS_USER_ID, userId);
|
||||
claimsMap.put(SecurityConstants.DETAILS_USERNAME, userName);
|
||||
String accessToken = JwtUtils.createToken(claimsMap);
|
||||
Map<String, Object> rspMap = new HashMap<String, Object>(16);
|
||||
rspMap.put("access_token", accessToken);
|
||||
rspMap.put("expires_in", EXPIRETIME);
|
||||
rspMap.put("isLogin", isLogin(String.valueOf(userId)));
|
||||
rspMap.put("deviceTypes", loginUser.getPermissions());
|
||||
long tokenTime = getTokenTime();
|
||||
//对token进行存储
|
||||
redisService.setCacheObject(LOGIN_STAFF_KEY + userId, token, tokenTime, TimeUnit.MINUTES);
|
||||
return rspMap;
|
||||
}
|
||||
|
||||
public boolean isLogin(String userId) {
|
||||
String existingTokenKey = redisService.getCacheObject(LOGIN_USER_KEY + userId);
|
||||
return existingTokenKey != null;
|
||||
|
|
|
|||
Loading…
Reference in New Issue