mitao
2025-01-17 afa0dbb4f54e7244835dd67ec33c3e545f122f71
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package com.ruoyi.system.controller.sys;
 
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;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.List;
 
import static com.ruoyi.common.core.web.domain.AjaxResult.success;
 
/**
 * @ClassName StaffMenuController
 * @Description TODO
 * @Author jqs
 * @Date 2023/6/25 16:19
 * @Version 1.0
 */
@RestController
@RequestMapping("/staffMenu")
public class StaffMenuController {
 
 
    @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 = success();
        ajax.put("checkedKeys", menuService.selectStaffMenuListByDeptId(deptId));
        ajax.put("menus", menuService.buildMenuTreeSelect(menus));
        return ajax;
    }
 
 
    @ApiOperation(value = "加载对应部门用户员工菜单列表树")
    @GetMapping(value = "/deptUserStaffMenuTreeselect/{deptUserId}")
    public AjaxResult deptUserStaffMenuTreeselect(@PathVariable("deptUserId") Long deptUserId)
    {
        Long userId = SecurityUtils.getUserId();
        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));
    }
}