//package com.landtool.lanbase.modules.sys.controller;
|
//
|
//import org.apache.commons.lang.StringUtils;
|
//import org.apache.shiro.authz.annotation.RequiresPermissions;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.web.bind.annotation.GetMapping;
|
//import org.springframework.web.bind.annotation.PathVariable;
|
//import org.springframework.web.bind.annotation.PostMapping;
|
//import org.springframework.web.bind.annotation.RequestBody;
|
//import org.springframework.web.bind.annotation.RequestMapping;
|
//import org.springframework.web.bind.annotation.RequestMethod;
|
//import org.springframework.web.bind.annotation.RestController;
|
//
|
//import com.landtool.lanbase.common.Constant.MenuType;
|
//import com.landtool.lanbase.common.annotation.LogAction;
|
//import com.landtool.lanbase.common.annotation.LogLogininfo;
|
//import com.landtool.lanbase.common.annotation.SysLog;
|
//import com.landtool.lanbase.common.exception.LanbaseException;
|
//import com.landtool.lanbase.common.utils.Result;
|
//import com.landtool.lanbase.modules.sys.entity.SysMenu;
|
//import com.landtool.lanbase.modules.sys.service.SysMenuService;
|
//import com.landtool.lanbase.modules.sys.service.SysUserService;
|
//
|
//import io.swagger.annotations.Api;
|
//import io.swagger.annotations.ApiOperation;
|
//import io.swagger.annotations.ApiParam;
|
//
|
//import java.util.HashMap;
|
//import java.util.List;
|
//import java.util.Set;
|
//
|
///**
|
// * @author lanbase
|
// * @Description: TODO(系统菜单)
|
// * @date 2017-6-23 15:07
|
// */
|
//@RestController
|
//@RequestMapping("/sys/menu")
|
//@Api(value = "", tags = {"系统菜单"})
|
//public class SysMenuController extends AbstractController {
|
//
|
// @Autowired
|
// private SysUserService sysUserService;
|
//
|
// @Autowired
|
// private SysMenuService sysMenuService;
|
//
|
// /**
|
// * 导航菜单
|
// */
|
// @RequestMapping(value ="/nav", method ={RequestMethod.POST, RequestMethod.GET})
|
// @ApiOperation(
|
// value = "导航菜单",
|
// notes = "返回导航菜单,带有权限,用于首页",
|
// response = Result.class
|
// )
|
// public Result nav(){
|
// List<SysMenu> menuList = sysMenuService.getUserMenuList(getUserId());
|
// Set<String> permissions = sysUserService.getUserPermissions(getUserId());
|
// return Result.ok().put("menuList", menuList).put("permissions", permissions);
|
// }
|
//
|
// /**
|
// * 所有菜单列表
|
// */
|
// @RequestMapping(value ="/list", method ={RequestMethod.POST, RequestMethod.GET})
|
// @RequiresPermissions("sys:menu:list")
|
// @ApiOperation(
|
// value = "菜单列表",
|
// notes = "所有菜单列表"
|
// )
|
// public List<SysMenu> list(){
|
// List<SysMenu> menuList = sysMenuService.queryList(new HashMap<String, Object>());
|
//
|
// return menuList;
|
// }
|
//
|
// /**
|
// * 选择菜单(添加、修改菜单)
|
// */
|
// @GetMapping("/select")
|
// @RequiresPermissions("sys:menu:select")
|
// @ApiOperation(
|
// value = "选择菜单",
|
// notes = "选择菜单(添加、修改菜单)"
|
// )
|
// public Result select(){
|
// //查询列表数据
|
// List<SysMenu> menuList = sysMenuService.queryNotButtonList();
|
//
|
// //添加顶级菜单
|
// SysMenu root = new SysMenu();
|
// root.setId(0L);
|
// root.setName("一级菜单");
|
// root.setParentId(-1L);
|
// root.setOpen(true);
|
// menuList.add(root);
|
//
|
// return Result.ok().put("menuList", menuList);
|
// }
|
//
|
// /**
|
// * 菜单信息
|
// */
|
// @GetMapping("/info/{menuId}")
|
// @RequiresPermissions("sys:menu:info")
|
// @ApiOperation(
|
// value = "菜单信息",
|
// notes = ""
|
// )
|
// public Result info(@ApiParam(name="menuId",value="菜单id",required=true)@PathVariable("menuId") Long menuId){
|
// SysMenu menu = sysMenuService.queryObject(menuId);
|
// return Result.ok().put("menu", menu);
|
// }
|
//
|
// /**
|
// * 保存
|
// */
|
// //@LogAction("保存菜单")
|
// @PostMapping("/save")
|
// @RequiresPermissions("sys:menu:save")
|
// @ApiOperation(
|
// value = "保存菜单",
|
// notes = ""
|
// )
|
// public Result save(@ApiParam(name="菜单对象",value="传入json格式",required=true)@RequestBody SysMenu menu){
|
// //数据校验
|
// verifyForm(menu);
|
//
|
// sysMenuService.save(menu);
|
//
|
// return Result.ok();
|
// }
|
//
|
// /**
|
// * 修改
|
// */
|
// //@LogLogininfo("修改")
|
// @PostMapping("/update")
|
// @RequiresPermissions("sys:menu:update")
|
// @ApiOperation(
|
// value = "修改菜单",
|
// notes = ""
|
// )
|
// public Result update(@ApiParam(name="菜单对象",value="传入json格式",required=true)@RequestBody SysMenu menu){
|
// //数据校验
|
// verifyForm(menu);
|
//
|
// sysMenuService.update(menu);
|
//
|
// return Result.ok();
|
// }
|
//
|
// /**
|
// * 删除
|
// */
|
// @SysLog("删除菜单")
|
// @PostMapping("/delete")
|
// @RequiresPermissions("sys:menu:delete")
|
// @ApiOperation(
|
// value = "删除菜单",
|
// notes = ""
|
// )
|
// public Result delete(@ApiParam(name="menuId",value="菜单id",required=true)long menuId){
|
// //判断是否有子菜单或按钮
|
// List<SysMenu> menuList = sysMenuService.queryListByParentId(menuId);
|
// SysMenu menu = sysMenuService.queryObject(menuId); //当前菜单
|
// SysMenu rootMenu = sysMenuService.queryObject(menuId); //一级菜单
|
// while (rootMenu.getParentId() != 0) {
|
// rootMenu = sysMenuService.queryObject(rootMenu.getParentId());
|
// }
|
//
|
// if (!rootMenu.getName().equals("内容管理") && menuList.size() > 0) {
|
// return Result.error("请先删除子菜单或按钮");
|
// }
|
//
|
// sysMenuService.deleteBatch(new Long[]{menuId});
|
// return Result.ok();
|
// }
|
//
|
// /**
|
// * 验证参数是否正确
|
// */
|
// private void verifyForm(SysMenu menu){
|
// if(StringUtils.isBlank(menu.getName())){
|
// throw new LanbaseException("菜单名称不能为空");
|
// }
|
//
|
// if(menu.getParentId() == null){
|
// throw new LanbaseException("上级菜单不能为空");
|
// }
|
//
|
// //菜单
|
// if(menu.getType() == MenuType.MENU.getValue()){
|
// if(StringUtils.isBlank(menu.getUrl())){
|
// throw new LanbaseException("菜单URL不能为空");
|
// }
|
// }
|
//
|
// //上级菜单类型
|
// int parentType = MenuType.CATALOG.getValue();
|
// if(menu.getParentId() != 0){
|
// SysMenu parentMenu = sysMenuService.queryObject(menu.getParentId());
|
// parentType = parentMenu.getType();
|
// }
|
//
|
// //目录、菜单
|
// if(menu.getType() == MenuType.CATALOG.getValue() ||
|
// menu.getType() == MenuType.MENU.getValue()){
|
// if(parentType != MenuType.CATALOG.getValue()){
|
// throw new LanbaseException("上级菜单只能为目录类型");
|
// }
|
// return ;
|
// }
|
//
|
// //按钮
|
// if(menu.getType() == MenuType.BUTTON.getValue()){
|
// if(parentType != MenuType.MENU.getValue()){
|
// throw new LanbaseException("上级菜单只能为菜单类型");
|
// }
|
// return ;
|
// }
|
// }
|
//}
|