From 937f99a139bedbacdf15e25cfd55aa592f56082c Mon Sep 17 00:00:00 2001
From: longz <longzhaoz@qq.com>
Date: 星期二, 02 六月 2026 15:01:59 +0800
Subject: [PATCH] feat(appointment): 添加访客预约系统敏感词库功能
---
backend/src/main/java/com/sinata/appointment/service/MiniVisitorApplicationService.java | 31 +++++++++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/backend/src/main/java/com/sinata/appointment/service/MiniVisitorApplicationService.java b/backend/src/main/java/com/sinata/appointment/service/MiniVisitorApplicationService.java
index e4e4848..244cef7 100644
--- a/backend/src/main/java/com/sinata/appointment/service/MiniVisitorApplicationService.java
+++ b/backend/src/main/java/com/sinata/appointment/service/MiniVisitorApplicationService.java
@@ -1,6 +1,7 @@
package com.sinata.appointment.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.sinata.appointment.constants.AppointmentFieldCodes;
import com.sinata.appointment.constants.BizErrorCode;
import com.sinata.appointment.dto.MiniVisitorCreateRequest;
@@ -59,6 +60,7 @@
? SensitiveDataUtil.encryptIdCard(input.idCard())
: "");
row.setGender(input.gender() == null ? "" : input.gender());
+ row.setIsDefault(hasAnyActiveVisitor(current.getId()) ? 0 : 1);
mpVisitorMapper.insert(row);
}
@@ -87,6 +89,20 @@
mpVisitorMapper.updateById(row);
}
+ @Transactional(rollbackFor = Exception.class)
+ public void setDefault(Long id, String uuid) {
+ MpUser current = miniAuthApplicationService.currentMpUser();
+ MpVisitor row = loadOwnedVisitor(id, uuid, current.getId());
+ mpVisitorMapper.update(
+ null,
+ new LambdaUpdateWrapper<MpVisitor>()
+ .eq(MpVisitor::getMpUserId, current.getId())
+ .eq(MpVisitor::getDelFlag, 0)
+ .set(MpVisitor::getIsDefault, 0));
+ row.setIsDefault(1);
+ mpVisitorMapper.updateById(row);
+ }
+
public MiniVisitorDetailVo detail(Long id, String uuid) {
MpUser current = miniAuthApplicationService.currentMpUser();
MpVisitor row = loadOwnedVisitor(id, uuid, current.getId());
@@ -101,6 +117,7 @@
? SensitiveDataUtil.decryptIdCard(row.getIdCardCipher())
: "");
vo.setGender(row.getGender());
+ vo.setIsDefault(isDefault(row));
return vo;
}
@@ -112,6 +129,7 @@
new LambdaQueryWrapper<MpVisitor>()
.eq(MpVisitor::getMpUserId, current.getId())
.eq(MpVisitor::getDelFlag, 0)
+ .orderByDesc(MpVisitor::getIsDefault)
.orderByDesc(MpVisitor::getCreateTime)
.orderByDesc(MpVisitor::getId));
return rows.stream().map(row -> toListVo(row, requiredCodes)).collect(Collectors.toList());
@@ -130,10 +148,23 @@
vo.setIdCardMasked(null);
}
vo.setVisitorCompany(row.getVisitorCompany());
+ vo.setIsDefault(isDefault(row));
vo.setMissingFieldCodes(resolveMissingFieldCodes(row, requiredCodes));
return vo;
}
+ private boolean isDefault(MpVisitor row) {
+ return row != null && row.getIsDefault() != null && row.getIsDefault() == 1;
+ }
+
+ private boolean hasAnyActiveVisitor(Long mpUserId) {
+ return mpVisitorMapper.selectCount(
+ new LambdaQueryWrapper<MpVisitor>()
+ .eq(MpVisitor::getMpUserId, mpUserId)
+ .eq(MpVisitor::getDelFlag, 0))
+ > 0;
+ }
+
private List<String> resolveMissingFieldCodes(MpVisitor row, Set<String> requiredCodes) {
List<String> missing = new ArrayList<>();
for (String code : requiredCodes) {
--
Gitblit v1.7.1