diff --git a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/controller/MenuManagementController.java b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/controller/MenuManagementController.java index c1ca515..1c7c59e 100644 --- a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/controller/MenuManagementController.java +++ b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/controller/MenuManagementController.java @@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import xyz.zhouxy.plusone.system.application.query.params.MenuQueryParams; import xyz.zhouxy.plusone.system.application.service.MenuManagementService; import xyz.zhouxy.plusone.system.application.service.command.CreateMenuCommand; import xyz.zhouxy.plusone.system.application.service.command.UpdateMenuCommand; @@ -66,7 +67,14 @@ public class MenuManagementController { public RestfulResult findById(@PathVariable("id") Long id) { adminAuthLogic.checkPermission("sys-menu-details"); var result = service.findById(id); - return RestfulResult.success("查询成功", result); + return success("查询成功", result); + } + + @GetMapping + public RestfulResult queryMenuTree(MenuQueryParams queryParams) { + adminAuthLogic.checkPermission("sys-menu-query"); + var result = service.queryMenuTree(queryParams); + return success("查询成功", result); } @GetMapping("queryByAccountId") diff --git a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/query/MenuQueries.java b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/query/MenuQueries.java new file mode 100644 index 0000000..33a62d2 --- /dev/null +++ b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/query/MenuQueries.java @@ -0,0 +1,22 @@ +package xyz.zhouxy.plusone.system.application.query; + +import java.util.List; + +import org.springframework.stereotype.Component; + +import xyz.zhouxy.plusone.system.application.query.params.MenuQueryParams; +import xyz.zhouxy.plusone.system.application.query.result.MenuViewObject; + +/** + * + * + * @author ZhouXY + */ +@Component +public class MenuQueries { + + public List queryMenuTree(MenuQueryParams queryParams) { + return null; + } + +} diff --git a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/query/PermissionQueries.java b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/query/PermissionQueries.java deleted file mode 100644 index 4de7330..0000000 --- a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/query/PermissionQueries.java +++ /dev/null @@ -1,10 +0,0 @@ -package xyz.zhouxy.plusone.system.application.query; - -/** - * - * - * @author ZhouXY - */ -public interface PermissionQueries { - // TODO【添加】 权限信息查询器 -} diff --git a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/query/params/MenuQueryParams.java b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/query/params/MenuQueryParams.java new file mode 100644 index 0000000..e691338 --- /dev/null +++ b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/query/params/MenuQueryParams.java @@ -0,0 +1,18 @@ +package xyz.zhouxy.plusone.system.application.query.params; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import xyz.zhouxy.plusone.constant.EntityStatus; + +@ToString +public class MenuQueryParams { + private @Getter @Setter String name; + private @Getter @Setter String path; + private @Getter @Setter String title; + private @Getter @Setter Boolean hidden; + private @Getter @Setter EntityStatus status; + private @Getter @Setter String component; + private @Getter @Setter Boolean cache; + private @Getter @Setter String resource; +} diff --git a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/query/result/MenuViewObject.java b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/query/result/MenuViewObject.java index 316eafe..e2f732f 100644 --- a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/query/result/MenuViewObject.java +++ b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/query/result/MenuViewObject.java @@ -25,60 +25,28 @@ import xyz.zhouxy.plusone.system.domain.model.menu.Menu.MenuType; @JsonInclude(JsonInclude.Include.NON_NULL) public class MenuViewObject implements IWithOrderNumber { - @Getter - @Setter - Integer type; + private @Getter @Setter Integer type; - @Getter - @Setter - String typeName; + private @Getter @Setter String typeName; - @Getter - @Setter - Long id; - @Getter - @Setter - Long parentId; + private @Getter @Setter Long id; + private @Getter @Setter Long parentId; - @Getter - @Setter - String name; + private @Getter @Setter String name; // 若 type 为 MENU_ITEM 且 path 以 http:// 或 https:// 开头则被识别为外链 - @Getter - @Setter - String path; - @Getter - @Setter - String title; - @Getter - @Setter - String icon; - @Getter - @Setter - boolean hidden; - @Getter - @Setter - int orderNumber; - @Getter - @Setter - Integer status; - @Getter - @Setter - String remarks; + private @Getter @Setter String path; + private @Getter @Setter String title; + private @Getter @Setter String icon; + private @Getter @Setter boolean hidden; + private @Getter @Setter int orderNumber; + private @Getter @Setter Integer status; + private @Getter @Setter String remarks; // MENU_ITEM - @Getter - @Setter - String component; - @Getter - @Setter - Boolean cache; - @Getter - @Setter - String resource; - @Getter - @Setter - List actions; + private @Getter @Setter String component; + private @Getter @Setter Boolean cache; + private @Getter @Setter String resource; + private @Getter @Setter List actions; // MENU_LIST List children; diff --git a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/service/MenuManagementService.java b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/service/MenuManagementService.java index b8b07d4..ef57775 100644 --- a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/service/MenuManagementService.java +++ b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/service/MenuManagementService.java @@ -17,6 +17,8 @@ import xyz.zhouxy.plusone.constant.EntityStatus; import xyz.zhouxy.plusone.domain.IWithOrderNumber; import xyz.zhouxy.plusone.exception.DataNotExistException; import xyz.zhouxy.plusone.system.application.exception.UnsupportedMenuTypeException; +import xyz.zhouxy.plusone.system.application.query.MenuQueries; +import xyz.zhouxy.plusone.system.application.query.params.MenuQueryParams; import xyz.zhouxy.plusone.system.application.query.result.MenuViewObject; import xyz.zhouxy.plusone.system.application.service.command.CreateMenuCommand; import xyz.zhouxy.plusone.system.application.service.command.UpdateMenuCommand; @@ -36,10 +38,12 @@ public class MenuManagementService { private final MenuService menuService; private final MenuRepository menuRepository; + private final MenuQueries menuQueries; - MenuManagementService(MenuService roleRepository, MenuRepository menuRepository) { - this.menuService = roleRepository; + MenuManagementService(MenuService menuService, MenuRepository menuRepository, MenuQueries menuQueries) { + this.menuService = menuService; this.menuRepository = menuRepository; + this.menuQueries = menuQueries; } // ==================== create ==================== @@ -123,6 +127,11 @@ public class MenuManagementService { return MenuViewObject.of(menu.orElseThrow(DataNotExistException::new)); } + @Transactional(propagation = Propagation.SUPPORTS) + public List queryMenuTree(MenuQueryParams queryParams) { + return menuQueries.queryMenuTree(queryParams); + } + @Transactional(propagation = Propagation.SUPPORTS) public List queryByAccountId(Long accountId) { var menus = menuService.queryAllMenuListByAccountId(accountId);