用户状态

This commit is contained in:
wangw 2025-05-24 14:58:38 +08:00
parent f0ad5f19bd
commit 32b0b24945
2 changed files with 5 additions and 19 deletions

View File

@ -49,23 +49,6 @@ public class AppApiMethodAspect {
@Around("pkg()")
public Object around(ProceedingJoinPoint pjp) throws Throwable {
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
String token = request.getHeader("token");
if (StringUtils.isBlank(token)) {
Claims claims = jwtUtils.getClaimByToken(token);
if (claims != null && !jwtUtils.isTokenExpired(claims.getExpiration())) {
Long userId = Long.parseLong(claims.getSubject());
UserEntity userInfo = userService.selectUserById(userId);
if (userInfo == null) {
throw new CzgException("用户不存在");
} else if (userInfo.getStatus() == 0) {
throw new UserException("用户被拉黑", 701);
} else if (userInfo.getStatus() == 2) {
throw new UserException("用户被禁用", 702);
}
}
}
long start = System.currentTimeMillis();
//避免回填
Object[] args = pjp.getArgs();

View File

@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.sqx.common.exception.CzgException;
import com.sqx.common.exception.SqxException;
import com.sqx.common.exception.UserException;
import com.sqx.common.utils.DateUtils;
import com.sqx.common.utils.IPUtils;
import com.sqx.modules.app.annotation.Login;
@ -111,8 +112,10 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
if(user == null) {
throw new SqxException("会话失效,请重新登录", HttpStatus.UNAUTHORIZED.value());
}
if (user != null && user.getStatus().equals(0)) {
throw new CzgException("异常行为用户: {}" + user.getUserId());
if (user.getStatus() == 0) {
throw new UserException("用户被拉黑", 701);
} else if (user.getStatus() == 2) {
throw new UserException("用户被禁用", 702);
}
// 实名认证信息
UserInfo userInfo = userInfoService.getOne(new LambdaQueryWrapper<UserInfo>().eq(UserInfo::getUserId, user.getUserId()));