feat: 实现刷新token逻辑
This commit is contained in:
@@ -28,5 +28,10 @@ public class UserController {
|
||||
return Results.success(userAuthDTO);
|
||||
}
|
||||
|
||||
@GetMapping("/inner/get-by-userid")
|
||||
public Result<UserAuthRespDTO> getUserById(@RequestParam("userId") String userid) {
|
||||
UserAuthRespDTO userAuthRespDTO = userService.findAuthInfoByUserId(userid);
|
||||
return Results.success(userAuthRespDTO);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,4 +22,9 @@ public interface UserService extends IService<User> {
|
||||
* @return
|
||||
*/
|
||||
UserAuthRespDTO findAuthInfoByUserAccount(String userAccount);
|
||||
|
||||
/**
|
||||
* 根据用户id查找用户认证信息
|
||||
*/
|
||||
UserAuthRespDTO findAuthInfoByUserId(String userId);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
@Override
|
||||
public Long userRegister(UserRegisterRequestDTO request) {
|
||||
UserAuthRespDTO authInfoByUserAccount = findAuthInfoByUserAccount(request.getUserAccount());
|
||||
if(authInfoByUserAccount!=null){
|
||||
if (authInfoByUserAccount != null) {
|
||||
throw new ClientException("重复创建用户");
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
// 使用 BCrypt 加密密码
|
||||
Date now = new Date();
|
||||
String salt = BCrypt.gensalt();
|
||||
String encryptPassword = BCrypt.hashpw(request.getUserPassword(),salt);
|
||||
String encryptPassword = BCrypt.hashpw(request.getUserPassword(), salt);
|
||||
User user = new User().setUserAccount(request.getUserAccount()).setUserPassword(encryptPassword)
|
||||
.setUserRole("user").setCreateTime(now).setUpdateTime(now);
|
||||
try {
|
||||
@@ -59,10 +59,22 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
public UserAuthRespDTO findAuthInfoByUserAccount(String userAccount) {
|
||||
User one = this.lambdaQuery().eq(User::getUserAccount, userAccount).one();
|
||||
UserAuthRespDTO userAuthDTO = new UserAuthRespDTO();
|
||||
if(one!=null){
|
||||
if (one != null) {
|
||||
BeanUtils.copyProperties(one, userAuthDTO);
|
||||
return userAuthDTO;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserAuthRespDTO findAuthInfoByUserId(String userId) {
|
||||
User one = this.lambdaQuery().eq(User::getId, userId).one();
|
||||
UserAuthRespDTO userAuthDTO = new UserAuthRespDTO();
|
||||
if (one != null) {
|
||||
BeanUtils.copyProperties(one, userAuthDTO);
|
||||
return userAuthDTO;
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user