From 61a340b47be7786d2fd9c71448decb7046cb05f8 Mon Sep 17 00:00:00 2001 From: zch Date: Mon, 18 Aug 2025 15:45:09 +0800 Subject: [PATCH] =?UTF-8?q?feat(portal):=20=E6=A0=91=E5=BD=A2=E7=BB=93?= =?UTF-8?q?=E6=9E=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 HwWebMenu 类的父类从 BaseEntity 改为 TreeEntity- 移除 HwWebMenu 类中的 children 属性 - 修改 HwWebMenu 类中的 webMenuType 属性类型 - 在 API 中添加 selectMenuTree 方法 - 在控制器中添加 selectMenuTree 方法 - 在服务接口和实现类中添加 selectMenuTree 方法 - 更新 Mapper XML 中的 SQL 语句 --- .../controller/HwWebMenuController.java | 8 ++ .../com/ruoyi/portal/domain/HwWebMenu.java | 88 +++++++------------ .../portal/service/IHwWebMenuService.java | 7 ++ .../service/impl/HwWebMenuServiceImpl.java | 10 +++ .../mapper/portal/HwWebMenuMapper.xml | 26 +++--- ruoyi-ui/src/api/portal/hwWebMenu.js | 8 ++ 6 files changed, 78 insertions(+), 69 deletions(-) diff --git a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/controller/HwWebMenuController.java b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/controller/HwWebMenuController.java index cb57b5d..f2eec13 100644 --- a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/controller/HwWebMenuController.java +++ b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/controller/HwWebMenuController.java @@ -100,4 +100,12 @@ public class HwWebMenuController extends BaseController { return toAjax(hwWebMenuService.deleteHwWebMenuByWebMenuIds(webMenuIds)); } + + /** + * 获取菜单树列表 + */ + @GetMapping("/selectMenuTree") + public AjaxResult selectMenuTree(HwWebMenu hwWebMenu){ + return success(hwWebMenuService.selectMenuTree(hwWebMenu)); + } } diff --git a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/HwWebMenu.java b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/HwWebMenu.java index 4cfa4d2..6df3911 100644 --- a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/HwWebMenu.java +++ b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/HwWebMenu.java @@ -3,17 +3,17 @@ package com.ruoyi.portal.domain; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.core.annotation.Excel; -import com.ruoyi.common.core.web.domain.BaseEntity; +import com.ruoyi.common.core.web.domain.TreeEntity; import java.util.List; /** * haiwei官网菜单对象 hw_web_menu - * + * * @author zch * @date 2025-08-18 */ -public class HwWebMenu extends BaseEntity +public class HwWebMenu extends TreeEntity { private static final long serialVersionUID = 1L; @@ -24,16 +24,10 @@ public class HwWebMenu extends BaseEntity @Excel(name = "父节点") private Long parent; - /** 祖先 */ - @Excel(name = "祖先") - private String ancestors; - /** 状态 */ @Excel(name = "状态") private String status; - private int webMenuType; - /** 菜单名称 */ @Excel(name = "菜单名称") private String webMenuName; @@ -46,99 +40,85 @@ public class HwWebMenu extends BaseEntity @Excel(name = "图片地址") private String webMenuPic; - private List children; + /** 官网菜单类型 */ + @Excel(name = "官网菜单类型") + private Long webMenuType; - public void setWebMenuId(Long webMenuId) + public void setWebMenuId(Long webMenuId) { this.webMenuId = webMenuId; } - public Long getWebMenuId() + public Long getWebMenuId() { return webMenuId; } - public void setParent(Long parent) + public void setParent(Long parent) { this.parent = parent; } - public Long getParent() + public Long getParent() { return parent; } - public void setAncestors(String ancestors) - { - this.ancestors = ancestors; - } - - public String getAncestors() - { - return ancestors; - } - public void setStatus(String status) + public void setStatus(String status) { this.status = status; } - public String getStatus() + public String getStatus() { return status; } - public void setWebMenuName(String webMenuName) + public void setWebMenuName(String webMenuName) { this.webMenuName = webMenuName; } - public String getWebMenuName() + public String getWebMenuName() { return webMenuName; } - public void setTenantId(Long tenantId) + public void setTenantId(Long tenantId) { this.tenantId = tenantId; } - public Long getTenantId() + public Long getTenantId() { return tenantId; } - public void setWebMenuPic(String webMenuPic) + public void setWebMenuPic(String webMenuPic) { this.webMenuPic = webMenuPic; } - public String getWebMenuPic() + public String getWebMenuPic() { return webMenuPic; } - - public List getChildren() { - return children; - } - - public void setChildren(List children) { - this.children = children; - } - - public int getWebMenuType() { - return webMenuType; - } - - public void setWebMenuType(int webMenuType) { + public void setWebMenuType(Long webMenuType) + { this.webMenuType = webMenuType; } + public Long getWebMenuType() + { + return webMenuType; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("webMenuId", getWebMenuId()) - .append("parent", getParent()) - .append("ancestors", getAncestors()) - .append("status", getStatus()) - .append("webMenuName", getWebMenuName()) - .append("tenantId", getTenantId()) - .append("webMenuPic", getWebMenuPic()) - .append("webMenuType", getWebMenuType()) - .toString(); + .append("webMenuId", getWebMenuId()) + .append("parent", getParent()) + .append("ancestors", getAncestors()) + .append("status", getStatus()) + .append("webMenuName", getWebMenuName()) + .append("tenantId", getTenantId()) + .append("webMenuPic", getWebMenuPic()) + .append("webMenuType", getWebMenuType()) + .toString(); } } diff --git a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/IHwWebMenuService.java b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/IHwWebMenuService.java index 4fc2d51..ca02c1a 100644 --- a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/IHwWebMenuService.java +++ b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/IHwWebMenuService.java @@ -58,4 +58,11 @@ public interface IHwWebMenuService * @return 结果 */ public int deleteHwWebMenuByWebMenuId(Long webMenuId); + + + /** + * 获取菜单树列表 + */ + public List selectMenuTree(HwWebMenu hwWebMenu); + } diff --git a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/impl/HwWebMenuServiceImpl.java b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/impl/HwWebMenuServiceImpl.java index 23521a9..b95dca6 100644 --- a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/impl/HwWebMenuServiceImpl.java +++ b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/impl/HwWebMenuServiceImpl.java @@ -45,6 +45,16 @@ public class HwWebMenuServiceImpl implements IHwWebMenuService */ @Override public List selectHwWebMenuList(HwWebMenu hwWebMenu) + { + List hwWebMenus = hwWebMenuMapper.selectHwWebMenuList(hwWebMenu); + return hwWebMenus; + } + + /** + * 获取菜单树列表 + */ + @Override + public List selectMenuTree(HwWebMenu hwWebMenu) { List hwWebMenus = hwWebMenuMapper.selectHwWebMenuList(hwWebMenu); return buildWebMenuTree(hwWebMenus); diff --git a/ruoyi-modules/hw-portal/src/main/resources/mapper/portal/HwWebMenuMapper.xml b/ruoyi-modules/hw-portal/src/main/resources/mapper/portal/HwWebMenuMapper.xml index 3d198f4..fb75ca1 100644 --- a/ruoyi-modules/hw-portal/src/main/resources/mapper/portal/HwWebMenuMapper.xml +++ b/ruoyi-modules/hw-portal/src/main/resources/mapper/portal/HwWebMenuMapper.xml @@ -1,9 +1,9 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + @@ -16,31 +16,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select web_menu_id, parent, - ancestors, status, web_menu_name, - tenant_id, web_menu__pic , - web_menu_type - from hw_web_menu + select web_menu_id, parent, ancestors, status, web_menu_name, tenant_id, web_menu__pic, web_menu_type from hw_web_menu - + - + insert into hw_web_menu @@ -52,7 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" tenant_id, web_menu__pic, web_menu_type, - + #{webMenuId}, #{parent}, @@ -62,7 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{tenantId}, #{webMenuPic}, #{webMenuType}, - + @@ -84,7 +80,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - delete from hw_web_menu where web_menu_id in + delete from hw_web_menu where web_menu_id in #{webMenuId} diff --git a/ruoyi-ui/src/api/portal/hwWebMenu.js b/ruoyi-ui/src/api/portal/hwWebMenu.js index a1e1dde..c3956d7 100644 --- a/ruoyi-ui/src/api/portal/hwWebMenu.js +++ b/ruoyi-ui/src/api/portal/hwWebMenu.js @@ -42,3 +42,11 @@ export function delHwWebMenu(webMenuId) { method: 'delete' }) } + +export function selectMenuTree(query) { + return request({ + url: '/portal/hwWebMenu/selectMenuTree', + method: 'get', + params: query + }) +}