重构menu菜单模块,去掉xml中的sql语句
This commit is contained in:
parent
4e7d0af153
commit
1b184ffc63
@ -27,7 +27,7 @@ public class SysMenu extends BaseEntity
|
||||
|
||||
|
||||
/** 菜单ID */
|
||||
@Id(keyType = KeyType.Auto)
|
||||
@Id
|
||||
private Long menuId;
|
||||
|
||||
/** 菜单名称 */
|
||||
@ -50,7 +50,7 @@ public class SysMenu extends BaseEntity
|
||||
private String component;
|
||||
|
||||
/** 路由参数 */
|
||||
private String query;
|
||||
private String queryParam;
|
||||
|
||||
/** 是否为外链(0是 1否) */
|
||||
private String isFrame;
|
||||
|
@ -59,7 +59,7 @@ public class SysMenuBo extends BaseEntity {
|
||||
/**
|
||||
* 路由参数
|
||||
*/
|
||||
private String query;
|
||||
private String queryParam;
|
||||
|
||||
/**
|
||||
* 是否为外链(0是 1否)
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.ruoyi.system.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -8,6 +10,7 @@ import java.util.List;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public class RouterVo
|
||||
{
|
||||
@ -56,93 +59,4 @@ public class RouterVo
|
||||
*/
|
||||
private List<RouterVo> children;
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPath()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path)
|
||||
{
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public boolean getHidden()
|
||||
{
|
||||
return hidden;
|
||||
}
|
||||
|
||||
public void setHidden(boolean hidden)
|
||||
{
|
||||
this.hidden = hidden;
|
||||
}
|
||||
|
||||
public String getRedirect()
|
||||
{
|
||||
return redirect;
|
||||
}
|
||||
|
||||
public void setRedirect(String redirect)
|
||||
{
|
||||
this.redirect = redirect;
|
||||
}
|
||||
|
||||
public String getComponent()
|
||||
{
|
||||
return component;
|
||||
}
|
||||
|
||||
public void setComponent(String component)
|
||||
{
|
||||
this.component = component;
|
||||
}
|
||||
|
||||
public String getQuery()
|
||||
{
|
||||
return query;
|
||||
}
|
||||
|
||||
public void setQuery(String query)
|
||||
{
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
public Boolean getAlwaysShow()
|
||||
{
|
||||
return alwaysShow;
|
||||
}
|
||||
|
||||
public void setAlwaysShow(Boolean alwaysShow)
|
||||
{
|
||||
this.alwaysShow = alwaysShow;
|
||||
}
|
||||
|
||||
public MetaVo getMeta()
|
||||
{
|
||||
return meta;
|
||||
}
|
||||
|
||||
public void setMeta(MetaVo meta)
|
||||
{
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
public List<RouterVo> getChildren()
|
||||
{
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<RouterVo> children)
|
||||
{
|
||||
this.children = children;
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class SysMenuVo implements Serializable {
|
||||
/**
|
||||
* 路由参数
|
||||
*/
|
||||
private String query;
|
||||
private String queryParam;
|
||||
|
||||
/**
|
||||
* 是否为外链(0是 1否)
|
||||
|
@ -1,12 +1,9 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.ruoyi.system.domain.SysMenu;
|
||||
import com.ruoyi.system.domain.bo.SysMenuBo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 菜单表 数据层
|
||||
@ -16,51 +13,5 @@ import org.apache.ibatis.annotations.Param;
|
||||
@Mapper
|
||||
public interface SysMenuMapper extends BaseMapper<SysMenu>
|
||||
{
|
||||
/**
|
||||
* 根据用户所有权限
|
||||
*
|
||||
* @return 权限列表
|
||||
*/
|
||||
List<String> selectMenuPerms();
|
||||
|
||||
/**
|
||||
* 根据用户查询系统菜单列表
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @return 菜单列表
|
||||
*/
|
||||
List<SysMenu> selectMenuListByUserId(SysMenuBo menu);
|
||||
|
||||
/**
|
||||
* 根据角色ID查询权限
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 权限列表
|
||||
*/
|
||||
List<String> selectMenuPermsByRoleId(Long roleId);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询权限
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 权限列表
|
||||
*/
|
||||
List<String> selectMenuPermsByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询菜单
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 菜单列表
|
||||
*/
|
||||
List<SysMenu> selectMenuTreeByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 根据角色ID查询菜单树信息
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @param menuCheckStrictly 菜单树选择项是否关联显示
|
||||
* @return 选中菜单列表
|
||||
*/
|
||||
List<Long> selectMenuListByRoleId(@Param("roleId") Long roleId, @Param("menuCheckStrictly") boolean menuCheckStrictly);
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.mybatisflex.core.query.QueryMethods;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.ruoyi.common.core.utils.MapstructUtils;
|
||||
import com.ruoyi.common.core.utils.StreamUtils;
|
||||
@ -29,11 +30,15 @@ import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.system.domain.vo.MetaVo;
|
||||
import com.ruoyi.system.domain.vo.RouterVo;
|
||||
import com.ruoyi.system.mapper.SysMenuMapper;
|
||||
import com.ruoyi.system.mapper.SysRoleMapper;
|
||||
import com.ruoyi.system.mapper.SysRoleMenuMapper;
|
||||
import com.ruoyi.system.service.ISysMenuService;
|
||||
|
||||
import static com.mybatisflex.core.query.QueryMethods.distinct;
|
||||
import static com.mybatisflex.core.query.QueryMethods.select;
|
||||
import static com.ruoyi.system.domain.table.SysMenuTableDef.SYS_MENU;
|
||||
import static com.ruoyi.system.domain.table.SysRoleMenuTableDef.SYS_ROLE_MENU;
|
||||
import static com.ruoyi.system.domain.table.SysRoleTableDef.SYS_ROLE;
|
||||
import static com.ruoyi.system.domain.table.SysUserRoleTableDef.SYS_USER_ROLE;
|
||||
import static com.ruoyi.system.domain.table.SysUserTableDef.SYS_USER;
|
||||
|
||||
/**
|
||||
* 菜单 业务层处理
|
||||
@ -91,16 +96,46 @@ public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuMapper,SysMenu> i
|
||||
*/
|
||||
@Override
|
||||
public List<SysMenuVo> selectMenuList(SysMenuBo menuBo, Long userId) {
|
||||
List<SysMenuVo> menuList;
|
||||
QueryWrapper queryWrapper = QueryWrapper.create();
|
||||
// 管理员显示所有菜单信息
|
||||
if (LoginHelper.isSuperAdmin(userId)) {
|
||||
QueryWrapper queryWrapper = buildQueryWrapper(menuBo);
|
||||
menuList = this.listAs(queryWrapper, SysMenuVo.class);
|
||||
queryWrapper = buildQueryWrapper(menuBo);
|
||||
} else {
|
||||
menuBo.getParams().put("userId", userId);
|
||||
List<SysMenu> list = menuMapper.selectMenuListByUserId(menuBo);
|
||||
menuList = MapstructUtils.convert(list, SysMenuVo.class);
|
||||
/*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
|
||||
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_role ro on ur.role_id = ro.role_id
|
||||
where ur.user_id = #{params.userId}
|
||||
<if test="menuName != null and menuName != ''">
|
||||
AND m.menu_name like concat('%', #{menuName}, '%')
|
||||
</if>
|
||||
<if test="visible != null and visible != ''">
|
||||
AND m.visible = #{visible}
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND m.status = #{status}
|
||||
</if>
|
||||
order by m.parent_id, m.order_num*/
|
||||
queryWrapper = queryWrapper
|
||||
.select(QueryMethods.distinct(SYS_MENU.MENU_ID,SYS_MENU.PARENT_ID,SYS_MENU.MENU_NAME,SYS_MENU.PATH,SYS_MENU.COMPONENT,SYS_MENU.QUERY_PARAM,SYS_MENU.VISIBLE,SYS_MENU.STATUS,SYS_MENU.PERMS,SYS_MENU.IS_FRAME,SYS_MENU.IS_CACHE,SYS_MENU.MENU_TYPE,SYS_MENU.ICON,SYS_MENU.ORDER_NUM,SYS_MENU.CREATE_TIME))
|
||||
.from(SYS_MENU)
|
||||
.leftJoin(SYS_ROLE_MENU).on(SYS_MENU.MENU_ID.eq(SYS_ROLE_MENU.MENU_ID))
|
||||
.leftJoin(SYS_USER_ROLE).on(SYS_ROLE_MENU.ROLE_ID.eq(SYS_USER_ROLE.ROLE_ID))
|
||||
.leftJoin(SYS_ROLE).on(SYS_ROLE.ROLE_ID.eq(SYS_USER_ROLE.ROLE_ID))
|
||||
.where(SYS_USER_ROLE.USER_ID.eq(userId));
|
||||
if (StringUtils.isNotEmpty(menuBo.getMenuName())) {
|
||||
queryWrapper.and(SYS_MENU.MENU_NAME.like(menuBo.getMenuName()));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(menuBo.getVisible())) {
|
||||
queryWrapper.and(SYS_MENU.VISIBLE.eq(menuBo.getVisible()));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(menuBo.getStatus())) {
|
||||
queryWrapper.and(SYS_MENU.STATUS.eq(menuBo.getStatus()));
|
||||
}
|
||||
queryWrapper.orderBy(SYS_MENU.PARENT_ID.asc(),SYS_MENU.ORDER_NUM.asc());
|
||||
}
|
||||
List<SysMenuVo> menuList = this.listAs(queryWrapper, SysMenuVo.class);
|
||||
return menuList;
|
||||
}
|
||||
|
||||
@ -112,7 +147,24 @@ public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuMapper,SysMenu> i
|
||||
*/
|
||||
@Override
|
||||
public Set<String> selectMenuPermsByUserId(Long userId) {
|
||||
List<String> perms = menuMapper.selectMenuPermsByUserId(userId);
|
||||
/*select distinct m.perms
|
||||
from sys_menu m
|
||||
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_role r on r.role_id = ur.role_id
|
||||
where m.status = '0' and r.status = '0' and ur.user_id = #{userId}*/
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.select(distinct(SYS_MENU.PERMS))
|
||||
.from(SYS_MENU)
|
||||
.leftJoin(SYS_ROLE_MENU).on(SYS_ROLE_MENU.MENU_ID.eq(SYS_MENU.MENU_ID))
|
||||
.leftJoin(SYS_USER_ROLE).on(SYS_USER_ROLE.ROLE_ID.eq(SYS_ROLE_MENU.ROLE_ID))
|
||||
.leftJoin(SYS_ROLE).on(SYS_ROLE.ROLE_ID.eq(SYS_USER_ROLE.ROLE_ID))
|
||||
.where(SYS_MENU.STATUS.eq("0"))
|
||||
.and(SYS_ROLE.STATUS.eq("0"))
|
||||
.and(SYS_USER_ROLE.USER_ID.eq(userId));
|
||||
|
||||
List<String> perms = this.listAs(queryWrapper, String.class);
|
||||
|
||||
Set<String> permsSet = new HashSet<>();
|
||||
for (String perm : perms) {
|
||||
if (StringUtils.isNotEmpty(perm)) {
|
||||
@ -130,7 +182,19 @@ public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuMapper,SysMenu> i
|
||||
*/
|
||||
@Override
|
||||
public Set<String> selectMenuPermsByRoleId(Long roleId) {
|
||||
List<String> perms = menuMapper.selectMenuPermsByRoleId(roleId);
|
||||
/*select distinct m.perms
|
||||
from sys_menu m
|
||||
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
||||
where m.status = '0' and rm.role_id = #{roleId}*/
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.select(distinct(SYS_MENU.PERMS))
|
||||
.from(SYS_MENU)
|
||||
.leftJoin(SYS_ROLE_MENU).on(SYS_ROLE_MENU.MENU_ID.eq(SYS_MENU.MENU_ID))
|
||||
.where(SYS_MENU.STATUS.eq("0"))
|
||||
.and(SYS_ROLE_MENU.ROLE_ID.eq(roleId));
|
||||
|
||||
List<String> perms = this.listAs(queryWrapper, String.class);
|
||||
//List<String> perms = menuMapper.selectMenuPermsByRoleId(roleId);
|
||||
Set<String> permsSet = new HashSet<>();
|
||||
for (String perm : perms) {
|
||||
if (StringUtils.isNotEmpty(perm)) {
|
||||
@ -156,13 +220,32 @@ public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuMapper,SysMenu> i
|
||||
*/
|
||||
@Override
|
||||
public List<SysMenu> selectMenuTreeByUserId(Long userId) {
|
||||
List<SysMenu> menus;
|
||||
QueryWrapper queryWrapper = QueryWrapper.create();
|
||||
if (LoginHelper.isSuperAdmin(userId)) {
|
||||
QueryWrapper queryWrapper = buildMenuTreeQueryWrapper();
|
||||
menus = this.list(queryWrapper);
|
||||
queryWrapper = buildMenuTreeQueryWrapper();
|
||||
} else {
|
||||
menus = menuMapper.selectMenuTreeByUserId(userId);
|
||||
/*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
|
||||
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_role ro on ur.role_id = ro.role_id
|
||||
left join sys_user u on ur.user_id = u.user_id
|
||||
where u.user_id = #{userId} and m.menu_type in ('M', 'C') and m.status = 0 AND ro.status = 0
|
||||
order by m.parent_id, m.order_num*/
|
||||
queryWrapper = queryWrapper
|
||||
.select(QueryMethods.distinct(SYS_MENU.MENU_ID,SYS_MENU.PARENT_ID,SYS_MENU.MENU_NAME,SYS_MENU.PATH,SYS_MENU.COMPONENT,SYS_MENU.QUERY_PARAM,SYS_MENU.VISIBLE,SYS_MENU.STATUS,SYS_MENU.PERMS,SYS_MENU.IS_FRAME,SYS_MENU.IS_CACHE,SYS_MENU.MENU_TYPE,SYS_MENU.ICON,SYS_MENU.ORDER_NUM,SYS_MENU.CREATE_TIME))
|
||||
.from(SYS_MENU)
|
||||
.leftJoin(SYS_ROLE_MENU).on(SYS_MENU.MENU_ID.eq(SYS_ROLE_MENU.MENU_ID))
|
||||
.leftJoin(SYS_USER_ROLE).on(SYS_ROLE_MENU.ROLE_ID.eq(SYS_USER_ROLE.ROLE_ID))
|
||||
.leftJoin(SYS_ROLE).on(SYS_ROLE.ROLE_ID.eq(SYS_USER_ROLE.ROLE_ID))
|
||||
.leftJoin(SYS_USER).on(SYS_USER.USER_ID.eq(SYS_USER_ROLE.USER_ID))
|
||||
.where(SYS_USER.USER_ID.eq(userId))
|
||||
.and(SYS_MENU.MENU_TYPE.in("M", "C"))
|
||||
.and(SYS_MENU.STATUS.eq("0"))
|
||||
.and(SYS_ROLE.STATUS.eq("0"))
|
||||
.orderBy(SYS_MENU.PARENT_ID.asc(),SYS_MENU.ORDER_NUM.asc());
|
||||
}
|
||||
List<SysMenu> menus= this.list(queryWrapper);
|
||||
return getChildPerms(menus, 0);
|
||||
}
|
||||
|
||||
@ -175,7 +258,25 @@ public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuMapper,SysMenu> i
|
||||
@Override
|
||||
public List<Long> selectMenuListByRoleId(Long roleId) {
|
||||
SysRoleVo role = sysRoleService.selectRoleById(roleId);
|
||||
return menuMapper.selectMenuListByRoleId(roleId, role.getMenuCheckStrictly());
|
||||
|
||||
/*select m.menu_id
|
||||
from sys_menu m
|
||||
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
||||
where rm.role_id = #{roleId}
|
||||
<if test="menuCheckStrictly">
|
||||
and m.menu_id not in (select m.parent_id from sys_menu m inner join sys_role_menu rm on m.menu_id = rm.menu_id and rm.role_id = #{roleId})
|
||||
</if>
|
||||
order by m.parent_id, m.order_num*/
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.select(SYS_MENU.MENU_ID)
|
||||
.from(SYS_MENU)
|
||||
.leftJoin(SYS_ROLE_MENU).on(SYS_ROLE_MENU.MENU_ID.eq(SYS_MENU.MENU_ID))
|
||||
.where(SYS_ROLE_MENU.ROLE_ID.eq(roleId));
|
||||
if(role.getMenuCheckStrictly()){
|
||||
queryWrapper.and(SYS_MENU.MENU_ID.notIn(select(SYS_MENU.PARENT_ID).from(SYS_MENU).innerJoin(SYS_ROLE_MENU).on(SYS_MENU.MENU_ID.eq(SYS_ROLE_MENU.MENU_ID)).and(SYS_ROLE_MENU.ROLE_ID.eq(roleId))));
|
||||
}
|
||||
queryWrapper.orderBy(SYS_MENU.PARENT_ID.asc(),SYS_MENU.ORDER_NUM.asc());
|
||||
return this.listAs(queryWrapper, Long.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -193,7 +294,7 @@ public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuMapper,SysMenu> i
|
||||
router.setName(getRouteName(menu));
|
||||
router.setPath(getRouterPath(menu));
|
||||
router.setComponent(getComponent(menu));
|
||||
router.setQuery(menu.getQuery());
|
||||
router.setQuery(menu.getQueryParam());
|
||||
router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath()));
|
||||
List<SysMenu> cMenus = menu.getChildren();
|
||||
if (StringUtils.isNotEmpty(cMenus) && UserConstants.TYPE_DIR.equals(menu.getMenuType())) {
|
||||
@ -208,7 +309,7 @@ public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuMapper,SysMenu> i
|
||||
children.setComponent(menu.getComponent());
|
||||
children.setName(StringUtils.capitalize(menu.getPath()));
|
||||
children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath()));
|
||||
children.setQuery(menu.getQuery());
|
||||
children.setQuery(menu.getQueryParam());
|
||||
childrenList.add(children);
|
||||
router.setChildren(childrenList);
|
||||
} else if (menu.getParentId().intValue() == 0 && isInnerLink(menu)) {
|
||||
|
@ -4,96 +4,5 @@
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.system.mapper.SysMenuMapper">
|
||||
|
||||
<resultMap type="SysMenu" id="SysMenuResult">
|
||||
<id property="menuId" column="menu_id" />
|
||||
<result property="menuName" column="menu_name" />
|
||||
<result property="parentName" column="parent_name" />
|
||||
<result property="parentId" column="parent_id" />
|
||||
<result property="orderNum" column="order_num" />
|
||||
<result property="path" column="path" />
|
||||
<result property="component" column="component" />
|
||||
<result property="query" column="query" />
|
||||
<result property="isFrame" column="is_frame" />
|
||||
<result property="isCache" column="is_cache" />
|
||||
<result property="menuType" column="menu_type" />
|
||||
<result property="visible" column="visible" />
|
||||
<result property="status" column="status" />
|
||||
<result property="perms" column="perms" />
|
||||
<result property="icon" column="icon" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectMenuVo">
|
||||
select menu_id, menu_name, parent_id, order_num, path, component, `query`, is_frame, is_cache, menu_type, visible, status, ifnull(perms,'') as perms, icon, create_time
|
||||
from sys_menu
|
||||
</sql>
|
||||
|
||||
<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
|
||||
from sys_menu m
|
||||
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_role ro on ur.role_id = ro.role_id
|
||||
where ur.user_id = #{params.userId}
|
||||
<if test="menuName != null and menuName != ''">
|
||||
AND m.menu_name like concat('%', #{menuName}, '%')
|
||||
</if>
|
||||
<if test="visible != null and visible != ''">
|
||||
AND m.visible = #{visible}
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND m.status = #{status}
|
||||
</if>
|
||||
order by m.parent_id, m.order_num
|
||||
</select>
|
||||
|
||||
<select id="selectMenuTreeByUserId" parameterType="Long" 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
|
||||
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_role ro on ur.role_id = ro.role_id
|
||||
left join sys_user u on ur.user_id = u.user_id
|
||||
where u.user_id = #{userId} and m.menu_type in ('M', 'C') and m.status = 0 AND ro.status = 0
|
||||
order by m.parent_id, m.order_num
|
||||
</select>
|
||||
|
||||
<select id="selectMenuListByRoleId" resultType="Long">
|
||||
select m.menu_id
|
||||
from sys_menu m
|
||||
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
||||
where rm.role_id = #{roleId}
|
||||
<if test="menuCheckStrictly">
|
||||
and m.menu_id not in (select m.parent_id from sys_menu m inner join sys_role_menu rm on m.menu_id = rm.menu_id and rm.role_id = #{roleId})
|
||||
</if>
|
||||
order by m.parent_id, m.order_num
|
||||
</select>
|
||||
|
||||
<select id="selectMenuPerms" resultType="String">
|
||||
select distinct m.perms
|
||||
from sys_menu m
|
||||
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
|
||||
</select>
|
||||
|
||||
<select id="selectMenuPermsByUserId" parameterType="Long" resultType="String">
|
||||
select distinct m.perms
|
||||
from sys_menu m
|
||||
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_role r on r.role_id = ur.role_id
|
||||
where m.status = '0' and r.status = '0' and ur.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="selectMenuPermsByRoleId" parameterType="Long" resultType="String">
|
||||
select distinct m.perms
|
||||
from sys_menu m
|
||||
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
||||
where m.status = '0' and rm.role_id = #{roleId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
Loading…
Reference in New Issue
Block a user