liujie
2026-09-14 15defa991fcd30b9fa60bab17d2230b5929bf2a2
backend/src/main/java/com/tourguide/modules/user/service/GuideAccountService.java
@@ -7,6 +7,7 @@
import com.tourguide.modules.order.mapper.TourOrderMapper;
import com.tourguide.modules.user.domain.ClientType;
import com.tourguide.modules.user.entity.GuideUser;
import com.tourguide.modules.user.mapper.GuideApplicationMapper;
import com.tourguide.modules.user.mapper.GuideUserMapper;
import com.tourguide.security.JwtTokenService;
import com.tourguide.security.TokenPayload;
@@ -14,16 +15,21 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.UUID;
@Service
public class GuideAccountService {
    private final GuideUserMapper guideUserMapper;
    private final GuideApplicationMapper guideApplicationMapper;
    private final TourOrderMapper tourOrderMapper;
    private final JwtTokenService jwtTokenService;
    private final TokenSessionService tokenSessionService;
    public GuideAccountService(GuideUserMapper guideUserMapper, TourOrderMapper tourOrderMapper,
    public GuideAccountService(GuideUserMapper guideUserMapper, GuideApplicationMapper guideApplicationMapper,
                               TourOrderMapper tourOrderMapper,
                               JwtTokenService jwtTokenService, TokenSessionService tokenSessionService) {
        this.guideUserMapper = guideUserMapper;
        this.guideApplicationMapper = guideApplicationMapper;
        this.tourOrderMapper = tourOrderMapper;
        this.jwtTokenService = jwtTokenService;
        this.tokenSessionService = tokenSessionService;
@@ -47,8 +53,19 @@
        if (user == null) {
            throw new BusinessException(404, "导游用户不存在");
        }
        String idCardNo = user.getIdCardNo();
        if (idCardNo != null && !idCardNo.trim().isEmpty()) {
            guideApplicationMapper.clearIdentityByIdCard(idCardNo);
        }
        user.setUsername("deleted_" + UUID.randomUUID().toString().replace("-", "").substring(0, 24));
        user.setMobile(null);
        user.setCertificateNo(null);
        user.setIdCardNo(null);
        user.setIdCardFrontUrl(null);
        user.setIdCardBackUrl(null);
        user.setStatus(GuideUserService.STATUS_CANCELLED);
        user.setAutoDisableWhitelisted(0);
        user.setAutoDisabled(0);
        guideUserMapper.updateById(user);
        tokenSessionService.remove(payload);
    }