接口调整
This commit is contained in:
@@ -30,6 +30,7 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode MENU_ROUTE_KIND_INVALID = new ErrorCode(1_002_001_008, "路由类型不合法");
|
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_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_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 ==========
|
// ========== 角色模块 1-002-002-000 ==========
|
||||||
ErrorCode ROLE_NOT_EXISTS = new ErrorCode(1_002_002_000, "角色不存在");
|
ErrorCode ROLE_NOT_EXISTS = new ErrorCode(1_002_002_000, "角色不存在");
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ public class DictTypeController {
|
|||||||
@Operation(summary = "获得字典类型的分页列表")
|
@Operation(summary = "获得字典类型的分页列表")
|
||||||
@PreAuthorize("@ss.hasPermission('system:dict:query')")
|
@PreAuthorize("@ss.hasPermission('system:dict:query')")
|
||||||
public CommonResult<PageResult<DictTypeRespVO>> pageDictTypes(@Valid DictTypePageReqVO pageReqVO) {
|
public CommonResult<PageResult<DictTypeRespVO>> pageDictTypes(@Valid DictTypePageReqVO pageReqVO) {
|
||||||
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
PageResult<DictTypeDO> pageResult = dictTypeService.getDictTypePage(pageReqVO);
|
PageResult<DictTypeDO> pageResult = dictTypeService.getDictTypePage(pageReqVO);
|
||||||
return success(BeanUtils.toBean(pageResult, DictTypeRespVO.class));
|
return success(BeanUtils.toBean(pageResult, DictTypeRespVO.class));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import jakarta.validation.constraints.Size;
|
import jakarta.validation.constraints.Size;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@@ -23,6 +24,10 @@ public class DictTypePageReqVO extends PageParam {
|
|||||||
@Size(max = 100, message = "字典类型类型长度不能超过100个字符")
|
@Size(max = 100, message = "字典类型类型长度不能超过100个字符")
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
|
@Schema(description = "字典类型编码,兼容前端 code 查询参数", example = "sys_common_sex")
|
||||||
|
@Size(max = 100, message = "字典类型编码长度不能超过100个字符")
|
||||||
|
private String code;
|
||||||
|
|
||||||
@Schema(description = "展示状态,参见 CommonStatusEnum 枚举类", example = "1")
|
@Schema(description = "展示状态,参见 CommonStatusEnum 枚举类", example = "1")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
@@ -30,4 +35,8 @@ public class DictTypePageReqVO extends PageParam {
|
|||||||
@Schema(description = "创建时间")
|
@Schema(description = "创建时间")
|
||||||
private LocalDateTime[] createTime;
|
private LocalDateTime[] createTime;
|
||||||
|
|
||||||
|
public String getTypeKeyword() {
|
||||||
|
return StringUtils.hasText(code) ? code : type;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,10 +31,12 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
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.convertList;
|
||||||
import static com.njcn.rdms.framework.common.util.collection.CollectionUtils.convertSet;
|
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.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.dal.dataobject.permission.MenuDO.ID_ROOT;
|
||||||
|
import static com.njcn.rdms.module.system.enums.ErrorCodeConstants.MENU_ROUTE_NAME_DUPLICATE;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface AuthConvert {
|
public interface AuthConvert {
|
||||||
@@ -208,19 +210,19 @@ public interface AuthConvert {
|
|||||||
|
|
||||||
default Map<Long, String> buildRouteNameMap(List<MenuDO> menus, Map<Long, String> fullPathCache) {
|
default Map<Long, String> buildRouteNameMap(List<MenuDO> menus, Map<Long, String> fullPathCache) {
|
||||||
Map<Long, String> routeNameMap = new LinkedHashMap<>();
|
Map<Long, String> routeNameMap = new LinkedHashMap<>();
|
||||||
Set<String> usedNames = new HashSet<>();
|
Map<String, Long> usedNames = new LinkedHashMap<>();
|
||||||
menus.forEach(menu -> {
|
menus.forEach(menu -> {
|
||||||
String fullPath = fullPathCache.get(menu.getId());
|
String fullPath = fullPathCache.get(menu.getId());
|
||||||
String baseName = resolveBaseRouteName(menu, fullPath);
|
String baseName = resolveBaseRouteName(menu, fullPath);
|
||||||
if (StrUtil.isBlank(baseName)) {
|
if (StrUtil.isBlank(baseName)) {
|
||||||
baseName = "route_" + menu.getId();
|
baseName = "route_" + menu.getId();
|
||||||
}
|
}
|
||||||
String routeName = baseName;
|
Long conflictMenuId = usedNames.putIfAbsent(baseName, menu.getId());
|
||||||
if (usedNames.contains(routeName)) {
|
if (conflictMenuId != null) {
|
||||||
routeName = baseName + "_" + menu.getId();
|
throw exception(MENU_ROUTE_NAME_DUPLICATE,
|
||||||
|
StrUtil.format("{}(菜单 {} 与菜单 {})", baseName, conflictMenuId, menu.getId()));
|
||||||
}
|
}
|
||||||
usedNames.add(routeName);
|
routeNameMap.put(menu.getId(), baseName);
|
||||||
routeNameMap.put(menu.getId(), routeName);
|
|
||||||
});
|
});
|
||||||
return routeNameMap;
|
return routeNameMap;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.ibatis.annotations.Update;
|
import org.apache.ibatis.annotations.Update;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@@ -15,12 +16,22 @@ import java.time.LocalDateTime;
|
|||||||
public interface DictTypeMapper extends BaseMapperX<DictTypeDO> {
|
public interface DictTypeMapper extends BaseMapperX<DictTypeDO> {
|
||||||
|
|
||||||
default PageResult<DictTypeDO> selectPage(DictTypePageReqVO reqVO) {
|
default PageResult<DictTypeDO> selectPage(DictTypePageReqVO reqVO) {
|
||||||
return selectPage(reqVO, new LambdaQueryWrapperX<DictTypeDO>()
|
LambdaQueryWrapperX<DictTypeDO> queryWrapper = new LambdaQueryWrapperX<>();
|
||||||
.likeIfPresent(DictTypeDO::getName, reqVO.getName())
|
String typeKeyword = reqVO.getTypeKeyword();
|
||||||
.likeIfPresent(DictTypeDO::getType, reqVO.getType())
|
boolean hasName = StringUtils.hasText(reqVO.getName());
|
||||||
.eqIfPresent(DictTypeDO::getStatus, reqVO.getStatus())
|
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())
|
.betweenIfPresent(DictTypeDO::getCreateTime, reqVO.getCreateTime())
|
||||||
.orderByDesc(DictTypeDO::getId));
|
.orderByDesc(DictTypeDO::getId);
|
||||||
|
return selectPage(reqVO, queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
default DictTypeDO selectByType(String type) {
|
default DictTypeDO selectByType(String type) {
|
||||||
|
|||||||
Reference in New Issue
Block a user