套餐设置套餐管理完善

This commit is contained in:
2026-02-03 14:03:07 +08:00
parent 3acf8ad50a
commit 3d31b3482a
4 changed files with 136 additions and 80 deletions

View File

@@ -69,7 +69,9 @@ public class InspectionTypeController extends BaseController {
// 验证code字段是否唯一
QueryWrapper<InspectionType> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("code", inspectionType.getCode());
queryWrapper.eq("code", inspectionType.getCode())
// 只在“有效(valid_flag=1)”范围内判重;逻辑删除(valid_flag=0)的不阻止复用编码
.eq("valid_flag", 1);
// 查询是否存在相同编码的记录
List<InspectionType> existingRecords = inspectionTypeService.list(queryWrapper);
@@ -86,7 +88,8 @@ public class InspectionTypeController extends BaseController {
return transactionTemplate.execute(status -> {
// 再次检查,防止并发问题
QueryWrapper<InspectionType> checkWrapper = new QueryWrapper<>();
checkWrapper.eq("code", inspectionType.getCode());
checkWrapper.eq("code", inspectionType.getCode())
.eq("valid_flag", 1);
List<InspectionType> finalCheck = inspectionTypeService.list(checkWrapper);
if (!finalCheck.isEmpty()) {
return AjaxResult.error("检验类型编码已存在");
@@ -123,7 +126,8 @@ public class InspectionTypeController extends BaseController {
// 验证code字段是否唯一排除自身
QueryWrapper<InspectionType> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("code", inspectionType.getCode())
.ne("id", inspectionType.getId());
.ne("id", inspectionType.getId())
.eq("valid_flag", 1);
if (inspectionTypeService.count(queryWrapper) > 0) {
return AjaxResult.error("检验类型编码已存在");
}