This commit is contained in:
KilLze
2026-01-11 00:28:23 +08:00
parent 2189575659
commit 7a8a03510c
3 changed files with 12 additions and 12 deletions

View File

@@ -4,6 +4,7 @@ import com.bao.dating.anno.Log;
import com.bao.dating.common.Result; import com.bao.dating.common.Result;
import com.bao.dating.common.ResultCode; import com.bao.dating.common.ResultCode;
import com.bao.dating.context.UserContext; import com.bao.dating.context.UserContext;
import com.bao.dating.pojo.dto.UserInfoDTO;
import com.bao.dating.pojo.dto.UserLoginDTO; import com.bao.dating.pojo.dto.UserLoginDTO;
import com.bao.dating.pojo.vo.UserInfoVO; import com.bao.dating.pojo.vo.UserInfoVO;
import com.bao.dating.pojo.vo.UserLoginVO; import com.bao.dating.pojo.vo.UserLoginVO;
@@ -91,7 +92,7 @@ public class UserController {
*/ */
@Log @Log
@PostMapping("/info/update") @PostMapping("/info/update")
public Result<UserInfoVO> userInfoUpdate(@RequestBody UserInfoUpdateDTO userInfoUpdateDTO) { public Result<UserInfoVO> userInfoUpdate(@RequestBody UserInfoDTO userInfoUpdateDTO) {
Long userId = UserContext.getUserId(); Long userId = UserContext.getUserId();
userInfoUpdateDTO.setUserId(userId); userInfoUpdateDTO.setUserId(userId);
UserInfoVO userInfoVO =userService.updateUserInfo(userInfoUpdateDTO); UserInfoVO userInfoVO =userService.updateUserInfo(userInfoUpdateDTO);

View File

@@ -77,7 +77,6 @@ public interface UserService {
* @return 用户 * @return 用户
*/ */
UserInfoDTO getUserInfoById(Long userId); UserInfoDTO getUserInfoById(Long userId);
UserInfoVO updateUserInfo(UserInfoUpdateDTO userInfoUpdateDTO);
void sendSmsCode(String phone); void sendSmsCode(String phone);

View File

@@ -242,12 +242,12 @@ public class UserServiceImpl implements UserService {
/** /**
* 更新用户信息 * 更新用户信息
* @param userInfoDTO *
* @return * @param userInfoUpdateDTO 用户信息更新参数
*/ */
@Override @Override
public UserInfoVO updateUserInfo(UserInfoDTO userInfoDTO) { public UserInfoVO updateUserInfo(UserInfoDTO userInfoUpdateDTO) {
Long userId = userInfoDTO.getUserId(); Long userId = userInfoUpdateDTO.getUserId();
User user = userMapper.selectByUserId(userId); User user = userMapper.selectByUserId(userId);
if (user == null) { if (user == null) {
throw new RuntimeException("用户不存在"); throw new RuntimeException("用户不存在");
@@ -256,16 +256,16 @@ public class UserServiceImpl implements UserService {
// 将需要审核的内容合并成一个文本,用于减少调用次数 // 将需要审核的内容合并成一个文本,用于减少调用次数
StringBuilder textBuilder = new StringBuilder(); StringBuilder textBuilder = new StringBuilder();
if (userInfoDTO.getNickname() != null && !userInfoDTO.getNickname().isEmpty()) { if (userInfoUpdateDTO.getNickname() != null && !userInfoUpdateDTO.getNickname().isEmpty()) {
textBuilder.append(userInfoDTO.getNickname()).append(" "); textBuilder.append(userInfoUpdateDTO.getNickname()).append(" ");
} }
if (userInfoDTO.getHobbies() != null && !userInfoDTO.getHobbies().isEmpty()) { if (userInfoUpdateDTO.getHobbies() != null && !userInfoUpdateDTO.getHobbies().isEmpty()) {
// 将爱好列表转换为字符串,用空格分隔 // 将爱好列表转换为字符串,用空格分隔
String hobbiesStr = String.join(" ", userInfoDTO.getHobbies()); String hobbiesStr = String.join(" ", userInfoUpdateDTO.getHobbies());
textBuilder.append(hobbiesStr).append(" "); textBuilder.append(hobbiesStr).append(" ");
} }
if (userInfoDTO.getSignature() != null && !userInfoDTO.getSignature().isEmpty()) { if (userInfoUpdateDTO.getSignature() != null && !userInfoUpdateDTO.getSignature().isEmpty()) {
textBuilder.append(userInfoDTO.getSignature()).append(" "); textBuilder.append(userInfoUpdateDTO.getSignature()).append(" ");
} }
// 文本审核 // 文本审核
if (textBuilder.length() > 0) { if (textBuilder.length() > 0) {