|
|
@@ -141,6 +141,32 @@ public class UserProfileServiceImpl implements UserProfileService {
|
|
|
throw new RuntimeException("用户不存在");
|
|
|
}
|
|
|
|
|
|
+ // ⭐ 关键修复:gender 和 birthDate 存储在 users 表中,需要单独更新
|
|
|
+ boolean userTableUpdated = false;
|
|
|
+ if (userProfile.getGender() != null || userProfile.getBirthDate() != null) {
|
|
|
+ User userUpdate = new User();
|
|
|
+ userUpdate.setUserId(userProfile.getUserId());
|
|
|
+
|
|
|
+ if (userProfile.getGender() != null) {
|
|
|
+ userUpdate.setGender(userProfile.getGender());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (userProfile.getBirthDate() != null) {
|
|
|
+ // 将 Date 转换为 LocalDate
|
|
|
+ LocalDate birthLocalDate = userProfile.getBirthDate().toInstant()
|
|
|
+ .atZone(ZoneId.systemDefault())
|
|
|
+ .toLocalDate();
|
|
|
+ userUpdate.setBirthDate(birthLocalDate);
|
|
|
+ }
|
|
|
+
|
|
|
+ int userResult = userMapper.updateById(userUpdate);
|
|
|
+ userTableUpdated = userResult > 0;
|
|
|
+ System.out.println("✅ 更新users表 - 用户ID: " + userProfile.getUserId() +
|
|
|
+ ", gender: " + userProfile.getGender() +
|
|
|
+ ", birthDate: " + userProfile.getBirthDate() +
|
|
|
+ ", 影响行数: " + userResult);
|
|
|
+ }
|
|
|
+
|
|
|
// 1. 查询是否存在用户扩展信息
|
|
|
UserProfile existProfile = userProfileMapper.selectByUserId(userProfile.getUserId());
|
|
|
|
|
|
@@ -165,6 +191,14 @@ public class UserProfileServiceImpl implements UserProfileService {
|
|
|
// 存在则更新 - 创建完整的更新对象
|
|
|
userProfile.setProfileId(existProfile.getProfileId());
|
|
|
|
|
|
+ // ⭐ 关键修复:添加 gender 和 birthDate 的保护逻辑
|
|
|
+ if (userProfile.getGender() == null) {
|
|
|
+ userProfile.setGender(existProfile.getGender());
|
|
|
+ }
|
|
|
+ if (userProfile.getBirthDate() == null) {
|
|
|
+ userProfile.setBirthDate(existProfile.getBirthDate());
|
|
|
+ }
|
|
|
+
|
|
|
// 处理认证状态字段 - 只在没有传入值时保持原值
|
|
|
if (userProfile.getIsRealNameVerified() == null) {
|
|
|
userProfile.setIsRealNameVerified(existProfile.getIsRealNameVerified());
|
|
|
@@ -220,10 +254,11 @@ public class UserProfileServiceImpl implements UserProfileService {
|
|
|
|
|
|
// 只调用一次updateById,包含评分更新
|
|
|
result = userProfileMapper.updateById(userProfile);
|
|
|
- System.out.println("更新用户扩展信息 - 用户ID: " + userProfile.getUserId() + ", 更新后评分: " + score + ", 影响行数: " + result);
|
|
|
+ System.out.println("✅ 更新user_profile表 - 用户ID: " + userProfile.getUserId() + ", 更新后评分: " + score + ", 影响行数: " + result);
|
|
|
}
|
|
|
|
|
|
- return result > 0;
|
|
|
+ // 只要 users 表或 user_profile 表有一个更新成功就返回 true
|
|
|
+ return (result > 0) || userTableUpdated;
|
|
|
}
|
|
|
|
|
|
@Override
|