提现问题

This commit is contained in:
2024-12-26 10:21:27 +08:00
parent 6d2e5f0d2a
commit cdefd711be
3 changed files with 18 additions and 8 deletions

View File

@@ -21,7 +21,6 @@ import java.util.Date;
/**
* 权限(Token)验证
*
*/
@Component
public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
@@ -35,37 +34,41 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
Login annotation;
if(handler instanceof HandlerMethod) {
if (handler instanceof HandlerMethod) {
annotation = ((HandlerMethod) handler).getMethodAnnotation(Login.class);
}else{
} else {
return true;
}
if(annotation == null){
if (annotation == null) {
return true;
}
//获取用户凭证
String token = request.getHeader(jwtUtils.getHeader());
if(StringUtils.isBlank(token)){
if (StringUtils.isBlank(token)) {
token = request.getParameter(jwtUtils.getHeader());
}
//凭证为空
if(StringUtils.isBlank(token)){
if (StringUtils.isBlank(token)) {
throw new SqxException(jwtUtils.getHeader() + "不能为空", HttpStatus.UNAUTHORIZED.value());
}
Claims claims = jwtUtils.getClaimByToken(token);
if(claims == null || jwtUtils.isTokenExpired(claims.getExpiration())){
if (claims == null || jwtUtils.isTokenExpired(claims.getExpiration())) {
throw new SqxException(jwtUtils.getHeader() + "失效,请重新登录", HttpStatus.UNAUTHORIZED.value());
}
//设置userId到request里后续根据userId获取用户信息
long userId = Long.parseLong(claims.getSubject());
UserEntity user = userService.selectUserById(userId);
if (user.getStatus().equals(0)) {
return false;
}
request.setAttribute(USER_KEY, userId);
//记录用户最后一次调用接口的时间
UserEntity userEntity=new UserEntity();
UserEntity userEntity = new UserEntity();
userEntity.setUserId(userId);
userEntity.setOnLineTime(DateUtils.format(new Date()));
userService.updateById(userEntity);