系统菜单搜索优化
parent
00c1b5e264
commit
35a07973e7
|
@ -63,7 +63,6 @@ public class SysUserOnlineController extends BaseController {
|
||||||
@Log(title = "在线用户", businessType = BusinessType.FORCE)
|
@Log(title = "在线用户", businessType = BusinessType.FORCE)
|
||||||
@DeleteMapping("/{tokenId}")
|
@DeleteMapping("/{tokenId}")
|
||||||
public Result forceLogout (@PathVariable String tokenId) {
|
public Result forceLogout (@PathVariable String tokenId) {
|
||||||
System.out.println(tokenId);
|
|
||||||
redisService.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + tokenId);
|
redisService.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + tokenId);
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.system.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.muyu.system.domain.SysMenu;
|
import com.muyu.system.domain.SysMenu;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -21,6 +22,8 @@ public interface SysMenuMapper extends BaseMapper<SysMenu> {
|
||||||
*/
|
*/
|
||||||
public List<SysMenu> selectMenuList (SysMenu menu);
|
public List<SysMenu> selectMenuList (SysMenu menu);
|
||||||
|
|
||||||
|
public List<SysMenu> selectSysMenuList (@Param("longs") List<Long> longs);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户所有权限
|
* 根据用户所有权限
|
||||||
*
|
*
|
||||||
|
|
|
@ -51,6 +51,23 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||||
return selectMenuList(new SysMenu(), userId);
|
return selectMenuList(new SysMenu(), userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<SysMenu> selectSysMenuList(List<SysMenu> menuList){
|
||||||
|
List<Long> longs = menuList.stream()
|
||||||
|
.map(menu -> menu.getParentId())
|
||||||
|
.filter(parentId -> parentId != 0)
|
||||||
|
.distinct()
|
||||||
|
.toList();
|
||||||
|
if (longs.size()==0){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
List<SysMenu> sysMenus = menuMapper.selectSysMenuList(longs);
|
||||||
|
List<SysMenu> sysMenus1 = selectSysMenuList(sysMenus);
|
||||||
|
if (sysMenus1 != null){
|
||||||
|
sysMenus.addAll(sysMenus1);
|
||||||
|
}
|
||||||
|
return sysMenus;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询系统菜单列表
|
* 查询系统菜单列表
|
||||||
*
|
*
|
||||||
|
@ -64,10 +81,14 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||||
// 管理员显示所有菜单信息
|
// 管理员显示所有菜单信息
|
||||||
if (SysUser.isAdmin(userId)) {
|
if (SysUser.isAdmin(userId)) {
|
||||||
menuList = menuMapper.selectMenuList(menu);
|
menuList = menuMapper.selectMenuList(menu);
|
||||||
|
menuList.addAll(selectSysMenuList(menuList));
|
||||||
} else {
|
} else {
|
||||||
menu.getParams().put("userId", userId);
|
menu.getParams().put("userId", userId);
|
||||||
menuList = menuMapper.selectMenuListByUserId(menu);
|
menuList = menuMapper.selectMenuListByUserId(menu);
|
||||||
}
|
}
|
||||||
|
menuList = menuList.stream()
|
||||||
|
.distinct()
|
||||||
|
.toList();
|
||||||
return menuList;
|
return menuList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -185,6 +185,17 @@
|
||||||
<include refid="selectMenuVo"/>
|
<include refid="selectMenuVo"/>
|
||||||
where menu_name=#{menuName} and parent_id = #{parentId} limit 1
|
where menu_name=#{menuName} and parent_id = #{parentId} limit 1
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectSysMenuList" resultType="com.muyu.system.domain.SysMenu">
|
||||||
|
<include refid="selectMenuVo"/>
|
||||||
|
<where>
|
||||||
|
menu_id in (
|
||||||
|
<foreach collection="longs" separator="," item="id">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
)
|
||||||
|
</where>
|
||||||
|
order by parent_id, order_num
|
||||||
|
</select>
|
||||||
|
|
||||||
<update id="updateMenu" parameterType="com.muyu.system.domain.SysMenu">
|
<update id="updateMenu" parameterType="com.muyu.system.domain.SysMenu">
|
||||||
update sys_menu
|
update sys_menu
|
||||||
|
|
Loading…
Reference in New Issue