修bug
This commit is contained in:
@@ -4,6 +4,7 @@ import com.bao.dating.anno.Log;
|
||||
import com.bao.dating.common.Result;
|
||||
import com.bao.dating.common.ResultCode;
|
||||
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.vo.UserInfoVO;
|
||||
import com.bao.dating.pojo.vo.UserLoginVO;
|
||||
@@ -91,7 +92,7 @@ public class UserController {
|
||||
*/
|
||||
@Log
|
||||
@PostMapping("/info/update")
|
||||
public Result<UserInfoVO> userInfoUpdate(@RequestBody UserInfoUpdateDTO userInfoUpdateDTO) {
|
||||
public Result<UserInfoVO> userInfoUpdate(@RequestBody UserInfoDTO userInfoUpdateDTO) {
|
||||
Long userId = UserContext.getUserId();
|
||||
userInfoUpdateDTO.setUserId(userId);
|
||||
UserInfoVO userInfoVO =userService.updateUserInfo(userInfoUpdateDTO);
|
||||
|
||||
@@ -77,7 +77,6 @@ public interface UserService {
|
||||
* @return 用户
|
||||
*/
|
||||
UserInfoDTO getUserInfoById(Long userId);
|
||||
UserInfoVO updateUserInfo(UserInfoUpdateDTO userInfoUpdateDTO);
|
||||
|
||||
void sendSmsCode(String phone);
|
||||
|
||||
|
||||
@@ -242,12 +242,12 @@ public class UserServiceImpl implements UserService {
|
||||
|
||||
/**
|
||||
* 更新用户信息
|
||||
* @param userInfoDTO
|
||||
* @return
|
||||
*
|
||||
* @param userInfoUpdateDTO 用户信息更新参数
|
||||
*/
|
||||
@Override
|
||||
public UserInfoVO updateUserInfo(UserInfoDTO userInfoDTO) {
|
||||
Long userId = userInfoDTO.getUserId();
|
||||
public UserInfoVO updateUserInfo(UserInfoDTO userInfoUpdateDTO) {
|
||||
Long userId = userInfoUpdateDTO.getUserId();
|
||||
User user = userMapper.selectByUserId(userId);
|
||||
if (user == null) {
|
||||
throw new RuntimeException("用户不存在");
|
||||
@@ -256,16 +256,16 @@ public class UserServiceImpl implements UserService {
|
||||
// 将需要审核的内容合并成一个文本,用于减少调用次数
|
||||
StringBuilder textBuilder = new StringBuilder();
|
||||
|
||||
if (userInfoDTO.getNickname() != null && !userInfoDTO.getNickname().isEmpty()) {
|
||||
textBuilder.append(userInfoDTO.getNickname()).append(" ");
|
||||
if (userInfoUpdateDTO.getNickname() != null && !userInfoUpdateDTO.getNickname().isEmpty()) {
|
||||
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(" ");
|
||||
}
|
||||
if (userInfoDTO.getSignature() != null && !userInfoDTO.getSignature().isEmpty()) {
|
||||
textBuilder.append(userInfoDTO.getSignature()).append(" ");
|
||||
if (userInfoUpdateDTO.getSignature() != null && !userInfoUpdateDTO.getSignature().isEmpty()) {
|
||||
textBuilder.append(userInfoUpdateDTO.getSignature()).append(" ");
|
||||
}
|
||||
// 文本审核
|
||||
if (textBuilder.length() > 0) {
|
||||
|
||||
Reference in New Issue
Block a user