| | |
| | | package com.ruoyi.system.controller.sys; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.ruoyi.common.core.constant.UserConstants; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.security.annotation.RequiresPermissions; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.system.api.domain.poji.sys.SysUser; |
| | | import com.ruoyi.system.domain.pojo.sys.SysMenu; |
| | | import com.ruoyi.system.service.sys.ISysMenuService; |
| | | import com.ruoyi.system.service.sys.ISysUserService; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | { |
| | | @Autowired |
| | | private ISysMenuService menuService; |
| | | |
| | | @Autowired |
| | | private ISysUserService sysUserService; |
| | | |
| | | /** |
| | | * 获取菜单列表 |
| | |
| | | public AjaxResult deptUserMenuTreeselect(@PathVariable("deptUserId") Long deptUserId) |
| | | { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | SysUser sysUser = sysUserService.selectUserById(deptUserId); |
| | | List<SysMenu> menus = menuService.selectDeptMenuList(deptUserId); |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | ajax.put("checkedKeys", menuService.selectMenuListByDeptUserId(deptUserId)); |
| | | ajax.put("menus", menuService.buildMenuTreeSelect(menus)); |
| | | ajax.put("dataScope", sysUser.getDataScope()); |
| | | return ajax; |
| | | } |
| | | |
| | |
| | | * 新增菜单 |
| | | */ |
| | | @RequiresPermissions("system:menu:add") |
| | | @Log(title = "菜单管理", businessType = BusinessType.INSERT) |
| | | @Log(title = "菜单管理", businessType = BusinessType.INSERT,operContent = "新增菜单") |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysMenu menu) |
| | | { |
| | |
| | | * 修改菜单 |
| | | */ |
| | | @RequiresPermissions("system:menu:edit") |
| | | @Log(title = "菜单管理", businessType = BusinessType.UPDATE) |
| | | @Log(title = "菜单管理", businessType = BusinessType.UPDATE,operContent = "修改菜单") |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysMenu menu) |
| | | { |
| | |
| | | * 删除菜单 |
| | | */ |
| | | @RequiresPermissions("system:menu:remove") |
| | | @Log(title = "菜单管理", businessType = BusinessType.DELETE) |
| | | @Log(title = "菜单管理", businessType = BusinessType.DELETE,operContent = "删除菜单") |
| | | @DeleteMapping("/{menuId}") |
| | | public AjaxResult remove(@PathVariable("menuId") Long menuId) |
| | | { |
| | |
| | | List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId); |
| | | return success(menuService.buildMenus(menus)); |
| | | } |
| | | |
| | | /** |
| | | * 获取路由信息 |
| | | * |
| | | * @return 路由信息 |
| | | */ |
| | | @GetMapping("getStaffRouters") |
| | | public AjaxResult getStaffRouters() |
| | | { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | List<SysMenu> menus = menuService.selectStaffMenuTreeByUserId(userId); |
| | | return success(menuService.buildMenus(menus)); |
| | | } |
| | | } |