diff --git a/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/auth/AuthController.java b/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/auth/AuthController.java index e1b6f0b..3c29493 100644 --- a/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/auth/AuthController.java +++ b/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/auth/AuthController.java @@ -108,7 +108,6 @@ public class AuthController { Set menuIds = permissionService.getRoleMenuListByRoleId(convertSet(roles, RoleDO::getId)); List menuList = menuService.getMenuList(menuIds); menuList = menuService.filterDisableMenus(menuList); - // 2. 拼接结果返回 return success(AuthConvert.INSTANCE.convert(user, roles, menuList)); } diff --git a/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/auth/vo/AuthPermissionInfoRespVO.java b/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/auth/vo/AuthPermissionInfoRespVO.java index fccfcfe..3fb08ee 100644 --- a/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/auth/vo/AuthPermissionInfoRespVO.java +++ b/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/auth/vo/AuthPermissionInfoRespVO.java @@ -1,5 +1,6 @@ package cd.casic.module.system.controller.admin.auth.vo; +import cd.casic.framework.commons.enums.CommonStatusEnum; import io.swagger.v3.oas.annotations.media.Schema; import lombok.AllArgsConstructor; import lombok.Builder; @@ -88,6 +89,34 @@ public class AuthPermissionInfoRespVO { @Schema(description = "是否总是显示", example = "false") private Boolean alwaysShow; + @Schema(description = "是否显示子菜单", example = "false") + private Boolean showChildren; + + @Schema(description = "当前激活目录", example = "/sys-conf/job") + private String currentActiveMenu; + + @Schema(description = "外部站点地址", example = "/sys-conf/job") + private String frameSrc; + /** + * 目录分组 + */ + @Schema(description = "目录分组", example = "3") + private String menuGroup; + + @Schema(description = "目录重定向", example = "/sys-conf/job") + private String redirect; + @Schema(description = "状态", example = "1") + private Integer status; + + @Schema(description = "isTag", example = "1") + private Boolean isTag; + @Schema(description = "tagDot", example = "1") + private Boolean tagDot; + @Schema(description = "tagType", example = "1") + private String tagType; + @Schema(description = "tagContent", example = "1") + private String tagContent; + /** * 子路由 */ diff --git a/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/dict/DictDataController.java b/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/dict/DictDataController.java index 0c1daa1..2cc5ba0 100644 --- a/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/dict/DictDataController.java +++ b/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/dict/DictDataController.java @@ -7,10 +7,7 @@ import cd.casic.framework.commons.pojo.PageParam; import cd.casic.framework.commons.pojo.PageResult; import cd.casic.framework.commons.util.object.BeanUtils; import cd.casic.framework.excel.excel.core.util.ExcelUtils; -import cd.casic.module.system.controller.admin.dict.vo.data.DictDataPageReqVO; -import cd.casic.module.system.controller.admin.dict.vo.data.DictDataRespVO; -import cd.casic.module.system.controller.admin.dict.vo.data.DictDataSaveReqVO; -import cd.casic.module.system.controller.admin.dict.vo.data.DictDataSimpleRespVO; +import cd.casic.module.system.controller.admin.dict.vo.data.*; import cd.casic.module.system.dal.dataobject.dict.DictDataDO; import cd.casic.module.system.service.dict.DictDataService; import io.swagger.v3.oas.annotations.Operation; @@ -101,4 +98,10 @@ public class DictDataController { BeanUtils.toBean(list, DictDataRespVO.class)); } + @GetMapping("/getDictDataTree") + @Operation(summary = "获取数据字典树") + public CommonResult> getDictDataTree() { + return success(dictDataService.getDictDataTree()); + } + } diff --git a/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/dict/vo/data/DictDataRespVO.java b/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/dict/vo/data/DictDataRespVO.java index 2f86981..6bd044e 100644 --- a/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/dict/vo/data/DictDataRespVO.java +++ b/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/dict/vo/data/DictDataRespVO.java @@ -2,6 +2,7 @@ package cd.casic.module.system.controller.admin.dict.vo.data; import cd.casic.framework.excel.excel.core.annotations.DictFormat; import cd.casic.framework.excel.excel.core.convert.DictConvert; +import cd.casic.module.system.dal.dataobject.dict.DictTypeDO; import cd.casic.module.system.enums.DictTypeConstants; import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import com.alibaba.excel.annotation.ExcelProperty; @@ -54,4 +55,5 @@ public class DictDataRespVO { @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "时间戳格式") private LocalDateTime createTime; + } diff --git a/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/dict/vo/data/DictDataTreeVO.java b/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/dict/vo/data/DictDataTreeVO.java new file mode 100644 index 0000000..12db994 --- /dev/null +++ b/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/dict/vo/data/DictDataTreeVO.java @@ -0,0 +1,26 @@ +package cd.casic.module.system.controller.admin.dict.vo.data; + +import cd.casic.module.system.controller.admin.dict.vo.type.DictTypeRespVO; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @author songqiang + * @date 2023-09-28 9:50 + * @description + */ +@Schema(description = "管理后台 - 字典树 Response VO") +@Data +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class DictDataTreeVO extends DictTypeRespVO { + + @Schema(description = "子节点") + private List children; +} diff --git a/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/dict/vo/type/DictTypePageReqVO.java b/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/dict/vo/type/DictTypePageReqVO.java index 62b3f07..5405853 100644 --- a/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/dict/vo/type/DictTypePageReqVO.java +++ b/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/dict/vo/type/DictTypePageReqVO.java @@ -32,4 +32,8 @@ public class DictTypePageReqVO extends PageParam { @Schema(description = "创建时间") private LocalDateTime[] createTime; + @Schema(description = "值类型类型,模糊匹配") + @Size(max = 128, message = "字典类型类型长度不能超过128个字符") + private String valueType; + } diff --git a/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/dict/vo/type/DictTypeRespVO.java b/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/dict/vo/type/DictTypeRespVO.java index a1ae714..bb7644a 100644 --- a/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/dict/vo/type/DictTypeRespVO.java +++ b/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/dict/vo/type/DictTypeRespVO.java @@ -40,4 +40,7 @@ public class DictTypeRespVO { @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "时间戳格式") private LocalDateTime createTime; + @Schema(description = "值类型", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + private String valueType; + } diff --git a/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/dict/vo/type/DictTypeSaveReqVO.java b/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/dict/vo/type/DictTypeSaveReqVO.java index 3ed3e60..77641b8 100644 --- a/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/dict/vo/type/DictTypeSaveReqVO.java +++ b/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/dict/vo/type/DictTypeSaveReqVO.java @@ -33,4 +33,7 @@ public class DictTypeSaveReqVO { @Schema(description = "备注", example = "快乐的备注") private String remark; + @Schema(description = "值类型", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + private String valueType; + } diff --git a/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/dict/vo/type/DictTypeSimpleRespVO.java b/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/dict/vo/type/DictTypeSimpleRespVO.java index 8f9e342..34b642c 100644 --- a/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/dict/vo/type/DictTypeSimpleRespVO.java +++ b/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/dict/vo/type/DictTypeSimpleRespVO.java @@ -18,4 +18,7 @@ public class DictTypeSimpleRespVO { @Schema(description = "字典类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "sys_common_sex") private String type; + @Schema(description = "值类型", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + private String valueType; + } diff --git a/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/permission/MenuController.java b/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/permission/MenuController.java index e72c45a..132a398 100644 --- a/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/permission/MenuController.java +++ b/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/permission/MenuController.java @@ -3,10 +3,7 @@ package cd.casic.module.system.controller.admin.permission; import cd.casic.framework.commons.enums.CommonStatusEnum; import cd.casic.framework.commons.pojo.CommonResult; import cd.casic.framework.commons.util.object.BeanUtils; -import cd.casic.module.system.controller.admin.permission.vo.menu.MenuListReqVO; -import cd.casic.module.system.controller.admin.permission.vo.menu.MenuRespVO; -import cd.casic.module.system.controller.admin.permission.vo.menu.MenuSaveVO; -import cd.casic.module.system.controller.admin.permission.vo.menu.MenuSimpleRespVO; +import cd.casic.module.system.controller.admin.permission.vo.menu.*; import cd.casic.module.system.dal.dataobject.permission.MenuDO; import cd.casic.module.system.service.permission.MenuService; import io.swagger.v3.oas.annotations.Operation; @@ -85,4 +82,15 @@ public class MenuController { return success(BeanUtils.toBean(menu, MenuRespVO.class)); } + @GetMapping("/getMenuTree") + @Operation(summary = "获取菜单树") + @PreAuthorize("@ss.hasPermission('system:menu:query')") + public CommonResult> getMenuTree() { + // 获得菜单列表,只要开启状态的 + MenuListReqVO reqVO = new MenuListReqVO(); + reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); + List list = menuService.getMenuListByTenant(reqVO); + return success(menuService.convertMenuTree(list)); + } + } diff --git a/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/permission/vo/menu/MenuRespVO.java b/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/permission/vo/menu/MenuRespVO.java index 8fd9140..a60d395 100644 --- a/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/permission/vo/menu/MenuRespVO.java +++ b/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/permission/vo/menu/MenuRespVO.java @@ -1,5 +1,6 @@ package cd.casic.module.system.controller.admin.permission.vo.menu; +import cd.casic.framework.commons.enums.CommonStatusEnum; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -69,4 +70,30 @@ public class MenuRespVO { @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "时间戳格式") private LocalDateTime createTime; + /** + * 目录分组 + */ + private String menuGroup; + /** + * 目录重定向 + */ + private String redirect; + + private Boolean showChildren; + /** + * 当前激活目录 + */ + private String currentActiveMenu; + /** + * 外部站点地址 + */ + private String frameSrc; + + + private Boolean isTag; + + private Boolean tagDot; + private String tagType; + private String tagContent; + } diff --git a/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/permission/vo/menu/MenuSaveVO.java b/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/permission/vo/menu/MenuSaveVO.java index d75a5f7..750af0b 100644 --- a/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/permission/vo/menu/MenuSaveVO.java +++ b/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/permission/vo/menu/MenuSaveVO.java @@ -64,4 +64,30 @@ public class MenuSaveVO { @Schema(description = "是否总是显示", example = "false") private Boolean alwaysShow; + /** + * 目录分组 + */ + private String menuGroup; + /** + * 目录重定向 + */ + private String redirect; + + private Boolean showChildren; + /** + * 当前激活目录 + */ + private String currentActiveMenu; + /** + * 外部站点地址 + */ + private String frameSrc; + + + private Boolean isTag; + + private Boolean tagDot; + private String tagType; + private String tagContent; + } diff --git a/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/permission/vo/menu/MenuTreeVO.java b/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/permission/vo/menu/MenuTreeVO.java new file mode 100644 index 0000000..12db769 --- /dev/null +++ b/modules/module-system-biz/src/main/java/cd/casic/module/system/controller/admin/permission/vo/menu/MenuTreeVO.java @@ -0,0 +1,105 @@ +package cd.casic.module.system.controller.admin.permission.vo.menu; + +import cd.casic.framework.commons.enums.CommonStatusEnum; +import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @author songqiang + * @date 2023-11-08 11:40 + * @description + */ +@Schema(description = "管理后台 - 菜单树 Response VO") +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_EMPTY) +public class MenuTreeVO { + + @Schema(description = "菜单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + private Long id; + + @Schema(description = "菜单名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") + private String name; + + @Schema(description = "父菜单 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + private Long parentId; + + @Schema(description = "类型,参见 MenuTypeEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private Integer type; + + @Schema(description = "路由地址", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "/system") + private String path; + + @Schema(description = "菜单图标", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "system") + private String icon; + + @Schema(description = "组件路径", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "system/user/index") + private String component; + + @Schema(description = "组件名", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "SystemUser") + private String componentName; + + @Schema(description = "子菜单", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + private List child; + + + /** + * 目录分组 + */ + private String menuGroup; + /** + * 目录重定向 + */ + private String redirect; + /** + * 状态 + * + * 枚举 {@link CommonStatusEnum} + */ + private Integer status; + /** + * 是否可见 + * + * 只有菜单、目录使用 + * 当设置为 true 时,该菜单不会展示在侧边栏,但是路由还是存在。例如说,一些独立的编辑页面 /edit/1024 等等 + */ + private Boolean visible; + /** + * 是否缓存 + * + * 只有菜单、目录使用,否使用 Vue 路由的 keep-alive 特性 + * 注意:如果开启缓存,则必须填写 {@link #componentName} 属性,否则无法缓存 + */ + private Boolean keepAlive; + /** + * 是否总是显示 + * + * 如果为 false 时,当该菜单只有一个子菜单时,不展示自己,直接展示子菜单 + */ + private Boolean alwaysShow; + /** + * 是否显示子菜单 + */ + private Boolean showChildren; + /** + * 当前激活目录 + */ + private String currentActiveMenu; + /** + * 外部站点地址 + */ + private String frameSrc; + + + private Boolean isTag; + + private Boolean tagDot; + private String tagType; + private String tagContent; +} diff --git a/modules/module-system-biz/src/main/java/cd/casic/module/system/convert/dict/DictDataConvert.java b/modules/module-system-biz/src/main/java/cd/casic/module/system/convert/dict/DictDataConvert.java new file mode 100644 index 0000000..bf5da56 --- /dev/null +++ b/modules/module-system-biz/src/main/java/cd/casic/module/system/convert/dict/DictDataConvert.java @@ -0,0 +1,33 @@ +package cd.casic.module.system.convert.dict; + +//import cd.casic.commons.pojo.PageResult; +import cd.casic.module.system.api.dict.dto.DictDataRespDTO; +import cd.casic.module.system.controller.admin.dict.vo.data.*; +import cd.casic.module.system.dal.dataobject.dict.DictDataDO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +@Mapper +public interface DictDataConvert { + + DictDataConvert INSTANCE = Mappers.getMapper(DictDataConvert.class); + + List convertList(List list); + + DictDataRespVO convert(DictDataDO bean); + +// PageResult convertPage(PageResult page); +// +// DictDataDO convert(DictDataUpdateReqVO bean); +// +// DictDataDO convert(DictDataCreateReqVO bean); +// +// List convertList02(List bean); + + DictDataRespDTO convert02(DictDataDO bean); + + List convertList03(List bean); + +} diff --git a/modules/module-system-biz/src/main/java/cd/casic/module/system/convert/dict/DictTypeConvert.java b/modules/module-system-biz/src/main/java/cd/casic/module/system/convert/dict/DictTypeConvert.java new file mode 100644 index 0000000..8ca5d14 --- /dev/null +++ b/modules/module-system-biz/src/main/java/cd/casic/module/system/convert/dict/DictTypeConvert.java @@ -0,0 +1,31 @@ +package cd.casic.module.system.convert.dict; + +//import cd.casic.commons.pojo.PageResult; +import cd.casic.module.system.controller.admin.dict.vo.data.DictDataTreeVO; +import cd.casic.module.system.controller.admin.dict.vo.type.*; +import cd.casic.module.system.dal.dataobject.dict.DictTypeDO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +@Mapper +public interface DictTypeConvert { + + DictTypeConvert INSTANCE = Mappers.getMapper(DictTypeConvert.class); + +// PageResult convertPage(PageResult bean); +// +// DictTypeRespVO convert(DictTypeDO bean); +// +// DictTypeDO convert(DictTypeCreateReqVO bean); +// +// DictTypeDO convert(DictTypeUpdateReqVO bean); +// +// List convertList(List list); +// +// List convertList02(List list); + + List convertList03(List list); + +} diff --git a/modules/module-system-biz/src/main/java/cd/casic/module/system/dal/dataobject/dict/DictTypeDO.java b/modules/module-system-biz/src/main/java/cd/casic/module/system/dal/dataobject/dict/DictTypeDO.java index ca5903d..50d7d44 100644 --- a/modules/module-system-biz/src/main/java/cd/casic/module/system/dal/dataobject/dict/DictTypeDO.java +++ b/modules/module-system-biz/src/main/java/cd/casic/module/system/dal/dataobject/dict/DictTypeDO.java @@ -55,4 +55,9 @@ public class DictTypeDO extends BaseDO { */ private LocalDateTime deletedTime; + /** + * 值类型 + */ + private String valueType; + } diff --git a/modules/module-system-biz/src/main/java/cd/casic/module/system/dal/dataobject/permission/MenuDO.java b/modules/module-system-biz/src/main/java/cd/casic/module/system/dal/dataobject/permission/MenuDO.java index f2dde16..de510e9 100644 --- a/modules/module-system-biz/src/main/java/cd/casic/module/system/dal/dataobject/permission/MenuDO.java +++ b/modules/module-system-biz/src/main/java/cd/casic/module/system/dal/dataobject/permission/MenuDO.java @@ -79,6 +79,14 @@ public class MenuDO extends BaseDO { * 组件名 */ private String componentName; + /** + * 目录分组 + */ + private String menuGroup; + /** + * 目录重定向 + */ + private String redirect; /** * 状态 * @@ -105,5 +113,23 @@ public class MenuDO extends BaseDO { * 如果为 false 时,当该菜单只有一个子菜单时,不展示自己,直接展示子菜单 */ private Boolean alwaysShow; + /** + * 是否显示子菜单 + */ + private Boolean showChildren; + /** + * 当前激活目录 + */ + private String currentActiveMenu; + /** + * 外部站点地址 + */ + private String frameSrc; + + private Boolean isTag; + + private Boolean tagDot; + private String tagType; + private String tagContent; } diff --git a/modules/module-system-biz/src/main/java/cd/casic/module/system/service/dict/DictDataService.java b/modules/module-system-biz/src/main/java/cd/casic/module/system/service/dict/DictDataService.java index d7d4a25..8107158 100644 --- a/modules/module-system-biz/src/main/java/cd/casic/module/system/service/dict/DictDataService.java +++ b/modules/module-system-biz/src/main/java/cd/casic/module/system/service/dict/DictDataService.java @@ -3,6 +3,7 @@ package cd.casic.module.system.service.dict; import cd.casic.framework.commons.pojo.PageResult; import cd.casic.module.system.controller.admin.dict.vo.data.DictDataPageReqVO; import cd.casic.module.system.controller.admin.dict.vo.data.DictDataSaveReqVO; +import cd.casic.module.system.controller.admin.dict.vo.data.DictDataTreeVO; import cd.casic.module.system.dal.dataobject.dict.DictDataDO; import org.springframework.lang.Nullable; @@ -107,4 +108,12 @@ public interface DictDataService { */ List getDictDataListByDictType(String dictType); + /** + * 生成数据字典树 + * @author songqiang + * @date 2023-09-28 9:57 + * @return 字典树 + */ + List getDictDataTree(); + } diff --git a/modules/module-system-biz/src/main/java/cd/casic/module/system/service/dict/DictDataServiceImpl.java b/modules/module-system-biz/src/main/java/cd/casic/module/system/service/dict/DictDataServiceImpl.java index 0ef37b5..42419ec 100644 --- a/modules/module-system-biz/src/main/java/cd/casic/module/system/service/dict/DictDataServiceImpl.java +++ b/modules/module-system-biz/src/main/java/cd/casic/module/system/service/dict/DictDataServiceImpl.java @@ -1,5 +1,9 @@ package cd.casic.module.system.service.dict; +import cd.casic.module.system.controller.admin.dict.vo.data.DictDataRespVO; +import cd.casic.module.system.controller.admin.dict.vo.data.DictDataTreeVO; +import cd.casic.module.system.convert.dict.DictDataConvert; +import cd.casic.module.system.convert.dict.DictTypeConvert; import cn.hutool.core.collection.CollUtil; import cd.casic.framework.commons.enums.CommonStatusEnum; import cd.casic.framework.commons.pojo.PageResult; @@ -15,10 +19,8 @@ import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; -import java.util.Collection; -import java.util.Comparator; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.stream.Collectors; import static cd.casic.framework.commons.exception.util.ServiceExceptionUtil.exception; import static cd.casic.module.system.enums.ErrorCodeConstants.*; @@ -176,4 +178,27 @@ public class DictDataServiceImpl implements DictDataService { return list; } + @Override + public List getDictDataTree() { + + List dictTypeList = dictTypeService.getDictTypeList(); + List dataTree = DictTypeConvert.INSTANCE.convertList03(dictTypeList); + if (CollUtil.isEmpty(dataTree)) { + return Collections.emptyList(); + } + List dictDataList = dictDataMapper.selectList(); + dictDataList.sort(COMPARATOR_TYPE_AND_SORT); + List list = DictDataConvert.INSTANCE.convertList03(dictDataList); + if (CollUtil.isEmpty(list)) { + return dataTree; + } + + Map> map = list.stream().collect(Collectors.groupingBy(DictDataRespVO::getDictType)); + for (DictDataTreeVO treeVO : dataTree) { + treeVO.setChildren(map.get(treeVO.getType())); + } + + return dataTree; + } + } diff --git a/modules/module-system-biz/src/main/java/cd/casic/module/system/service/permission/MenuService.java b/modules/module-system-biz/src/main/java/cd/casic/module/system/service/permission/MenuService.java index eeb33c3..3e57e9b 100644 --- a/modules/module-system-biz/src/main/java/cd/casic/module/system/service/permission/MenuService.java +++ b/modules/module-system-biz/src/main/java/cd/casic/module/system/service/permission/MenuService.java @@ -3,6 +3,7 @@ package cd.casic.module.system.service.permission; import cd.casic.module.system.controller.admin.permission.vo.menu.MenuListReqVO; import cd.casic.module.system.controller.admin.permission.vo.menu.MenuSaveVO; +import cd.casic.module.system.controller.admin.permission.vo.menu.MenuTreeVO; import cd.casic.module.system.dal.dataobject.permission.MenuDO; import java.util.Collection; @@ -93,4 +94,13 @@ public interface MenuService { */ List getMenuList(Collection ids); + /** + * 生成菜单树 + * @author songqiang + * @date 2023-11-08 14:08 + * @param list + * @return + */ + List convertMenuTree(List list); + } diff --git a/modules/module-system-biz/src/main/java/cd/casic/module/system/service/permission/MenuServiceImpl.java b/modules/module-system-biz/src/main/java/cd/casic/module/system/service/permission/MenuServiceImpl.java index 4c72628..fb39ef8 100644 --- a/modules/module-system-biz/src/main/java/cd/casic/module/system/service/permission/MenuServiceImpl.java +++ b/modules/module-system-biz/src/main/java/cd/casic/module/system/service/permission/MenuServiceImpl.java @@ -1,5 +1,6 @@ package cd.casic.module.system.service.permission; +import cd.casic.module.system.controller.admin.permission.vo.menu.MenuTreeVO; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjUtil; import cd.casic.framework.commons.enums.CommonStatusEnum; @@ -22,6 +23,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.*; +import java.util.stream.Collectors; import static cd.casic.framework.commons.exception.util.ServiceExceptionUtil.exception; import static cd.casic.framework.commons.util.collection.CollectionUtils.convertList; @@ -259,4 +261,54 @@ public class MenuServiceImpl implements MenuService { } } + @Override + public List convertMenuTree(List list) { + + if (CollUtil.isEmpty(list)) { + return Collections.emptyList(); + } + + list.sort(Comparator.comparing(MenuDO::getSort)); + List menuTreeList = new ArrayList<>(list.size()); + for (MenuDO menuDO : list) { + menuTreeList.add(menuDOToMenuTreeVO(menuDO)); + } + + List parentList = menuTreeList.stream() + .filter(i -> i.getParentId() == 0L) + .collect(Collectors.toList()); + + parentList.forEach(i -> findChild(i, menuTreeList)); + + return parentList; + } + + private void findChild(MenuTreeVO menuTreeVO, List list) { + List collect = list.stream() + .filter(i -> i.getParentId().equals(menuTreeVO.getId())) + .collect(Collectors.toList()); + + menuTreeVO.setChild(collect); + collect.forEach(i -> findChild(i, list)); + } + + private MenuTreeVO menuDOToMenuTreeVO(MenuDO menuDO) { + if ( menuDO == null ) { + return null; + } + + MenuTreeVO menuTreeVO = new MenuTreeVO(); +// menuTreeVO.setId( menuDO.getId() ); +// menuTreeVO.setName( menuDO.getName() ); +// menuTreeVO.setParentId( menuDO.getParentId() ); +// menuTreeVO.setType( menuDO.getType() ); +// menuTreeVO.setPath( menuDO.getPath() ); +// menuTreeVO.setIcon( menuDO.getIcon() ); +// menuTreeVO.setComponent( menuDO.getComponent() ); +// menuTreeVO.setComponentName( menuDO.getComponentName() ); + BeanUtils.copyProperties(menuDO, menuTreeVO); + + return menuTreeVO; + } + }