update 简化查询菜单功能

2.X
疯狂的狮子li 3 years ago
parent 901940b042
commit 58981b5b3d

@ -61,6 +61,16 @@ public interface UserConstants {
*/ */
String NO_FRAME = "1"; String NO_FRAME = "1";
/**
*
*/
String MENU_NORMAL = "0";
/**
*
*/
String MENU_DISABLE = "1";
/** /**
* *
*/ */

@ -3,6 +3,7 @@ package com.ruoyi.system.domain;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.ruoyi.common.core.web.domain.TreeEntity; import com.ruoyi.common.core.web.domain.TreeEntity;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@ -105,6 +106,7 @@ public class SysMenu extends TreeEntity {
* *
*/ */
@ApiModelProperty(value = "权限字符串") @ApiModelProperty(value = "权限字符串")
@JsonInclude(JsonInclude.Include.NON_NULL)
@Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符") @Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符")
private String perms; private String perms;

@ -1,5 +1,7 @@
package com.ruoyi.system.mapper; package com.ruoyi.system.mapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.core.constant.UserConstants;
import com.ruoyi.common.mybatis.core.mapper.BaseMapperPlus; import com.ruoyi.common.mybatis.core.mapper.BaseMapperPlus;
import com.ruoyi.system.domain.SysMenu; import com.ruoyi.system.domain.SysMenu;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -41,7 +43,14 @@ public interface SysMenuMapper extends BaseMapperPlus<SysMenuMapper, SysMenu, Sy
* *
* @return * @return
*/ */
List<SysMenu> selectMenuTreeAll(); default List<SysMenu> selectMenuTreeAll() {
LambdaQueryWrapper<SysMenu> lqw = new LambdaQueryWrapper<SysMenu>()
.in(SysMenu::getMenuType, UserConstants.TYPE_DIR, UserConstants.TYPE_MENU)
.eq(SysMenu::getStatus, UserConstants.MENU_NORMAL)
.orderByAsc(SysMenu::getParentId)
.orderByAsc(SysMenu::getOrderNum);
return this.selectList(lqw);
}
/** /**
* ID * ID

@ -27,30 +27,9 @@
<result property="remark" column="remark" /> <result property="remark" column="remark" />
</resultMap> </resultMap>
<select id="selectMenuTreeAll" resultMap="SysMenuResult">
select distinct m.menu_id,
m.parent_id,
m.menu_name,
m.path,
m.component,
m.`query`,
m.visible,
m.status,
ifnull(m.perms, '') as perms,
m.is_frame,
m.is_cache,
m.menu_type,
m.icon,
m.order_num,
m.create_time
from sys_menu m
where m.menu_type in ('M', 'C')
and m.status = 0
order by m.parent_id, m.order_num
</select>
<select id="selectMenuListByUserId" parameterType="SysMenu" resultMap="SysMenuResult"> <select id="selectMenuListByUserId" parameterType="SysMenu" resultMap="SysMenuResult">
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status,
m.perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
from sys_menu m from sys_menu m
left join sys_role_menu rm on m.menu_id = rm.menu_id left join sys_role_menu rm on m.menu_id = rm.menu_id
left join sys_user_role ur on rm.role_id = ur.role_id left join sys_user_role ur on rm.role_id = ur.role_id
@ -77,7 +56,7 @@
m.`query`, m.`query`,
m.visible, m.visible,
m.status, m.status,
ifnull(m.perms, '') as perms, m.perms,
m.is_frame, m.is_frame,
m.is_cache, m.is_cache,
m.menu_type, m.menu_type,

Loading…
Cancel
Save