Commit a5b53cc7 authored by 赵啸非's avatar 赵啸非

修改设备管理系统单点登录

parent 4a8a4e12
......@@ -73,6 +73,17 @@ public interface IUserFeign extends IFeign {
@PostMapping("/api/user/findAllUser")
String findAllUser(@RequestBody UserPdu userPdu);
/**
* 获取token
*
* @param
* @return
*/
@PostMapping(value = "/user/token")
Rest<String> getToken(@RequestParam(value = "userKey") String userKey);
}
......@@ -111,6 +122,11 @@ class UserFeignFallbackFactory implements FallbackFactory<IUserFeign> {
public String findAllUser(UserPdu userPdu) {
return null;
}
@Override
public Rest<String> getToken(String userKey) {
return Rest.fail("token获取失败");
}
};
}
}
......
......@@ -3,12 +3,14 @@ package com.mortals.xhx.base.framework.interceptor;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.ap.SysConstains;
import com.mortals.framework.common.Rest;
import com.mortals.framework.service.IAuthTokenService;
import com.mortals.framework.service.ICacheService;
import com.mortals.framework.service.IUser;
import com.mortals.framework.util.DateUtils;
import com.mortals.framework.util.StringUtils;
import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.feign.user.IUserFeign;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
......@@ -54,6 +56,9 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
@Value("${token.database:0}")
private Integer portalDb;
@Autowired
private IUserFeign userFeign;
protected static final Long SECOND = 1l;
......@@ -85,11 +90,14 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
Claims claims = parseToken(token);
String uuid = (String) claims.get(SysConstains.LOGIN_USER_KEY);
String userKey = getTokenKey(uuid);
cacheService.select(portalDb);
String userStr = cacheService.get(userKey);
cacheService.select(db);
//cacheService.select(portalDb);
// String userStr = cacheService.get(userKey);
Rest<String> rest = userFeign.getToken(userKey);
String userStr = rest.getData();
//cacheService.select(db);
if (StringUtils.isNotEmpty(userStr)) {
UserEntity userEntity = JSONObject.parseObject(userStr, UserEntity.class);
userEntity.setToken(token);
return userEntity;
}
} catch (Exception e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment