修复V4目录搜索与幂等审计

This commit is contained in:
andy
2026-07-19 23:44:59 +07:00
parent f2c2616ab0
commit 739fccd955
5 changed files with 184 additions and 13 deletions

View File

@@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
import org.springframework.stereotype.Repository;
@@ -87,14 +88,16 @@ public class MybatisReservationV4CatalogRepository implements ReservationV4Catal
String keyword,
int pageNum,
int pageSize) {
String normalizedKeyword = trimToNull(keyword);
String normalizedCodeKeyword = normalizeCode(normalizedKeyword);
LambdaQueryWrapper<ReservationCatalogAccountEntity> query = Wrappers.<ReservationCatalogAccountEntity>lambdaQuery()
.eq(ReservationCatalogAccountEntity::getHotelId, hotelId)
.eq(ReservationCatalogAccountEntity::getStatus, ReservationV4CatalogStatus.ACTIVE.name())
.isNull(ReservationCatalogAccountEntity::getLogicDeletedAt)
.and(trimToNull(keyword) != null, wrapper -> wrapper
.like(ReservationCatalogAccountEntity::getAccountCode, trimToNull(keyword))
.and(normalizedKeyword != null, wrapper -> wrapper
.like(ReservationCatalogAccountEntity::getAccountCode, normalizedCodeKeyword)
.or()
.like(ReservationCatalogAccountEntity::getAccountName, trimToNull(keyword)))
.like(ReservationCatalogAccountEntity::getAccountName, normalizedKeyword))
.orderByAsc(ReservationCatalogAccountEntity::getAccountCode)
.orderByAsc(ReservationCatalogAccountEntity::getId);
Page<ReservationCatalogAccountEntity> page = accountMapper.selectPage(Page.of(pageNum, pageSize), query);
@@ -114,15 +117,17 @@ public class MybatisReservationV4CatalogRepository implements ReservationV4Catal
String keyword,
int pageNum,
int pageSize) {
String normalizedKeyword = trimToNull(keyword);
String normalizedCodeKeyword = normalizeCode(normalizedKeyword);
LambdaQueryWrapper<ReservationCatalogCodeEntity> query = Wrappers.<ReservationCatalogCodeEntity>lambdaQuery()
.eq(ReservationCatalogCodeEntity::getHotelId, hotelId)
.eq(ReservationCatalogCodeEntity::getCatalogType, catalogType)
.eq(ReservationCatalogCodeEntity::getStatus, ReservationV4CatalogStatus.ACTIVE.name())
.isNull(ReservationCatalogCodeEntity::getLogicDeletedAt)
.and(trimToNull(keyword) != null, wrapper -> wrapper
.like(ReservationCatalogCodeEntity::getCode, trimToNull(keyword))
.and(normalizedKeyword != null, wrapper -> wrapper
.like(ReservationCatalogCodeEntity::getCode, normalizedCodeKeyword)
.or()
.like(ReservationCatalogCodeEntity::getDisplayName, trimToNull(keyword)))
.like(ReservationCatalogCodeEntity::getDisplayName, normalizedKeyword))
.orderByAsc(ReservationCatalogCodeEntity::getSortOrder)
.orderByAsc(ReservationCatalogCodeEntity::getCode)
.orderByAsc(ReservationCatalogCodeEntity::getId);
@@ -144,13 +149,14 @@ public class MybatisReservationV4CatalogRepository implements ReservationV4Catal
int pageNum,
int pageSize) {
String normalizedKeyword = trimToNull(keyword);
String normalizedCodeKeyword = normalizeCode(normalizedKeyword);
String normalizedStatus = trimToNull(status);
LambdaQueryWrapper<ReservationCatalogAccountEntity> query = Wrappers.<ReservationCatalogAccountEntity>lambdaQuery()
.eq(ReservationCatalogAccountEntity::getHotelId, hotelId)
.eq(normalizedStatus != null, ReservationCatalogAccountEntity::getStatus, normalizedStatus)
.isNull(ReservationCatalogAccountEntity::getLogicDeletedAt)
.and(normalizedKeyword != null, wrapper -> wrapper
.like(ReservationCatalogAccountEntity::getAccountCode, normalizedKeyword)
.like(ReservationCatalogAccountEntity::getAccountCode, normalizedCodeKeyword)
.or()
.like(ReservationCatalogAccountEntity::getAccountName, normalizedKeyword))
.orderByAsc(ReservationCatalogAccountEntity::getAccountCode)
@@ -174,6 +180,7 @@ public class MybatisReservationV4CatalogRepository implements ReservationV4Catal
int pageNum,
int pageSize) {
String normalizedKeyword = trimToNull(keyword);
String normalizedCodeKeyword = normalizeCode(normalizedKeyword);
String normalizedStatus = trimToNull(status);
LambdaQueryWrapper<ReservationCatalogCodeEntity> query = Wrappers.<ReservationCatalogCodeEntity>lambdaQuery()
.eq(ReservationCatalogCodeEntity::getHotelId, hotelId)
@@ -181,7 +188,7 @@ public class MybatisReservationV4CatalogRepository implements ReservationV4Catal
.eq(normalizedStatus != null, ReservationCatalogCodeEntity::getStatus, normalizedStatus)
.isNull(ReservationCatalogCodeEntity::getLogicDeletedAt)
.and(normalizedKeyword != null, wrapper -> wrapper
.like(ReservationCatalogCodeEntity::getCode, normalizedKeyword)
.like(ReservationCatalogCodeEntity::getCode, normalizedCodeKeyword)
.or()
.like(ReservationCatalogCodeEntity::getDisplayName, normalizedKeyword))
.orderByAsc(ReservationCatalogCodeEntity::getSortOrder)
@@ -433,4 +440,9 @@ public class MybatisReservationV4CatalogRepository implements ReservationV4Catal
}
return value.trim();
}
private String normalizeCode(String value) {
String normalized = trimToNull(value);
return normalized == null ? null : normalized.toUpperCase(Locale.ROOT);
}
}