| package com.doumee.api.system; | 
|   | 
| import com.doumee.api.BaseController; | 
| import com.doumee.biz.system.SystemRoleBiz; | 
| 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.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.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 java.util.ArrayList; | 
| import java.util.List; | 
|   | 
| import org.springframework.web.bind.annotation.*; | 
| /** | 
|  * @author Eva.Caesar Liu | 
|  * @date 2023/03/21 14:49 | 
|  */ | 
| @Api(tags = "系统角色") | 
| @RestController | 
| @RequestMapping("/system/role") | 
| public class SystemRoleController extends BaseController { | 
|   | 
|     @Autowired | 
|     private SystemRoleService systemRoleService; | 
|   | 
|     @Autowired | 
|     private SystemRoleBiz systemRoleBiz; | 
|   | 
|     @PreventRepeat | 
|     @ApiOperation("配置角色菜单") | 
|     @PostMapping("/createRoleMenu") | 
|     @RequiresPermissions("system:role:createRoleMenu") | 
|     public ApiResponse createRoleMenu (@Validated @RequestBody CreateRoleMenuDTO dto, @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { | 
|         dto.setCreateUser(this.getLoginUser(token).getId()); | 
|         systemRoleBiz.createRoleMenu(dto); | 
|         return ApiResponse.success(null); | 
|     } | 
|   | 
|     @PreventRepeat | 
|     @ApiOperation("配置角色权限") | 
|     @PostMapping("/createRolePermission") | 
|     @RequiresPermissions("system:role:createRolePermission") | 
|     public ApiResponse createRolePermission (@Validated @RequestBody CreateRolePermissionDTO dto, @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { | 
|         dto.setCreateUser(this.getLoginUser(token).getId()); | 
|         systemRoleBiz.createRolePermission(dto); | 
|         return ApiResponse.success(null); | 
|     } | 
|   | 
|     @PreventRepeat | 
|     @ApiOperation("新建") | 
|     @PostMapping("/create") | 
|     @RequiresPermissions("system:role:create") | 
|     public ApiResponse create(@Validated(OperaType.Create.class) @RequestBody SystemRole systemRole, @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { | 
|         systemRole.setCreateUser(this.getLoginUser(token).getId()); | 
|         return ApiResponse.success(systemRoleBiz.create(systemRole)); | 
|     } | 
|   | 
|     @ApiOperation("删除") | 
|     @GetMapping("/delete/{id}") | 
|     @RequiresPermissions("system:role:delete") | 
|     public ApiResponse deleteById(@PathVariable Integer id) { | 
|         systemRoleBiz.deleteById(id); | 
|         return ApiResponse.success(null); | 
|     } | 
|   | 
|     @ApiOperation("批量删除") | 
|     @GetMapping("/delete/batch") | 
|     @RequiresPermissions("system:role:delete") | 
|     public ApiResponse deleteByIdInBatch(@RequestParam String ids) { | 
|         String [] idArray = ids.split(","); | 
|         List<Integer> idList = new ArrayList<>(); | 
|         for (String id : idArray) { | 
|             idList.add(Integer.valueOf(id)); | 
|         } | 
|         systemRoleBiz.deleteByIdInBatch(idList); | 
|         return ApiResponse.success(null); | 
|     } | 
|   | 
|     @ApiOperation("修改") | 
|     @PostMapping("/updateById") | 
|     @RequiresPermissions("system:role:update") | 
|     public ApiResponse updateById(@Validated(OperaType.Update.class) @RequestBody SystemRole systemRole, @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { | 
|         systemRole.setUpdateUser(this.getLoginUser(token).getId()); | 
|         systemRoleBiz.updateById(systemRole); | 
|         return ApiResponse.success(null); | 
|     } | 
|   | 
|     @ApiOperation("分页查询") | 
|     @PostMapping("/page") | 
|     @RequiresPermissions("system:role:query") | 
|     public ApiResponse<PageData<SystemRoleListVO>> findPage (@RequestBody PageWrap<QuerySystemRoleDTO> pageWrap) { | 
|         return ApiResponse.success(systemRoleService.findPage(pageWrap)); | 
|     } | 
|   | 
|     @ApiOperation("查询所有") | 
|     @GetMapping("/all") | 
|     @RequiresPermissions("system:role:query") | 
|     public ApiResponse<List<SystemRole>> findAll () { | 
|         SystemRole systemRole = new SystemRole(); | 
|         systemRole.setDeleted(Boolean.FALSE); | 
|         return ApiResponse.success(systemRoleService.findList(systemRole)); | 
|     } | 
| } |