优化用户查询的接口

This commit is contained in:
jishenghua
2025-08-14 23:03:55 +08:00
parent 90c411a5fd
commit fbda24da30
2 changed files with 7 additions and 2 deletions

View File

@@ -65,7 +65,12 @@ public class UserService {
public User getUser(long id)throws Exception {
User result=null;
try{
result=userMapper.selectByPrimaryKey(id);
//先校验是否登录,然后才能查询用户数据
HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
Long userId = this.getUserId(request);
if(userId!=null) {
result = userMapper.selectByPrimaryKey(id);
}
}catch(Exception e){
JshException.readFail(logger, e);
}