| | |
| | | package com.ycl.controller.user; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ycl.annotation.LogSave; |
| | | import com.ycl.api.CommonPage; |
| | | import com.ycl.api.CommonResult; |
| | | import com.ycl.entity.user.UmsMenu; |
| | |
| | | import com.ycl.entity.user.UmsRole; |
| | | import com.ycl.service.user.UmsRoleService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | |
| | | @ApiOperation("添加角色") |
| | | @RequestMapping(value = "/create", method = RequestMethod.POST) |
| | | @ResponseBody |
| | | @LogSave(operationType = "角色管理",contain = "新建角色") |
| | | public CommonResult create(@RequestBody UmsRole role) { |
| | | boolean success = roleService.create(role); |
| | | if (success) { |
| | |
| | | @ApiOperation("批量删除角色") |
| | | @RequestMapping(value = "/delete", method = RequestMethod.POST) |
| | | @ResponseBody |
| | | @LogSave(operationType = "角色管理",contain = "批量删除角色") |
| | | public CommonResult delete(@RequestParam("ids") List<Long> ids) { |
| | | boolean success = roleService.delete(ids); |
| | | if (success) { |
| | |
| | | @ResponseBody |
| | | public CommonResult<List<UmsRole>> listAll() { |
| | | List<UmsRole> roleList = roleService.list(); |
| | | return CommonResult.success(roleList); |
| | | } |
| | | |
| | | @ApiOperation("获取未被禁用角色") |
| | | @RequestMapping(value = "/allow_list", method = RequestMethod.GET) |
| | | @ResponseBody |
| | | public CommonResult<List<UmsRole>> allowList() { |
| | | List<UmsRole> roleList = roleService.list(new LambdaQueryWrapper<UmsRole>().eq(UmsRole::getStatus,1)); |
| | | return CommonResult.success(roleList); |
| | | } |
| | | |
| | |
| | | @ApiOperation("给角色分配菜单") |
| | | @RequestMapping(value = "/allocMenu", method = RequestMethod.POST) |
| | | @ResponseBody |
| | | @LogSave(operationType = "角色管理",contain = "权限设置") |
| | | public CommonResult allocMenu(@RequestParam Long roleId, @RequestParam List<Long> menuIds) { |
| | | int count = roleService.allocMenu(roleId, menuIds); |
| | | return CommonResult.success(count); |
| | |
| | | int count = roleService.allocResource(roleId, resourceIds); |
| | | return CommonResult.success(count); |
| | | } |
| | | @ApiOperation("批量修改角色状态") |
| | | @RequestMapping(value = "/updateStatusBatch", method = RequestMethod.POST) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "ids", value = "用户Ids",required = true, dataType = "Array"), |
| | | @ApiImplicitParam(name = "status", value = "状态0->禁用;1->启用",required = true, dataType = "Integer") |
| | | }) |
| | | @ResponseBody |
| | | @LogSave(operationType = "角色管理",contain = "批量启用/禁用角色") |
| | | public CommonResult updateStatusBatch(@RequestParam("ids") List<Long> ids, @RequestParam(value = "status") Integer status) { |
| | | boolean success = roleService.updateStatusBatch(ids, status); |
| | | if (success) { |
| | | return CommonResult.success(null); |
| | | } |
| | | return CommonResult.failed(); |
| | | } |
| | | |
| | | } |