feat(user): implement user profile management functionality
- Add user nickname update endpoint with validation - Introduce user profile update endpoint supporting nickname and password changes - Create UserProfileResponse DTO with nickname field - Add SetUserNicknameRequest DTO for nickname updates - Implement UserProfileUpdateRequest DTO for profile modifications - Refactor UserService to UserProfileService with enhanced capabilities - Update UserMapper to include nickname in result mapping - Add new error codes for nickname and profile update failures - Modify CORS configuration to allow requests from localhost:5173 - Remove obsolete AppConfig RestTemplate bean definition - Rename UserinfoResponse to UserProfileResponse for consistency - Adjust controller endpoints to use updated service and DTOs - Add transactional support for user profile updates - Improve error handling for user-related operations
This commit is contained in:
@@ -1,53 +0,0 @@
|
||||
package cn.nopj.chaos_api.service;
|
||||
|
||||
import cn.nopj.chaos_api.dto.response.UserinfoResponse;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户信息服务
|
||||
*
|
||||
* @author nopj
|
||||
*/
|
||||
public interface UserInfoService {
|
||||
|
||||
/**
|
||||
* 设置用户密码
|
||||
*
|
||||
* @param id 用户id
|
||||
* @param password 密码
|
||||
*/
|
||||
void setUserPassword(Long id, String password);
|
||||
|
||||
/**
|
||||
* 获取所有用户信息
|
||||
*
|
||||
* @return 所有用户信息
|
||||
*/
|
||||
List<UserinfoResponse> getAllUsers();
|
||||
|
||||
/**
|
||||
* 设置用户密码
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param password 密码
|
||||
*/
|
||||
void setUserPassword(@Pattern(regexp = "^[0-9]+$", message = "用户id格式错误") String userId, @Pattern(regexp = "^.{8,16}$", message = "密码长度需为8-16位") String password);
|
||||
|
||||
/**
|
||||
* 更新用户名
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param newUsername 新用户名
|
||||
*/
|
||||
void updateUsername(String username, String newUsername);
|
||||
|
||||
/**
|
||||
* 根据用户名查询用户信息
|
||||
*
|
||||
* @param username 用户名
|
||||
* @return 用户信息
|
||||
*/
|
||||
UserinfoResponse findUserWithRoles(String username);
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package cn.nopj.chaos_api.service;
|
||||
|
||||
import cn.nopj.chaos_api.dto.request.UserProfileUpdateRequest;
|
||||
import cn.nopj.chaos_api.dto.response.UserProfileResponse;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户信息服务
|
||||
*
|
||||
* @author nopj
|
||||
*/
|
||||
public interface UserProfileServcie {
|
||||
|
||||
/**
|
||||
* 设置用户密码
|
||||
*
|
||||
* @param id 用户id
|
||||
* @param password 密码
|
||||
*/
|
||||
void setUserPassword(Long id, String password);
|
||||
|
||||
/**
|
||||
* 获取所有用户信息
|
||||
*
|
||||
* @return 所有用户信息
|
||||
*/
|
||||
List<UserProfileResponse> getAllUsers();
|
||||
|
||||
/**
|
||||
* 设置用户密码
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param password 密码
|
||||
*/
|
||||
void setUserPassword(@Pattern(regexp = "^[0-9]+$", message = "用户id格式错误") String userId, @Pattern(regexp = "^.{8,16}$", message = "密码长度需为8-16位") String password);
|
||||
|
||||
/**
|
||||
* 更新用户名
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param newUsername 新用户名
|
||||
*/
|
||||
void updateUsername(String username, String newUsername);
|
||||
|
||||
/**
|
||||
* 根据用户名查询用户信息
|
||||
*
|
||||
* @param username 用户名
|
||||
* @return 用户信息
|
||||
*/
|
||||
UserProfileResponse findUserWithRoles(String username);
|
||||
|
||||
/**
|
||||
* 设置用户昵称
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param nickname 昵称
|
||||
* @return 处理结果
|
||||
*/
|
||||
UserProfileResponse setUserNickname(@NotBlank(message = "用户账号不能为空") String username, @NotBlank(message = "昵称不能为空") String nickname);
|
||||
|
||||
/**
|
||||
* 批量设置用户昵称
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param nickname 昵称
|
||||
* @return 处理结果
|
||||
*/
|
||||
UserProfileResponse setUserNickname(@NotBlank(message = "用户ID不能为空") Long userId, @NotBlank(message = "昵称不能为空") String nickname);
|
||||
|
||||
|
||||
/**
|
||||
* 更新用户信息
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param request 用户信息
|
||||
* @return 处理结果
|
||||
*/
|
||||
UserProfileResponse updateUserProfile(String username, UserProfileUpdateRequest request);
|
||||
}
|
||||
Reference in New Issue
Block a user