优化手机验证码注册 user_id异常的问题

This commit is contained in:
2025-08-21 19:05:20 +08:00
parent 66d039b507
commit f0cffe3e12
3 changed files with 56 additions and 1 deletions

View File

@@ -56,8 +56,10 @@ public class UserService implements UserDetailsService {
// 2. 检查手机号是否已注册
if (userRepository.existsByPhone(phone)) {
User user = userRepository.findByPhone(phone).get();
user.setUserId(deviceId);
user.setNewUser(false);
user.setDeviceId(deviceId);
user.setLastLoginTime(createTime);
user.setUpdateTime(createTime);
return user;
} else {
// 3. 创建新用户
@@ -116,4 +118,11 @@ public class UserService implements UserDetailsService {
return userRepository.findUserByUserId(userId).
orElseThrow(() -> new UsernameNotFoundException("User not found with userId: " + userId));
}
// public boolean updateUser(User user) {
// if (!userRepository.existsByUserId(user.getUserId())) {
// return false;
// }
// return userRepository.updateUser(user);
// }
}