userinfo获取不插入记录

This commit is contained in:
张松 2025-01-10 16:16:39 +08:00
parent 61303bf0d6
commit 591929d979
5 changed files with 18 additions and 4 deletions

View File

@ -183,7 +183,7 @@ public class AppController {
return Result.error("实名修改失败: 每月可修改次数已用完,请联系管理员"); return Result.error("实名修改失败: 每月可修改次数已用完,请联系管理员");
} }
AuthRespDTO resp = aliService.auth(certName, certNum, accountNo, mobile); AuthRespDTO resp = aliService.auth(certName, certNum, accountNo, mobile);
UserInfo userInfo = userInfoService.getByUserId(userId); UserInfo userInfo = userInfoService.getByUserIdOrSave(userId);
userInfo.setCertName(certName); userInfo.setCertName(certName);
userInfo.setCertNo(certNum); userInfo.setCertNo(certNum);
userInfo.setAccountNo(accountNo); userInfo.setAccountNo(accountNo);

View File

@ -11,6 +11,7 @@ import java.util.List;
* @createDate 2025-01-02 14:15:08 * @createDate 2025-01-02 14:15:08
*/ */
public interface UserInfoService extends IService<UserInfo> { public interface UserInfoService extends IService<UserInfo> {
UserInfo getByUserIdOrSave(long userId);
UserInfo getByUserId(long userId); UserInfo getByUserId(long userId);

View File

@ -22,7 +22,7 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
implements UserInfoService { implements UserInfoService {
@Override @Override
public UserInfo getByUserId(long userId) { public UserInfo getByUserIdOrSave(long userId) {
UserInfo userInfo = getOne(new LambdaQueryWrapper<UserInfo>() UserInfo userInfo = getOne(new LambdaQueryWrapper<UserInfo>()
.eq(UserInfo::getUserId, userId)); .eq(UserInfo::getUserId, userId));
if (userInfo == null) { if (userInfo == null) {
@ -33,6 +33,17 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
return userInfo; return userInfo;
} }
@Override
public UserInfo getByUserId(long userId) {
UserInfo userInfo = getOne(new LambdaQueryWrapper<UserInfo>()
.eq(UserInfo::getUserId, userId));
if (userInfo == null) {
userInfo = new UserInfo();
userInfo.setUserId(userId);
}
return userInfo;
}
@Override @Override
public boolean isAuth(long userId) { public boolean isAuth(long userId) {
UserInfo userInfo = getOne(new LambdaQueryWrapper<UserInfo>() UserInfo userInfo = getOne(new LambdaQueryWrapper<UserInfo>()

View File

@ -1670,7 +1670,7 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
throw new SqxException("用户信息不存在"); throw new SqxException("用户信息不存在");
} }
UserInfo userInfo = userInfoService.getByUserId(userId); UserInfo userInfo = userInfoService.getByUserIdOrSave(userId);
if (userInfo.getCertName() != null) { if (userInfo.getCertName() != null) {
throw new SqxException("此账号已认证"); throw new SqxException("此账号已认证");
} }
@ -1700,7 +1700,7 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
throw new SqxException("用户信息不存在"); throw new SqxException("用户信息不存在");
} }
UserInfo userInfo = userInfoService.getByUserId(userId); UserInfo userInfo = userInfoService.getByUserIdOrSave(userId);
if (StrUtil.isNotEmpty(userInfo.getCertName()) && StrUtil.isNotEmpty(userInfo.getAccountNo()) && StrUtil.isNotEmpty(userInfo.getMobile())) { if (StrUtil.isNotEmpty(userInfo.getCertName()) && StrUtil.isNotEmpty(userInfo.getAccountNo()) && StrUtil.isNotEmpty(userInfo.getMobile())) {
throw new SqxException("此账号已认证"); throw new SqxException("此账号已认证");
} }

View File

@ -261,6 +261,8 @@ public class TempOrdersTask {
.eq(InviteAchievement::getState, 1).select(InviteAchievement::getTargetUserId)).stream().map(InviteAchievement::getTargetUserId).collect(Collectors.toSet()); .eq(InviteAchievement::getState, 1).select(InviteAchievement::getTargetUserId)).stream().map(InviteAchievement::getTargetUserId).collect(Collectors.toSet());
int count = 0; int count = 0;
if (!byUserIdList.isEmpty()) { if (!byUserIdList.isEmpty()) {
List<UserInfo> list = userInfoService.list(new LambdaQueryWrapper<UserInfo>().in(UserInfo::getUserId, byUserIdList).isNotNull(UserInfo::getAccountNo).select(UserInfo::getCertNo));
System.out.println(list.stream().map(UserInfo::getCertNo).collect(Collectors.toSet()));
count = userInfoService.list(new LambdaQueryWrapper<UserInfo>().in(UserInfo::getUserId, byUserIdList).isNotNull(UserInfo::getAccountNo).select(UserInfo::getCertNo)) count = userInfoService.list(new LambdaQueryWrapper<UserInfo>().in(UserInfo::getUserId, byUserIdList).isNotNull(UserInfo::getAccountNo).select(UserInfo::getCertNo))
.stream().map(UserInfo::getCertNo).collect(Collectors.toSet()).size(); .stream().map(UserInfo::getCertNo).collect(Collectors.toSet()).size();
}else { }else {