feat(portal): 树形结构接口

- 将 HwWebMenu 类的父类从 BaseEntity 改为 TreeEntity- 移除 HwWebMenu 类中的 children 属性
- 修改 HwWebMenu 类中的 webMenuType 属性类型
- 在 API 中添加 selectMenuTree 方法
- 在控制器中添加 selectMenuTree 方法
- 在服务接口和实现类中添加 selectMenuTree 方法
- 更新 Mapper XML 中的 SQL 语句
master
zch 6 days ago
parent 93781bca14
commit 61a340b47b

@ -100,4 +100,12 @@ public class HwWebMenuController extends BaseController
{ {
return toAjax(hwWebMenuService.deleteHwWebMenuByWebMenuIds(webMenuIds)); return toAjax(hwWebMenuService.deleteHwWebMenuByWebMenuIds(webMenuIds));
} }
/**
*
*/
@GetMapping("/selectMenuTree")
public AjaxResult selectMenuTree(HwWebMenu hwWebMenu){
return success(hwWebMenuService.selectMenuTree(hwWebMenu));
}
} }

@ -3,7 +3,7 @@ package com.ruoyi.portal.domain;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel; 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; import java.util.List;
@ -13,7 +13,7 @@ import java.util.List;
* @author zch * @author zch
* @date 2025-08-18 * @date 2025-08-18
*/ */
public class HwWebMenu extends BaseEntity public class HwWebMenu extends TreeEntity
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -24,16 +24,10 @@ public class HwWebMenu extends BaseEntity
@Excel(name = "父节点") @Excel(name = "父节点")
private Long parent; private Long parent;
/** 祖先 */
@Excel(name = "祖先")
private String ancestors;
/** 状态 */ /** 状态 */
@Excel(name = "状态") @Excel(name = "状态")
private String status; private String status;
private int webMenuType;
/** 菜单名称 */ /** 菜单名称 */
@Excel(name = "菜单名称") @Excel(name = "菜单名称")
private String webMenuName; private String webMenuName;
@ -46,7 +40,9 @@ public class HwWebMenu extends BaseEntity
@Excel(name = "图片地址") @Excel(name = "图片地址")
private String webMenuPic; private String webMenuPic;
private List<HwWebMenu> children; /** 官网菜单类型 */
@Excel(name = "官网菜单类型")
private Long webMenuType;
public void setWebMenuId(Long webMenuId) public void setWebMenuId(Long webMenuId)
{ {
@ -66,15 +62,6 @@ public class HwWebMenu extends BaseEntity
{ {
return parent; 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; this.status = status;
@ -111,23 +98,16 @@ public class HwWebMenu extends BaseEntity
{ {
return webMenuPic; return webMenuPic;
} }
public void setWebMenuType(Long webMenuType)
public List<HwWebMenu> getChildren() { {
return children;
}
public void setChildren(List<HwWebMenu> children) {
this.children = children;
}
public int getWebMenuType() {
return webMenuType;
}
public void setWebMenuType(int webMenuType) {
this.webMenuType = webMenuType; this.webMenuType = webMenuType;
} }
public Long getWebMenuType()
{
return webMenuType;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

@ -58,4 +58,11 @@ public interface IHwWebMenuService
* @return * @return
*/ */
public int deleteHwWebMenuByWebMenuId(Long webMenuId); public int deleteHwWebMenuByWebMenuId(Long webMenuId);
/**
*
*/
public List<HwWebMenu> selectMenuTree(HwWebMenu hwWebMenu);
} }

@ -45,6 +45,16 @@ public class HwWebMenuServiceImpl implements IHwWebMenuService
*/ */
@Override @Override
public List<HwWebMenu> selectHwWebMenuList(HwWebMenu hwWebMenu) public List<HwWebMenu> selectHwWebMenuList(HwWebMenu hwWebMenu)
{
List<HwWebMenu> hwWebMenus = hwWebMenuMapper.selectHwWebMenuList(hwWebMenu);
return hwWebMenus;
}
/**
*
*/
@Override
public List<HwWebMenu> selectMenuTree(HwWebMenu hwWebMenu)
{ {
List<HwWebMenu> hwWebMenus = hwWebMenuMapper.selectHwWebMenuList(hwWebMenu); List<HwWebMenu> hwWebMenus = hwWebMenuMapper.selectHwWebMenuList(hwWebMenu);
return buildWebMenuTree(hwWebMenus); return buildWebMenuTree(hwWebMenus);

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.portal.mapper.HwWebMenuMapper"> <mapper namespace="com.ruoyi.portal.mapper.HwWebMenuMapper">
<resultMap type="HwWebMenu" id="HwWebMenuResult"> <resultMap type="HwWebMenu" id="HwWebMenuResult">
@ -16,11 +16,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectHwWebMenuVo"> <sql id="selectHwWebMenuVo">
select web_menu_id, parent, select web_menu_id, parent, ancestors, status, web_menu_name, tenant_id, web_menu__pic, web_menu_type from hw_web_menu
ancestors, status, web_menu_name,
tenant_id, web_menu__pic ,
web_menu_type
from hw_web_menu
</sql> </sql>
<select id="selectHwWebMenuList" parameterType="HwWebMenu" resultMap="HwWebMenuResult"> <select id="selectHwWebMenuList" parameterType="HwWebMenu" resultMap="HwWebMenuResult">
@ -31,8 +27,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''"> and status = #{status}</if> <if test="status != null and status != ''"> and status = #{status}</if>
<if test="webMenuName != null and webMenuName != ''"> and web_menu_name like concat('%', #{webMenuName}, '%')</if> <if test="webMenuName != null and webMenuName != ''"> and web_menu_name like concat('%', #{webMenuName}, '%')</if>
<if test="tenantId != null "> and tenant_id = #{tenantId}</if> <if test="tenantId != null "> and tenant_id = #{tenantId}</if>
<if test="webMenuType != null "> and web_menu_type = #{webMenuType}</if>
<if test="webMenuPic != null and webMenuPic != ''"> and web_menu__pic = #{webMenuPic}</if> <if test="webMenuPic != null and webMenuPic != ''"> and web_menu__pic = #{webMenuPic}</if>
<if test="webMenuType != null "> and web_menu_type = #{webMenuType}</if>
</where> </where>
</select> </select>

@ -42,3 +42,11 @@ export function delHwWebMenu(webMenuId) {
method: 'delete' method: 'delete'
}) })
} }
export function selectMenuTree(query) {
return request({
url: '/portal/hwWebMenu/selectMenuTree',
method: 'get',
params: query
})
}

Loading…
Cancel
Save