| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | * 获取菜单列表 |
| | | */ |
| | | @ApiOperation("获取菜单列表") |
| | | @PreAuthorize("@ss.hasPermi('system:menu:list')") |
| | | @SaCheckPermission("system:menu:list") |
| | | @GetMapping("/list") |
| | | public AjaxResult<List<SysMenu>> list(SysMenu menu) { |
| | | List<SysMenu> menus = menuService.selectMenuList(menu, getUserId()); |
| | |
| | | * 根据菜单编号获取详细信息 |
| | | */ |
| | | @ApiOperation("根据菜单编号获取详细信息") |
| | | @PreAuthorize("@ss.hasPermi('system:menu:query')") |
| | | @SaCheckPermission("system:menu:query") |
| | | @GetMapping(value = "/{menuId}") |
| | | public AjaxResult<SysMenu> getInfo(@PathVariable Long menuId) { |
| | | return AjaxResult.success(menuService.selectMenuById(menuId)); |
| | |
| | | * 新增菜单 |
| | | */ |
| | | @ApiOperation("新增菜单") |
| | | @PreAuthorize("@ss.hasPermi('system:menu:add')") |
| | | @SaCheckPermission("system:menu:add") |
| | | @Log(title = "菜单管理", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult<Void> add(@Validated @RequestBody SysMenu menu) { |
| | |
| | | } else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) { |
| | | return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头"); |
| | | } |
| | | menu.setCreateBy(getUsername()); |
| | | return toAjax(menuService.insertMenu(menu)); |
| | | } |
| | | |
| | |
| | | * 修改菜单 |
| | | */ |
| | | @ApiOperation("修改菜单") |
| | | @PreAuthorize("@ss.hasPermi('system:menu:edit')") |
| | | @SaCheckPermission("system:menu:edit") |
| | | @Log(title = "菜单管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult<Void> edit(@Validated @RequestBody SysMenu menu) { |
| | |
| | | } else if (menu.getMenuId().equals(menu.getParentId())) { |
| | | return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己"); |
| | | } |
| | | menu.setUpdateBy(getUsername()); |
| | | return toAjax(menuService.updateMenu(menu)); |
| | | } |
| | | |
| | |
| | | * 删除菜单 |
| | | */ |
| | | @ApiOperation("删除菜单") |
| | | @PreAuthorize("@ss.hasPermi('system:menu:remove')") |
| | | @SaCheckPermission("system:menu:remove") |
| | | @Log(title = "菜单管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{menuId}") |
| | | public AjaxResult<Void> remove(@PathVariable("menuId") Long menuId) { |