| | |
| | | */ |
| | | package org.springblade.modules.system.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import io.swagger.annotations.*; |
| | | import lombok.AllArgsConstructor; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | |
| | | import org.springblade.core.tool.constant.RoleConstant; |
| | | import org.springblade.core.tool.node.TreeNode; |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.modules.system.dto.MenuDTO; |
| | | import org.springblade.modules.system.entity.Menu; |
| | | import org.springblade.modules.system.entity.TopMenu; |
| | | import org.springblade.modules.system.service.IMenuService; |
| | |
| | | @ApiOperation(value = "详情", notes = "传入menu") |
| | | public R<MenuVO> detail(Menu menu) { |
| | | Menu detail = menuService.getOne(Condition.getQueryWrapper(menu)); |
| | | return R.data(MenuWrapper.build().entityVO(detail)); |
| | | MenuVO menuVO = MenuWrapper.build().entityVO(detail); |
| | | if(StringUtils.isNotBlank(menuVO.getLabelStr())){ |
| | | List<List<String>> lists = (List<List<String>>) JSON.parse(menuVO.getLabelStr() ); |
| | | menuVO.setLabelList(lists); |
| | | } |
| | | return R.data(menuVO); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取动态菜单 |
| | | */ |
| | | @GetMapping("/dynamicMenu") |
| | | @ApiOperation(value = "菜单列表", notes = "传入menu") |
| | | public R<List<MenuVO>> dynamicMenu(String roleId, Long topMenuId, @RequestParam(value = "labelType", required = false) Integer labelType) { |
| | | List<MenuVO> list = menuService.routes(roleId, topMenuId,labelType); |
| | | return R.data(list); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 懒加载菜单列表 |
| | | */ |
| | | @GetMapping("/lazy-menu-list") |
| | |
| | | @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) |
| | | @ApiOperationSupport(order = 6) |
| | | @ApiOperation(value = "新增或修改", notes = "传入menu") |
| | | public R submit(@Valid @RequestBody Menu menu) { |
| | | public R submit(@Valid @RequestBody MenuDTO menu) { |
| | | if (menuService.submit(menu)) { |
| | | CacheUtil.clear(MENU_CACHE); |
| | | CacheUtil.clear(MENU_CACHE, Boolean.FALSE); |
| | |
| | | @ApiOperationSupport(order = 8) |
| | | @ApiOperation(value = "前端菜单数据", notes = "前端菜单数据") |
| | | public R<List<MenuVO>> routes(BladeUser user, Long topMenuId) { |
| | | List<MenuVO> list = menuService.routes((user == null) ? null : user.getRoleId(), topMenuId); |
| | | List<MenuVO> list = menuService.routes((user == null) ? null : user.getRoleId(), topMenuId,null); |
| | | return R.data(list); |
| | | } |
| | | |