项目提交
parent
dd7f850f48
commit
18f53affb5
|
@ -135,4 +135,8 @@ public interface SysMenuMapper extends BaseMapper<SysMenu> {
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public SysMenu checkMenuNameUnique (@Param("menuName") String menuName, @Param("parentId") Long parentId);
|
public SysMenu checkMenuNameUnique (@Param("menuName") String menuName, @Param("parentId") Long parentId);
|
||||||
|
|
||||||
|
List<SysMenu> selectBatchParentIds(@Param("parentIdList") List<Long> parentIdList);
|
||||||
|
|
||||||
|
List<SysMenu> selectBatchMenuIds(@Param("menuIdList") List<Long> menuIdList);
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,11 +64,54 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||||
// 管理员显示所有菜单信息
|
// 管理员显示所有菜单信息
|
||||||
if (SysUser.isAdmin(userId)) {
|
if (SysUser.isAdmin(userId)) {
|
||||||
menuList = menuMapper.selectMenuList(menu);
|
menuList = menuMapper.selectMenuList(menu);
|
||||||
|
List<SysMenu> sysMenus =selectParentMenuList(menuList);
|
||||||
|
if (sysMenus !=null){
|
||||||
|
menuList.addAll(sysMenus);
|
||||||
|
}
|
||||||
|
List<SysMenu> sysMenus1 = selectChildMenuList(menuMapper.selectMenuList(menu));
|
||||||
|
if (sysMenus1 !=null){
|
||||||
|
menuList.addAll(sysMenus1);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
menu.getParams().put("userId", userId);
|
menu.getParams().put("userId", userId);
|
||||||
menuList = menuMapper.selectMenuListByUserId(menu);
|
menuList = menuMapper.selectMenuListByUserId(menu);
|
||||||
}
|
}
|
||||||
return menuList;
|
return menuList.stream()
|
||||||
|
.distinct().toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<SysMenu> selectChildMenuList(List<SysMenu> menuList) {
|
||||||
|
List<Long> menuIdList = menuList.stream()
|
||||||
|
.map(menu -> menu.getMenuId())
|
||||||
|
.toList();
|
||||||
|
if (menuIdList.size() >0 && menuIdList !=null){
|
||||||
|
List<SysMenu> sysMenus = menuMapper.selectBatchMenuIds(menuIdList);
|
||||||
|
if (sysMenus.size() >0 && sysMenus !=null){
|
||||||
|
List<SysMenu> sysMenus1 =selectChildMenuList(sysMenus);
|
||||||
|
if (sysMenus1!=null){
|
||||||
|
sysMenus.addAll(sysMenus1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sysMenus;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<SysMenu> selectParentMenuList(List<SysMenu> menuList) {
|
||||||
|
List<Long> parentIdList = menuList.stream()
|
||||||
|
.map(menu -> menu.getParentId())
|
||||||
|
.filter(parentId -> parentId !=0)
|
||||||
|
.distinct().toList();
|
||||||
|
if (parentIdList.size() >0 && parentIdList !=null){
|
||||||
|
List<SysMenu> sysMenus =menuMapper.selectBatchParentIds(parentIdList);
|
||||||
|
List<SysMenu> sysMenus1 =selectParentMenuList(sysMenus);
|
||||||
|
if (sysMenus1!=null){
|
||||||
|
sysMenus.addAll(sysMenus1);
|
||||||
|
}
|
||||||
|
return sysMenus;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -185,6 +185,28 @@
|
||||||
<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="selectBatchParentIds" resultType="com.muyu.system.domain.SysMenu">
|
||||||
|
<include refid="selectMenuVo"/>
|
||||||
|
<where>
|
||||||
|
menu_id in(
|
||||||
|
<foreach collection="parentIdList" separator="," item="id">
|
||||||
|
#{id}
|
||||||
|
</foreach> )
|
||||||
|
|
||||||
|
</where>
|
||||||
|
order by parent_id, order_num
|
||||||
|
</select>
|
||||||
|
<select id="selectBatchMenuIds" resultType="com.muyu.system.domain.SysMenu">
|
||||||
|
<include refid="selectMenuVo"/>
|
||||||
|
<where>
|
||||||
|
parent_id in(
|
||||||
|
<foreach collection="menuIdList" 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