mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-20 18:15:56 +08:00
update 优化 根据租户套餐ID查询菜单树信息 接口写法
This commit is contained in:
parent
bbfd0d1580
commit
f3d1f12190
@ -85,7 +85,7 @@ public class SysMenuController extends BaseController {
|
||||
public R<MenuTreeSelectVo> tenantPackageMenuTreeselect(@PathVariable("packageId") Long packageId) {
|
||||
List<SysMenuVo> menus = menuService.selectMenuList(LoginHelper.getUserId());
|
||||
MenuTreeSelectVo selectVo = new MenuTreeSelectVo();
|
||||
selectVo.setCheckedKeys(menuService.selectMenuListByTenantPackageId(packageId));
|
||||
selectVo.setCheckedKeys(menuService.selectMenuListByPackageId(packageId));
|
||||
selectVo.setMenus(menuService.buildMenuTreeSelect(menus));
|
||||
return R.ok(selectVo);
|
||||
}
|
||||
|
||||
@ -80,12 +80,4 @@ public interface SysMenuMapper extends BaseMapperPlus<SysMenuMapper, SysMenu, Sy
|
||||
*/
|
||||
List<Long> selectMenuListByRoleId(@Param("roleId") Long roleId, @Param("menuCheckStrictly") boolean menuCheckStrictly);
|
||||
|
||||
/**
|
||||
* 根据租户套餐菜单ID查询菜单树信息
|
||||
*
|
||||
* @param menuIds 租户套餐菜单ID
|
||||
* @return 选中菜单列表
|
||||
*/
|
||||
List<Long> selectMenuListByTenantPackageMenuId(@Param("menuIds") String menuIds);
|
||||
|
||||
}
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import com.ruoyi.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import com.ruoyi.system.domain.SysTenantPackage;
|
||||
import com.ruoyi.system.domain.vo.SysTenantPackageVo;
|
||||
import com.ruoyi.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 租户套餐Mapper接口
|
||||
@ -12,12 +11,4 @@ import org.apache.ibatis.annotations.Param;
|
||||
*/
|
||||
public interface SysTenantPackageMapper extends BaseMapperPlus<SysTenantPackageMapper, SysTenantPackage, SysTenantPackageVo> {
|
||||
|
||||
/**
|
||||
* 获取租户套餐菜单id
|
||||
*
|
||||
* @param packageId 租户套餐id
|
||||
* @return 菜单id
|
||||
*/
|
||||
String selectMenuIds(@Param("packageId") Long packageId);
|
||||
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ public interface ISysMenuService {
|
||||
* @param packageId 租户套餐ID
|
||||
* @return 选中菜单列表
|
||||
*/
|
||||
List<Long> selectMenuListByTenantPackageId(Long packageId);
|
||||
List<Long> selectMenuListByPackageId(Long packageId);
|
||||
|
||||
/**
|
||||
* 构建前端路由所需要的菜单
|
||||
|
||||
@ -2,6 +2,7 @@ package com.ruoyi.system.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@ -16,6 +17,7 @@ import com.ruoyi.common.satoken.utils.LoginHelper;
|
||||
import com.ruoyi.system.domain.SysMenu;
|
||||
import com.ruoyi.system.domain.SysRole;
|
||||
import com.ruoyi.system.domain.SysRoleMenu;
|
||||
import com.ruoyi.system.domain.SysTenantPackage;
|
||||
import com.ruoyi.system.domain.bo.SysMenuBo;
|
||||
import com.ruoyi.system.domain.vo.MetaVo;
|
||||
import com.ruoyi.system.domain.vo.RouterVo;
|
||||
@ -158,10 +160,23 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
||||
* @return 选中菜单列表
|
||||
*/
|
||||
@Override
|
||||
public List<Long> selectMenuListByTenantPackageId(Long packageId) {
|
||||
String menuIds = sysTenantPackageMapper.selectMenuIds(packageId);
|
||||
return StringUtils.isNotBlank(menuIds)
|
||||
? baseMapper.selectMenuListByTenantPackageMenuId(menuIds) : new ArrayList<>();
|
||||
public List<Long> selectMenuListByPackageId(Long packageId) {
|
||||
SysTenantPackage tenantPackage = sysTenantPackageMapper.selectById(packageId);
|
||||
String menuIds = tenantPackage.getMenuIds();
|
||||
if (StringUtils.isBlank(menuIds)) {
|
||||
return List.of();
|
||||
}
|
||||
List<Long> parentIds = null;
|
||||
if (tenantPackage.getMenuCheckStrictly()) {
|
||||
parentIds = baseMapper.selectObjs(new LambdaQueryWrapper<SysMenu>()
|
||||
.select(SysMenu::getParentId)
|
||||
.in(SysMenu::getMenuId, menuIds))
|
||||
.stream().distinct().map(Convert::toLong).toList();
|
||||
}
|
||||
return baseMapper.selectObjs(new LambdaQueryWrapper<SysMenu>()
|
||||
.in(SysMenu::getMenuId, menuIds)
|
||||
.notIn(CollUtil.isNotEmpty(parentIds), SysMenu::getMenuId, parentIds))
|
||||
.stream().map(Convert::toLong).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -82,10 +82,4 @@
|
||||
where m.status = '0' and rm.role_id = #{roleId}
|
||||
</select>
|
||||
|
||||
<select id="selectMenuListByTenantPackageMenuId" resultType="java.lang.Long">
|
||||
select m.menu_id
|
||||
from sys_menu m
|
||||
where m.menu_id in (${menuIds})
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@ -4,10 +4,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.system.mapper.SysTenantPackageMapper">
|
||||
|
||||
<select id="selectMenuIds" resultType="java.lang.String">
|
||||
SELECT menu_ids
|
||||
FROM sys_tenant_package
|
||||
WHERE package_id = #{packageId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user