| package com.doumee.api.cloud; | 
|   | 
| import com.doumee.api.BaseController; | 
| import com.doumee.biz.system.SystemDepartmentBiz; | 
| import com.doumee.config.annotation.CloudRequiredPermission; | 
| import com.doumee.core.annotation.pr.PreventRepeat; | 
| import com.doumee.core.annotation.trace.Trace; | 
| 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.QuerySystemUserDTO; | 
| import com.doumee.dao.system.model.SystemDepartment; | 
| import com.doumee.dao.system.vo.SystemDepartmentListVO; | 
| import com.doumee.dao.system.vo.SystemUserListVO; | 
| import com.doumee.service.system.SystemUserService; | 
| 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.validation.annotation.Validated; | 
| import org.springframework.web.bind.annotation.*; | 
|   | 
| import java.util.ArrayList; | 
| import java.util.List; | 
|   | 
| /** | 
|  * @author Eva.Caesar Liu | 
|  * @date 2023/03/21 14:49 | 
|  */ | 
| @Api(tags = "部门") | 
| @RestController | 
| @RequestMapping(Constants.CLOUD_SERVICE_URL_INDEX+"/system/department") | 
| public class SystemDepartmentCloudController extends BaseController { | 
|   | 
|     @Autowired | 
|     private SystemDepartmentBiz systemDepartmentBiz; | 
|   | 
|     @Autowired | 
|     private SystemUserService systemUserService; | 
|   | 
|     @PreventRepeat | 
|     @ApiOperation("新建") | 
|     @PostMapping("/create") | 
|     @CloudRequiredPermission("system:department:create") | 
|     public ApiResponse create(@RequestHeader(Constants.HEADER_USER_TOKEN) String token,@Validated(OperaType.Create.class) @RequestBody SystemDepartment systemDepartment) { | 
|         systemDepartment.setCreateUser(getLoginUser(token).getId()); | 
|         systemDepartment.setUpdateUser(getLoginUser(token).getId()); | 
|         return ApiResponse.success(systemDepartmentBiz.create(systemDepartment)); | 
|     } | 
|   | 
|     @ApiOperation("删除") | 
|     @GetMapping("/delete/{id}") | 
|     @CloudRequiredPermission("system:department:delete") | 
|     public ApiResponse deleteById(@RequestHeader(Constants.HEADER_USER_TOKEN) String token,@PathVariable Integer id) { | 
|         systemDepartmentBiz.deleteById(id); | 
|         return ApiResponse.success(null); | 
|     } | 
|   | 
|     @ApiOperation("批量删除") | 
|     @GetMapping("/delete/batch") | 
|     @PreventRepeat | 
|     @CloudRequiredPermission("system:department:delete") | 
|     public ApiResponse deleteByIdInBatch(@RequestHeader(Constants.HEADER_USER_TOKEN) String token,@RequestParam String ids) { | 
|         String [] idArray = ids.split(","); | 
|         List<Integer> idList = new ArrayList<>(); | 
|         for (String id : idArray) { | 
|             idList.add(Integer.valueOf(id)); | 
|         } | 
|         systemDepartmentBiz.deleteByIdInBatch(idList); | 
|         return ApiResponse.success(null); | 
|     } | 
|   | 
|     @ApiOperation("修改") | 
|     @PostMapping("/updateById") | 
|     @CloudRequiredPermission("system:department:update") | 
|     public ApiResponse updateById(@RequestHeader(Constants.HEADER_USER_TOKEN) String token,@Validated(OperaType.Update.class) @RequestBody SystemDepartment systemDepartment) { | 
|         systemDepartment.setCreateUser(getLoginUser(token).getId()); | 
|         systemDepartment.setUpdateUser(getLoginUser(token).getId()); | 
|         systemDepartmentBiz.updateById(systemDepartment); | 
|         return ApiResponse.success(null); | 
|     } | 
|   | 
|     @ApiOperation("查询部门列表") | 
|     @PostMapping("/tree") | 
|     @CloudRequiredPermission("system:department:query") | 
|     public ApiResponse<List<SystemDepartmentListVO>> findTree (@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { | 
|         return ApiResponse.success(systemDepartmentBiz.findTree()); | 
|     } | 
|   | 
|     @ApiOperation("查询部门列表及部门下的人员") | 
|     @GetMapping("/findTreeUser") | 
|     @CloudRequiredPermission("system:department:query") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(name = "parentId", value = "parentId", paramType = "query", dataType = "Integer"), | 
|     }) | 
|     public ApiResponse<SystemDepartmentListVO> findTreeUser(@RequestHeader(Constants.HEADER_USER_TOKEN) String token,Integer parentId) { | 
|         return ApiResponse.success(systemDepartmentBiz.findTreeUser(parentId)); | 
|     } | 
|   | 
|     @Trace(exclude = true) | 
|     @ApiOperation("查询部门人员") | 
|     @PostMapping("/users") | 
|     @CloudRequiredPermission("system:department:queryUsers") | 
|     public ApiResponse<PageData<SystemUserListVO>> findPage (@RequestHeader(Constants.HEADER_USER_TOKEN) String token,@RequestBody PageWrap<QuerySystemUserDTO> pageWrap) { | 
|         return ApiResponse.success(systemUserService.findPage(pageWrap)); | 
|     } | 
| } |