接口调整

This commit is contained in:
2026-03-23 21:50:55 +08:00
parent 95e6f1faea
commit 0eddb928e2
5 changed files with 35 additions and 11 deletions

View File

@@ -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, "角色不存在");

View File

@@ -75,6 +75,7 @@ public class DictTypeController {
@Operation(summary = "获得字典类型的分页列表")
@PreAuthorize("@ss.hasPermission('system:dict:query')")
public CommonResult<PageResult<DictTypeRespVO>> pageDictTypes(@Valid DictTypePageReqVO pageReqVO) {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
PageResult<DictTypeDO> pageResult = dictTypeService.getDictTypePage(pageReqVO);
return success(BeanUtils.toBean(pageResult, DictTypeRespVO.class));
}

View File

@@ -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;
}
}

View File

@@ -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<Long, String> buildRouteNameMap(List<MenuDO> menus, Map<Long, String> fullPathCache) {
Map<Long, String> routeNameMap = new LinkedHashMap<>();
Set<String> usedNames = new HashSet<>();
Map<String, Long> 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;
}

View File

@@ -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<DictTypeDO> {
default PageResult<DictTypeDO> selectPage(DictTypePageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<DictTypeDO>()
.likeIfPresent(DictTypeDO::getName, reqVO.getName())
.likeIfPresent(DictTypeDO::getType, reqVO.getType())
.eqIfPresent(DictTypeDO::getStatus, reqVO.getStatus())
LambdaQueryWrapperX<DictTypeDO> 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) {