|
@@ -44,6 +44,7 @@ public class TokenArgumentResolver implements HandlerMethodArgumentResolver {
|
|
if (request == null) {
|
|
if (request == null) {
|
|
throw new CustomException(HttpStatusEnum.UNKNOWN_ERROR);
|
|
throw new CustomException(HttpStatusEnum.UNKNOWN_ERROR);
|
|
}
|
|
}
|
|
|
|
+ //是否强制验证登录状态
|
|
boolean b = parameter.hasParameterAnnotation(ValidLogin.class);
|
|
boolean b = parameter.hasParameterAnnotation(ValidLogin.class);
|
|
String token = request.getHeader("token");
|
|
String token = request.getHeader("token");
|
|
if (b && StringUtils.isEmpty(token)) {
|
|
if (b && StringUtils.isEmpty(token)) {
|
|
@@ -54,15 +55,22 @@ public class TokenArgumentResolver implements HandlerMethodArgumentResolver {
|
|
UserData data = new UserData();
|
|
UserData data = new UserData();
|
|
data.setDeviceType(deviceType);
|
|
data.setDeviceType(deviceType);
|
|
if (StringUtils.isEmpty(token)) {
|
|
if (StringUtils.isEmpty(token)) {
|
|
|
|
+ if (b) {
|
|
|
|
+ throw new CustomException(HttpStatusEnum.USER_NO_LOGIN);
|
|
|
|
+ }
|
|
return data;
|
|
return data;
|
|
}
|
|
}
|
|
UserTokenDTO tokenInfoByTokenDevice = userTokenService.getTokenInfoByTokenDevice(token, deviceType.toString());
|
|
UserTokenDTO tokenInfoByTokenDevice = userTokenService.getTokenInfoByTokenDevice(token, deviceType.toString());
|
|
if (tokenInfoByTokenDevice == null) {
|
|
if (tokenInfoByTokenDevice == null) {
|
|
|
|
+ if (b) {
|
|
|
|
+ throw new CustomException(HttpStatusEnum.USER_NO_LOGIN);
|
|
|
|
+ }
|
|
return data;
|
|
return data;
|
|
}
|
|
}
|
|
if (b && tokenInfoByTokenDevice.getUserId() == null) {
|
|
if (b && tokenInfoByTokenDevice.getUserId() == null) {
|
|
throw new CustomException(HttpStatusEnum.USER_NO_LOGIN);
|
|
throw new CustomException(HttpStatusEnum.USER_NO_LOGIN);
|
|
}
|
|
}
|
|
- return BeanUtils.copy(tokenInfoByTokenDevice, UserData.class);
|
|
|
|
|
|
+ data.setUserId(tokenInfoByTokenDevice.getUserId());
|
|
|
|
+ return data;
|
|
}
|
|
}
|
|
}
|
|
}
|