refactor(user): 重构用户相关接口与实现
- 修改application.yaml中logic-not-delete-value为"null"
- 删除RoleController中无用的RoleResponse导入
- 修改RoleController的@GetMapping注解路径为/options
- UserController使用构造器注入替代@Autowired并添加@RequiredArgsConstructor
- UserController的@RequestMapping从/api/user改为/api/users
- UserController的获取用户列表接口路径从/all改为/并增加分页参数说明
- UserController新增根据ID获取用户信息接口GET /{id}
- UserController的重置用户密码接口路径从/setUserPassword改为/{userId}/password
- 删除UserController中已废弃的更新用户名接口/updateUsername
- UserController的获取当前用户信息接口路径从/profile改为/me
- UserController的更新用户信息接口路径从/profile改为/me
- UserController新增更新用户名接口PUT /me/username并标记为@Deprecated
- UserController的设置用户昵称接口路径改为/{userId}/nickname
- UserProfileService接口中的findUserWithRoles方法重命名为findUserWithRolesByUsername
- UserProfileService接口新增findUserWithRolesById方法定义
- UserProfileServiceImpl实现类中删除无用RoleResponse导入
- UserProfileServiceImpl中findUserWithRoles方法重命名为findUserWithRolesByUsername
- UserProfileServiceImpl中实现findUserWithRolesById方法逻辑并增加空值校验
This commit is contained in:
@@ -4,7 +4,6 @@ import cn.nopj.chaos_api.common.constants.ErrorCode;
|
||||
import cn.nopj.chaos_api.common.exceotion.BizException;
|
||||
import cn.nopj.chaos_api.domain.entity.User;
|
||||
import cn.nopj.chaos_api.dto.request.UserProfileUpdateRequest;
|
||||
import cn.nopj.chaos_api.dto.response.RoleResponse;
|
||||
import cn.nopj.chaos_api.dto.response.UserProfileResponse;
|
||||
import cn.nopj.chaos_api.mapper.UserMapper;
|
||||
import cn.nopj.chaos_api.service.UserProfileService;
|
||||
@@ -81,7 +80,7 @@ public class UserProfileServiceImpl implements UserProfileService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserProfileResponse findUserWithRoles(String username) {
|
||||
public UserProfileResponse findUserWithRolesByUsername(String username) {
|
||||
if (username == null || username.isEmpty()){
|
||||
throw new BizException(ErrorCode.USER_NOT_EXISTS);
|
||||
}
|
||||
@@ -160,8 +159,21 @@ public class UserProfileServiceImpl implements UserProfileService {
|
||||
return userPage.convert(UserProfileResponse::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserProfileResponse findUserWithRolesById(Long id) {
|
||||
|
||||
if (id == null){
|
||||
throw new BizException(ErrorCode.USER_ID_INVALID);
|
||||
}
|
||||
|
||||
User userWithRolesById = userMapper.findUserWithRolesById(id);
|
||||
|
||||
if (userWithRolesById == null){
|
||||
throw new BizException(ErrorCode.USER_NOT_EXISTS);
|
||||
}
|
||||
|
||||
return new UserProfileResponse(userWithRolesById);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user