Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/haizhentong
| | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | { |
| | | @Autowired |
| | | private ISysMenuService menuService; |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | @ApiOperation("菜单权限(有层级)") |
| | | @GetMapping("/levelList") |
| | | public AjaxResult levelList() |
| | | { |
| | | Integer roleType = tokenService.getLoginUser().getUser().getRoleType(); |
| | | // 获取当前角色的菜单列表 |
| | | List<SysMenu> menus = menuService.selectList(); |
| | | List<SysMenu> menus = menuService.selectListByRoleType(roleType); |
| | | if(menus.size()==0){ |
| | | return AjaxResult.success(new ArrayList<>()); |
| | | } |
| | |
| | | @Autowired |
| | | private ISysMenuService menuService; |
| | | |
| | | @PreAuthorize("@ss.hasPermi('system:role')") |
| | | // @PreAuthorize("@ss.hasPermi('system:role')") |
| | | @ApiOperation(value = "角色列表") |
| | | @PostMapping("/list") |
| | | public AjaxResult list(@RequestBody SysRoleQuery query) |
| | |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('system:role')") |
| | | // @PreAuthorize("@ss.hasPermi('system:role')") |
| | | @ApiOperation(value = "角色列表不分页") |
| | | @PostMapping("/listNotPage") |
| | | public AjaxResult list() |
| | |
| | | /** |
| | | * 新增角色 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:role:add')") |
| | | // @PreAuthorize("@ss.hasPermi('system:role:add')") |
| | | @ApiOperation(value = "新增角色") |
| | | @Log(title = "角色信息-新增角色", businessType = BusinessType.INSERT) |
| | | @PostMapping("/add") |
| | |
| | | /** |
| | | * 修改保存角色 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | // @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | @ApiOperation(value = "编辑角色") |
| | | @Log(title = "角色信息-编辑角色", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | |
| | | |
| | | List<SysMenu> selectList(); |
| | | |
| | | List<SysMenu> selectListByRoleType(@Param("roleType")Integer roleType); |
| | | |
| | | } |
| | |
| | | */ |
| | | List<SysMenu> selectList(); |
| | | |
| | | /** |
| | | * 通过角色类型查询菜单 |
| | | * @param roleType |
| | | * @return |
| | | */ |
| | | |
| | | List<SysMenu> selectListByRoleType(Integer roleType); |
| | | } |
| | |
| | | public List<SysMenu> selectList() { |
| | | return menuMapper.selectList(); |
| | | } |
| | | @Override |
| | | public List<SysMenu> selectListByRoleType(Integer roleType) { |
| | | return menuMapper.selectListByRoleType(roleType); |
| | | } |
| | | |
| | | /** |
| | | * 获取路由名称 |
| | |
| | | router_name AS routerName |
| | | from sys_menu |
| | | </select> |
| | | <select id="selectListByRoleType" resultType="com.ruoyi.common.core.domain.entity.SysMenu"> |
| | | select |
| | | menu_id AS menuId, |
| | | menu_name AS menuName, |
| | | parent_id AS parentId, |
| | | order_num AS orderNum, |
| | | `path` AS path, |
| | | component AS component, |
| | | `query` AS query, |
| | | is_frame AS isFrame, |
| | | is_cache AS isCache, |
| | | menu_type AS menuType, |
| | | visible AS visible, |
| | | STATUS AS STATUS, |
| | | IFNULL( perms, '' ) AS perms, |
| | | icon AS icon, |
| | | create_time AS createTime, |
| | | role_type AS roleType, |
| | | router_name AS routerName |
| | | from sys_menu where role_type = #{roleType} |
| | | </select> |
| | | |
| | | <update id="updateMenu" parameterType="com.ruoyi.common.core.domain.entity.SysMenu"> |
| | | <update id="updateMenu" parameterType="com.ruoyi.common.core.domain.entity.SysMenu"> |
| | | update sys_menu |
| | | <set> |
| | | <if test="menuName != null and menuName != ''">menu_name = #{menuName},</if> |