From 0eddb928e21031da3b8e7da5c5a0f1a2877afaff Mon Sep 17 00:00:00 2001 From: hongawen <83944980@qq.com> Date: Mon, 23 Mar 2026 21:50:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/enums/ErrorCodeConstants.java | 1 + .../admin/dict/DictTypeController.java | 1 + .../admin/dict/vo/type/DictTypePageReqVO.java | 9 ++++++++ .../system/convert/auth/AuthConvert.java | 14 +++++++------ .../system/dal/mysql/dict/DictTypeMapper.java | 21 ++++++++++++++----- 5 files changed, 35 insertions(+), 11 deletions(-) diff --git a/rdms-system/rdms-system-api/src/main/java/com/njcn/rdms/module/system/enums/ErrorCodeConstants.java b/rdms-system/rdms-system-api/src/main/java/com/njcn/rdms/module/system/enums/ErrorCodeConstants.java index 265e383..a95198d 100644 --- a/rdms-system/rdms-system-api/src/main/java/com/njcn/rdms/module/system/enums/ErrorCodeConstants.java +++ b/rdms-system/rdms-system-api/src/main/java/com/njcn/rdms/module/system/enums/ErrorCodeConstants.java @@ -30,6 +30,7 @@ public interface ErrorCodeConstants { ErrorCode MENU_ROUTE_KIND_INVALID = new ErrorCode(1_002_001_008, "路由类型不合法"); ErrorCode MENU_ROUTE_PROPS_JSON_INVALID = new ErrorCode(1_002_001_009, "路由 props JSON 不合法"); ErrorCode MENU_ROUTE_IFRAME_URL_REQUIRED = new ErrorCode(1_002_001_010, "iframe 路由必须配置 props.url"); + ErrorCode MENU_ROUTE_NAME_DUPLICATE = new ErrorCode(1_002_001_011, "路由名重复,请检查菜单数据:{}"); // ========== 角色模块 1-002-002-000 ========== ErrorCode ROLE_NOT_EXISTS = new ErrorCode(1_002_002_000, "角色不存在"); diff --git a/rdms-system/rdms-system-boot/src/main/java/com/njcn/rdms/module/system/controller/admin/dict/DictTypeController.java b/rdms-system/rdms-system-boot/src/main/java/com/njcn/rdms/module/system/controller/admin/dict/DictTypeController.java index 87e75db..4dbcc50 100644 --- a/rdms-system/rdms-system-boot/src/main/java/com/njcn/rdms/module/system/controller/admin/dict/DictTypeController.java +++ b/rdms-system/rdms-system-boot/src/main/java/com/njcn/rdms/module/system/controller/admin/dict/DictTypeController.java @@ -75,6 +75,7 @@ public class DictTypeController { @Operation(summary = "获得字典类型的分页列表") @PreAuthorize("@ss.hasPermission('system:dict:query')") public CommonResult> pageDictTypes(@Valid DictTypePageReqVO pageReqVO) { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); PageResult pageResult = dictTypeService.getDictTypePage(pageReqVO); return success(BeanUtils.toBean(pageResult, DictTypeRespVO.class)); } diff --git a/rdms-system/rdms-system-boot/src/main/java/com/njcn/rdms/module/system/controller/admin/dict/vo/type/DictTypePageReqVO.java b/rdms-system/rdms-system-boot/src/main/java/com/njcn/rdms/module/system/controller/admin/dict/vo/type/DictTypePageReqVO.java index 4ef1026..6b913ac 100644 --- a/rdms-system/rdms-system-boot/src/main/java/com/njcn/rdms/module/system/controller/admin/dict/vo/type/DictTypePageReqVO.java +++ b/rdms-system/rdms-system-boot/src/main/java/com/njcn/rdms/module/system/controller/admin/dict/vo/type/DictTypePageReqVO.java @@ -5,6 +5,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.util.StringUtils; import jakarta.validation.constraints.Size; import java.time.LocalDateTime; @@ -23,6 +24,10 @@ public class DictTypePageReqVO extends PageParam { @Size(max = 100, message = "字典类型类型长度不能超过100个字符") private String type; + @Schema(description = "字典类型编码,兼容前端 code 查询参数", example = "sys_common_sex") + @Size(max = 100, message = "字典类型编码长度不能超过100个字符") + private String code; + @Schema(description = "展示状态,参见 CommonStatusEnum 枚举类", example = "1") private Integer status; @@ -30,4 +35,8 @@ public class DictTypePageReqVO extends PageParam { @Schema(description = "创建时间") private LocalDateTime[] createTime; + public String getTypeKeyword() { + return StringUtils.hasText(code) ? code : type; + } + } diff --git a/rdms-system/rdms-system-boot/src/main/java/com/njcn/rdms/module/system/convert/auth/AuthConvert.java b/rdms-system/rdms-system-boot/src/main/java/com/njcn/rdms/module/system/convert/auth/AuthConvert.java index fb75993..9d5a7a7 100644 --- a/rdms-system/rdms-system-boot/src/main/java/com/njcn/rdms/module/system/convert/auth/AuthConvert.java +++ b/rdms-system/rdms-system-boot/src/main/java/com/njcn/rdms/module/system/convert/auth/AuthConvert.java @@ -31,10 +31,12 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import static com.njcn.rdms.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.njcn.rdms.framework.common.util.collection.CollectionUtils.convertList; import static com.njcn.rdms.framework.common.util.collection.CollectionUtils.convertSet; import static com.njcn.rdms.framework.common.util.collection.CollectionUtils.filterList; import static com.njcn.rdms.module.system.dal.dataobject.permission.MenuDO.ID_ROOT; +import static com.njcn.rdms.module.system.enums.ErrorCodeConstants.MENU_ROUTE_NAME_DUPLICATE; @Mapper public interface AuthConvert { @@ -208,19 +210,19 @@ public interface AuthConvert { default Map buildRouteNameMap(List menus, Map fullPathCache) { Map routeNameMap = new LinkedHashMap<>(); - Set usedNames = new HashSet<>(); + Map usedNames = new LinkedHashMap<>(); menus.forEach(menu -> { String fullPath = fullPathCache.get(menu.getId()); String baseName = resolveBaseRouteName(menu, fullPath); if (StrUtil.isBlank(baseName)) { baseName = "route_" + menu.getId(); } - String routeName = baseName; - if (usedNames.contains(routeName)) { - routeName = baseName + "_" + menu.getId(); + Long conflictMenuId = usedNames.putIfAbsent(baseName, menu.getId()); + if (conflictMenuId != null) { + throw exception(MENU_ROUTE_NAME_DUPLICATE, + StrUtil.format("{}(菜单 {} 与菜单 {})", baseName, conflictMenuId, menu.getId())); } - usedNames.add(routeName); - routeNameMap.put(menu.getId(), routeName); + routeNameMap.put(menu.getId(), baseName); }); return routeNameMap; } diff --git a/rdms-system/rdms-system-boot/src/main/java/com/njcn/rdms/module/system/dal/mysql/dict/DictTypeMapper.java b/rdms-system/rdms-system-boot/src/main/java/com/njcn/rdms/module/system/dal/mysql/dict/DictTypeMapper.java index 9a6e5d5..855bed7 100644 --- a/rdms-system/rdms-system-boot/src/main/java/com/njcn/rdms/module/system/dal/mysql/dict/DictTypeMapper.java +++ b/rdms-system/rdms-system-boot/src/main/java/com/njcn/rdms/module/system/dal/mysql/dict/DictTypeMapper.java @@ -8,6 +8,7 @@ import com.njcn.rdms.module.system.dal.dataobject.dict.DictTypeDO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Update; +import org.springframework.util.StringUtils; import java.time.LocalDateTime; @@ -15,12 +16,22 @@ import java.time.LocalDateTime; public interface DictTypeMapper extends BaseMapperX { default PageResult selectPage(DictTypePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(DictTypeDO::getName, reqVO.getName()) - .likeIfPresent(DictTypeDO::getType, reqVO.getType()) - .eqIfPresent(DictTypeDO::getStatus, reqVO.getStatus()) + LambdaQueryWrapperX queryWrapper = new LambdaQueryWrapperX<>(); + String typeKeyword = reqVO.getTypeKeyword(); + boolean hasName = StringUtils.hasText(reqVO.getName()); + boolean hasType = StringUtils.hasText(typeKeyword); + if (hasName && hasType) { + queryWrapper.and(wrapper -> wrapper.like(DictTypeDO::getName, reqVO.getName()) + .or() + .like(DictTypeDO::getType, typeKeyword)); + } else { + queryWrapper.likeIfPresent(DictTypeDO::getName, reqVO.getName()) + .likeIfPresent(DictTypeDO::getType, typeKeyword); + } + queryWrapper.eqIfPresent(DictTypeDO::getStatus, reqVO.getStatus()) .betweenIfPresent(DictTypeDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(DictTypeDO::getId)); + .orderByDesc(DictTypeDO::getId); + return selectPage(reqVO, queryWrapper); } default DictTypeDO selectByType(String type) {