|  |  |  | 
|---|
|  |  |  | import com.doumee.api.BaseController; | 
|---|
|  |  |  | import com.doumee.biz.system.SystemPermissionBiz; | 
|---|
|  |  |  | 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.dao.system.dto.QuerySystemPermissionDTO; | 
|---|
|  |  |  | import com.doumee.core.utils.Constants; | 
|---|
|  |  |  | import com.doumee.dao.system.dto.DeleteSystemPermissionDTO; | 
|---|
|  |  |  | import com.doumee.dao.system.model.SystemPermission; | 
|---|
|  |  |  | import com.doumee.dao.system.vo.SystemPermissionListVO; | 
|---|
|  |  |  | import com.doumee.service.system.SystemPermissionService; | 
|---|
|  |  |  | 
|---|
|  |  |  | 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.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import com.doumee.service.business.third.model.ApiResponse; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @author Eva.Caesar Liu | 
|---|
|  |  |  | * @date 2023/03/21 14:49 | 
|---|
|  |  |  | * @author  dm | 
|---|
|  |  |  | * @since 2025/03/31 16:44 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Api(tags = "系统权限") | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | 
|---|
|  |  |  | @ApiOperation("新建") | 
|---|
|  |  |  | @PostMapping("/create") | 
|---|
|  |  |  | @RequiresPermissions("system:permission:create") | 
|---|
|  |  |  | public ApiResponse create(@Validated(OperaType.Create.class) @RequestBody SystemPermission systemPermission) { | 
|---|
|  |  |  | public ApiResponse create(@Validated(Constants.OperaType.Create.class) @RequestBody SystemPermission systemPermission) { | 
|---|
|  |  |  | return ApiResponse.success(systemPermissionBiz.create(systemPermission)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("删除") | 
|---|
|  |  |  | @GetMapping("/delete/{id}") | 
|---|
|  |  |  | @PostMapping("/delete") | 
|---|
|  |  |  | @RequiresPermissions("system:permission:delete") | 
|---|
|  |  |  | public ApiResponse deleteById(@PathVariable Integer id) { | 
|---|
|  |  |  | systemPermissionBiz.deleteById(id); | 
|---|
|  |  |  | public ApiResponse deleteById(@RequestBody DeleteSystemPermissionDTO dto) { | 
|---|
|  |  |  | systemPermissionService.delete(dto); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("批量删除") | 
|---|
|  |  |  | @GetMapping("/delete/batch") | 
|---|
|  |  |  | @PostMapping("/delete/batch") | 
|---|
|  |  |  | @RequiresPermissions("system:permission: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)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | systemPermissionBiz.deleteByIdInBatch(idList); | 
|---|
|  |  |  | public ApiResponse deleteByIdInBatch(@RequestBody List<DeleteSystemPermissionDTO> dtos) { | 
|---|
|  |  |  | systemPermissionService.deleteInBatch(dtos); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("修改") | 
|---|
|  |  |  | @PostMapping("/updateById") | 
|---|
|  |  |  | @RequiresPermissions("system:permission:update") | 
|---|
|  |  |  | public ApiResponse updateById(@Validated(OperaType.Update.class) @RequestBody SystemPermission systemPermission) { | 
|---|
|  |  |  | public ApiResponse updateById(@Validated(Constants.OperaType.Update.class) @RequestBody SystemPermission systemPermission) { | 
|---|
|  |  |  | systemPermissionBiz.updateById(systemPermission); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("分页查询") | 
|---|
|  |  |  | @PostMapping("/page") | 
|---|
|  |  |  | @RequiresPermissions("system:permission:query") | 
|---|
|  |  |  | public ApiResponse<PageData<SystemPermissionListVO>> findPage (@RequestBody PageWrap<QuerySystemPermissionDTO> pageWrap) { | 
|---|
|  |  |  | return ApiResponse.success(systemPermissionService.findPage(pageWrap)); | 
|---|
|  |  |  | @ApiOperation("批量修改") | 
|---|
|  |  |  | @PostMapping("/updateByIdInBatch") | 
|---|
|  |  |  | @RequiresPermissions("system:permission:update") | 
|---|
|  |  |  | public ApiResponse updateById(@RequestBody List<SystemPermission> permissions) { | 
|---|
|  |  |  | systemPermissionService.updateByIdInBatch(permissions); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("查询所有") | 
|---|
|  |  |  | @GetMapping("/all") | 
|---|
|  |  |  | @ApiOperation("查询权限树列表") | 
|---|
|  |  |  | @GetMapping("/tree") | 
|---|
|  |  |  | @RequiresPermissions("system:permission:query") | 
|---|
|  |  |  | public ApiResponse<List<SystemPermission>> findAll () { | 
|---|
|  |  |  | SystemPermission systemPermission = new SystemPermission(); | 
|---|
|  |  |  | systemPermission.setDeleted(Boolean.FALSE); | 
|---|
|  |  |  | return ApiResponse.success(systemPermissionService.findList(systemPermission)); | 
|---|
|  |  |  | public ApiResponse<List<SystemPermissionListVO>> findAll () { | 
|---|
|  |  |  | return ApiResponse.success(systemPermissionService.findTree()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|