mitao
2025-01-17 afa0dbb4f54e7244835dd67ec33c3e545f122f71
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/sys/StaffMenuController.java
@@ -2,8 +2,10 @@
import com.ruoyi.common.core.web.domain.AjaxResult;
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.web.bind.annotation.GetMapping;
@@ -12,6 +14,8 @@
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import static com.ruoyi.common.core.web.domain.AjaxResult.success;
/**
 * @ClassName StaffMenuController
@@ -28,13 +32,19 @@
    @Autowired
    private ISysMenuService menuService;
    @Autowired
    private ISysUserService sysUserService;
    @ApiOperation(value = "加载对应部门员工菜单列表树")
    @GetMapping(value = "/roleStaffMenuTreeselect/{deptId}")
    public AjaxResult deptStaffMenuTreeselect(@PathVariable("deptId") Long deptId)
    {
        Long userId = SecurityUtils.getUserId();
        List<SysMenu> menus = menuService.selectStaffMenuList(userId);
        AjaxResult ajax = AjaxResult.success();
        AjaxResult ajax = success();
        ajax.put("checkedKeys", menuService.selectStaffMenuListByDeptId(deptId));
        ajax.put("menus", menuService.buildMenuTreeSelect(menus));
        return ajax;
@@ -46,11 +56,23 @@
    public AjaxResult deptUserStaffMenuTreeselect(@PathVariable("deptUserId") Long deptUserId)
    {
        Long userId = SecurityUtils.getUserId();
        List<SysMenu> menus = menuService.selectStaffMenuList(userId);
        AjaxResult ajax = AjaxResult.success();
        SysUser sysUser = sysUserService.selectUserById(deptUserId);
        List<SysMenu> menus = menuService.selectStaffDeptMenuList(deptUserId);
        AjaxResult ajax = success();
        ajax.put("checkedKeys", menuService.selectStaffMenuListByDeptUserId(deptUserId));
        ajax.put("menus", menuService.buildMenuTreeSelect(menus));
        ajax.put("dataScopeEmployee", sysUser.getDataScopeEmployee());
        return ajax;
    }
    /**
     * 获取菜单下拉树列表
     */
    @GetMapping("/treedeptselect")
    public AjaxResult treedeptselect(SysMenu menu)
    {
        Long userId = SecurityUtils.getUserId();
        List<SysMenu> menus = menuService.selectStaffMenuList(menu, userId);
        return success(menuService.buildMenuTreeSelect(menus));
    }
}