|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.doumee.api.BaseController; | 
|---|
|  |  |  | import com.doumee.biz.system.SystemRoleBiz; | 
|---|
|  |  |  | import com.doumee.config.annotation.CloudRequiredPermission; | 
|---|
|  |  |  | import com.doumee.core.annotation.pr.PreventRepeat; | 
|---|
|  |  |  | import com.doumee.core.constants.OperaType; | 
|---|
|  |  |  | import com.doumee.core.model.ApiResponse; | 
|---|
|  |  |  | import com.doumee.core.model.PageData; | 
|---|
|  |  |  | import com.doumee.core.model.PageWrap; | 
|---|
|  |  |  | import com.doumee.service.business.third.model.ApiResponse; | 
|---|
|  |  |  | import com.doumee.service.business.third.model.PageData; | 
|---|
|  |  |  | import com.doumee.service.business.third.model.PageWrap; | 
|---|
|  |  |  | import com.doumee.core.utils.Constants; | 
|---|
|  |  |  | import com.doumee.dao.system.dto.CreateRoleMenuDTO; | 
|---|
|  |  |  | import com.doumee.dao.system.dto.CreateRolePermissionDTO; | 
|---|
|  |  |  | import com.doumee.dao.system.dto.QuerySystemRoleDTO; | 
|---|
|  |  |  | import com.doumee.dao.system.model.SystemDataPermission; | 
|---|
|  |  |  | import com.doumee.dao.system.model.SystemRole; | 
|---|
|  |  |  | import com.doumee.dao.system.vo.SystemRoleListVO; | 
|---|
|  |  |  | import com.doumee.service.system.SystemRoleService; | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import io.swagger.annotations.ApiOperation; | 
|---|
|  |  |  | import org.apache.shiro.authz.annotation.RequiresPermissions; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.validation.annotation.Validated; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Api(tags = "系统角色") | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | @RequestMapping("/cloudService/system/role") | 
|---|
|  |  |  | @RequestMapping(Constants.CLOUD_SERVICE_URL_INDEX+"/system/role") | 
|---|
|  |  |  | public class SystemRoleCloudController extends BaseController { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | 
|---|
|  |  |  | @PreventRepeat | 
|---|
|  |  |  | @ApiOperation("配置角色菜单") | 
|---|
|  |  |  | @PostMapping("/createRoleMenu") | 
|---|
|  |  |  | @RequiresPermissions("system:role:createRoleMenu") | 
|---|
|  |  |  | @CloudRequiredPermission("system:role:createRoleMenu") | 
|---|
|  |  |  | public ApiResponse createRoleMenu (@RequestHeader(Constants.HEADER_USER_TOKEN) String token, @Validated @RequestBody CreateRoleMenuDTO dto) { | 
|---|
|  |  |  | dto.setCreateUser(this.getLoginUser(token).getId()); | 
|---|
|  |  |  | systemRoleBiz.createRoleMenu(dto); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | @PreventRepeat | 
|---|
|  |  |  | @ApiOperation("配置角色权限") | 
|---|
|  |  |  | @PostMapping("/createRolePermission") | 
|---|
|  |  |  | @RequiresPermissions("system:role:createRolePermission") | 
|---|
|  |  |  | @CloudRequiredPermission("system:role:createRolePermission") | 
|---|
|  |  |  | public ApiResponse createRolePermission (@RequestHeader(Constants.HEADER_USER_TOKEN) String token,@Validated @RequestBody CreateRolePermissionDTO dto) { | 
|---|
|  |  |  | dto.setCreateUser(this.getLoginUser(token).getId()); | 
|---|
|  |  |  | systemRoleBiz.createRolePermission(dto); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreventRepeat | 
|---|
|  |  |  | @ApiOperation("配置角色数据权限") | 
|---|
|  |  |  | @PostMapping("/createRoleDataPermission") | 
|---|
|  |  |  | @CloudRequiredPermission("system:datapermission:create") | 
|---|
|  |  |  | public ApiResponse createRoleDataPermission (@RequestHeader(Constants.HEADER_USER_TOKEN) String token,@Validated @RequestBody SystemDataPermission dto) { | 
|---|
|  |  |  | dto.setLoginUserInfo(this.getLoginUser(token)); | 
|---|
|  |  |  | systemRoleBiz.createRoleDataPermission(dto); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreventRepeat | 
|---|
|  |  |  | @ApiOperation("新建") | 
|---|
|  |  |  | @PostMapping("/create") | 
|---|
|  |  |  | @RequiresPermissions("system:role:create") | 
|---|
|  |  |  | @CloudRequiredPermission("system:role:create") | 
|---|
|  |  |  | public ApiResponse create(@RequestHeader(Constants.HEADER_USER_TOKEN) String token,@Validated(OperaType.Create.class) @RequestBody SystemRole systemRole) { | 
|---|
|  |  |  | systemRole.setCreateUser(this.getLoginUser(token).getId()); | 
|---|
|  |  |  | return ApiResponse.success(systemRoleBiz.create(systemRole)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("删除") | 
|---|
|  |  |  | @GetMapping("/delete/{id}") | 
|---|
|  |  |  | @RequiresPermissions("system:role:delete") | 
|---|
|  |  |  | @CloudRequiredPermission("system:role:delete") | 
|---|
|  |  |  | public ApiResponse deleteById(@RequestHeader(Constants.HEADER_USER_TOKEN) String token,@PathVariable Integer id) { | 
|---|
|  |  |  | systemRoleBiz.deleteById(id); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("批量删除") | 
|---|
|  |  |  | @GetMapping("/delete/batch") | 
|---|
|  |  |  | @RequiresPermissions("system:role:delete") | 
|---|
|  |  |  | @CloudRequiredPermission("system:role:delete") | 
|---|
|  |  |  | public ApiResponse deleteByIdInBatch(@RequestHeader(Constants.HEADER_USER_TOKEN) String token,@RequestParam String ids) { | 
|---|
|  |  |  | String [] idArray = ids.split(","); | 
|---|
|  |  |  | List<Integer> idList = new ArrayList<>(); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("修改") | 
|---|
|  |  |  | @PostMapping("/updateById") | 
|---|
|  |  |  | @RequiresPermissions("system:role:update") | 
|---|
|  |  |  | @CloudRequiredPermission("system:role:update") | 
|---|
|  |  |  | public ApiResponse updateById(@RequestHeader(Constants.HEADER_USER_TOKEN) String token,@Validated(OperaType.Update.class) @RequestBody SystemRole systemRole) { | 
|---|
|  |  |  | systemRole.setUpdateUser(this.getLoginUser(token).getId()); | 
|---|
|  |  |  | systemRoleBiz.updateById(systemRole); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("分页查询") | 
|---|
|  |  |  | @PostMapping("/page") | 
|---|
|  |  |  | @RequiresPermissions("system:role:query") | 
|---|
|  |  |  | @CloudRequiredPermission("system:role:query") | 
|---|
|  |  |  | public ApiResponse<PageData<SystemRoleListVO>> findPage (@RequestHeader(Constants.HEADER_USER_TOKEN) String token,@RequestBody PageWrap<QuerySystemRoleDTO> pageWrap) { | 
|---|
|  |  |  | return ApiResponse.success(systemRoleService.findPage(pageWrap)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("查询所有") | 
|---|
|  |  |  | @GetMapping("/all") | 
|---|
|  |  |  | @RequiresPermissions("system:role:query") | 
|---|
|  |  |  | @CloudRequiredPermission("system:role:query") | 
|---|
|  |  |  | public ApiResponse<List<SystemRole>> findAll (@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { | 
|---|
|  |  |  | SystemRole systemRole = new SystemRole(); | 
|---|
|  |  |  | systemRole.setDeleted(Boolean.FALSE); | 
|---|