From 82a8bc62d5b9d5d607f6952329952b17eda2f0a0 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期一, 14 九月 2026 15:44:34 +0800
Subject: [PATCH] update
---
backend/src/main/java/com/tourguide/modules/user/service/GuideUserService.java | 25 ++++++++++++++++++-------
1 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/backend/src/main/java/com/tourguide/modules/user/service/GuideUserService.java b/backend/src/main/java/com/tourguide/modules/user/service/GuideUserService.java
index 8b4039c..7ed8357 100644
--- a/backend/src/main/java/com/tourguide/modules/user/service/GuideUserService.java
+++ b/backend/src/main/java/com/tourguide/modules/user/service/GuideUserService.java
@@ -41,6 +41,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -128,6 +129,7 @@
public GuideUser findByPhone(String phone) {
return userMapper.selectOne(new LambdaQueryWrapper<GuideUser>()
.and(query -> query.eq(GuideUser::getUsername, phone).or().eq(GuideUser::getMobile, phone))
+ .orderByDesc(GuideUser::getId)
.last("LIMIT 1"));
}
@@ -282,6 +284,10 @@
}
String username = application.getMobile().trim();
GuideUser existingUser = findByPhone(username);
+ if (existingUser != null && existingUser.getStatus() == STATUS_CANCELLED) {
+ anonymizeCancelledGuide(existingUser);
+ existingUser = null;
+ }
if (existingUser != null && (existingUser.getStatus() == null || existingUser.getStatus() != 2)) {
throw new BusinessException(409, "该手机号已存在导游账号");
}
@@ -305,6 +311,10 @@
@Transactional
public GuideUserResponse createPendingFromApplication(GuideApplication application) {
GuideUser user = findByPhone(application.getMobile());
+ if (user != null && user.getStatus() == STATUS_CANCELLED) {
+ anonymizeCancelledGuide(user);
+ user = null;
+ }
if (user == null) {
user = new GuideUser();
user.setUsername(application.getMobile().trim());
@@ -316,18 +326,19 @@
throw new BusinessException(409, "该手机号已存在导游账号");
}
ensureUniqueGuideIdentity(application, user);
- if (user.getStatus() == STATUS_CANCELLED) {
- user.setStatus(STATUS_PENDING);
- user.setAutoDisableWhitelisted(0);
- user.setPremiumEnabled(0);
- user.setAutoDisabled(0);
- user.setDeleted(0);
- }
copyApplicationProfile(user, application);
if (user.getId() == null) userMapper.insert(user); else userMapper.updateById(user);
return GuideUserResponse.from(user);
}
+ private void anonymizeCancelledGuide(GuideUser user) {
+ user.setUsername("deleted_" + UUID.randomUUID().toString().replace("-", "").substring(0, 24));
+ user.setMobile(null);
+ user.setCertificateNo(null);
+ user.setIdCardNo(null);
+ userMapper.updateById(user);
+ }
+
private void ensureUniqueGuideIdentity(GuideApplication application, GuideUser existingUser) {
if (StringUtils.hasText(application.getCertificateNo())
&& userMapper.selectCount(new LambdaQueryWrapper<GuideUser>()
--
Gitblit v1.7.1