mirror of https://gitee.com/stylefeng/roses
【7.6.0】【sys】新增一个通过菜单id获取菜单详情的接口
parent
b6219971ef
commit
486a4b134b
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.sys.api;
|
||||
|
||||
import cn.stylefeng.roses.kernel.sys.api.pojo.menu.UserAppMenuInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 菜单信息的Api
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/6/26 21:36
|
||||
*/
|
||||
public interface SysMenuServiceApi {
|
||||
|
||||
/**
|
||||
* 通过菜单id获取菜单对应的菜单信息集合
|
||||
* <p>
|
||||
* 一般用在渲染首页的用户常用功能
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/6/26 21:37
|
||||
*/
|
||||
List<UserAppMenuInfo> getUserAppMenuDetailList(Set<Long> menuIdList);
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package cn.stylefeng.roses.kernel.sys.api.pojo.menu;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 菜单详情
|
||||
* <p>
|
||||
* 用在渲染用户的常用功能
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/6/26 21:35
|
||||
*/
|
||||
@Data
|
||||
public class UserAppMenuInfo {
|
||||
|
||||
/**
|
||||
* 菜单名称
|
||||
*/
|
||||
@ChineseDescription("菜单名称")
|
||||
private String menuName;
|
||||
|
||||
/**
|
||||
* 菜单图标
|
||||
*/
|
||||
@ChineseDescription("菜单图标")
|
||||
private String menuIcon;
|
||||
|
||||
/**
|
||||
* 菜单路由
|
||||
*/
|
||||
@ChineseDescription("菜单路由")
|
||||
private String menuRouter;
|
||||
|
||||
}
|
|
@ -9,7 +9,9 @@ import cn.stylefeng.roses.kernel.rule.constants.SymbolConstant;
|
|||
import cn.stylefeng.roses.kernel.rule.constants.TreeConstants;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
import cn.stylefeng.roses.kernel.rule.tree.buildpids.PidStructureBuildUtil;
|
||||
import cn.stylefeng.roses.kernel.sys.api.SysMenuServiceApi;
|
||||
import cn.stylefeng.roses.kernel.sys.api.callback.RemoveMenuCallbackApi;
|
||||
import cn.stylefeng.roses.kernel.sys.api.pojo.menu.UserAppMenuInfo;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.app.service.SysAppService;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.menu.entity.SysMenu;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.menu.enums.SysMenuExceptionEnum;
|
||||
|
@ -39,7 +41,7 @@ import java.util.stream.Collectors;
|
|||
* @date 2023/06/10 21:28
|
||||
*/
|
||||
@Service
|
||||
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements SysMenuService {
|
||||
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements SysMenuService, SysMenuServiceApi {
|
||||
|
||||
@Resource
|
||||
private SysAppService sysAppService;
|
||||
|
@ -190,9 +192,8 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
|
||||
// 查询指定的菜单内容
|
||||
sysMenuLambdaQueryWrapper.select(SysMenu::getMenuId, SysMenu::getMenuParentId, SysMenu::getAppId, SysMenu::getMenuCode,
|
||||
SysMenu::getMenuName, SysMenu::getMenuType,
|
||||
SysMenu::getAntdvIcon, SysMenu::getAntdvVisible, SysMenu::getAntdvActiveUrl, SysMenu::getAntdvRouter,
|
||||
SysMenu::getAntdvComponent, SysMenu::getMenuSort);
|
||||
SysMenu::getMenuName, SysMenu::getMenuType, SysMenu::getAntdvIcon, SysMenu::getAntdvVisible, SysMenu::getAntdvActiveUrl,
|
||||
SysMenu::getAntdvRouter, SysMenu::getAntdvComponent, SysMenu::getMenuSort);
|
||||
|
||||
sysMenuLambdaQueryWrapper.orderByAsc(SysMenu::getMenuSort);
|
||||
|
||||
|
@ -254,6 +255,32 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
return MenuFactory.createAppGroupDetailResult(appList, sysMenuList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserAppMenuInfo> getUserAppMenuDetailList(Set<Long> menuIdList) {
|
||||
|
||||
// 通过id查询菜单的详情信息
|
||||
LambdaQueryWrapper<SysMenu> sysMenuLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
sysMenuLambdaQueryWrapper.in(SysMenu::getMenuId, menuIdList);
|
||||
sysMenuLambdaQueryWrapper.select(SysMenu::getMenuName, SysMenu::getAntdvRouter, SysMenu::getAntdvIcon);
|
||||
List<SysMenu> sysMenuList = this.list(sysMenuLambdaQueryWrapper);
|
||||
|
||||
if (ObjectUtil.isEmpty(sysMenuList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
// 转化成响应信息
|
||||
List<UserAppMenuInfo> result = new ArrayList<>();
|
||||
for (SysMenu sysMenu : sysMenuList) {
|
||||
UserAppMenuInfo userAppMenuInfo = new UserAppMenuInfo();
|
||||
userAppMenuInfo.setMenuName(sysMenu.getMenuName());
|
||||
userAppMenuInfo.setMenuIcon(sysMenu.getAntdvIcon());
|
||||
userAppMenuInfo.setMenuRouter(sysMenu.getAntdvRouter());
|
||||
result.add(userAppMenuInfo);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取信息
|
||||
*
|
||||
|
@ -319,5 +346,4 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue