feat:jiekou

This commit is contained in:
xiang
2026-03-21 20:38:38 +08:00
parent 4ea369b33d
commit ace15206ec
5 changed files with 54 additions and 1 deletions

View File

@@ -43,4 +43,7 @@ public interface XUserService {
LoginResp refresh(RefreshRequest request);
Boolean updateStatus(Long id, Integer status);
Long getUserId(String token);
Long getTenantId(String token);
}

View File

@@ -413,4 +413,26 @@ public class XUserServiceImpl implements XUserService {
user.setStatus(status);
return userMapper.update(user) > 0;
}
@Override
public Long getUserId(String token) {
try {
Jwt jwt = jwtDecoder.decode(token);
Object userId = jwt.getClaim("userId");
return (long) userId;
} catch (Exception e) {
throw new BusinessException(Code01UserErrorCode.TOKEN_NOT_VALID);
}
}
@Override
public Long getTenantId(String token) {
try {
Jwt jwt = jwtDecoder.decode(token);
Object userId = jwt.getClaim("tenantId");
return (long) userId;
} catch (Exception e) {
throw new BusinessException(Code01UserErrorCode.TOKEN_NOT_VALID);
}
}
}