From e4eec9fc65f1d63f06606a15f0ce518d4fe023fd Mon Sep 17 00:00:00 2001 From: zhanghua <314079846@qq.com> Date: 星期四, 16 二月 2023 14:10:32 +0800 Subject: [PATCH] 优化 --- ycl-platform/src/main/java/com/ycl/controller/cockpit/teamConstruction/TeamConstructionController.java | 51 ++++++++++++++++++++++++--------------------------- 1 files changed, 24 insertions(+), 27 deletions(-) diff --git a/ycl-platform/src/main/java/com/ycl/controller/cockpit/teamConstruction/TeamConstructionController.java b/ycl-platform/src/main/java/com/ycl/controller/cockpit/teamConstruction/TeamConstructionController.java index 2806951..cba4e8d 100644 --- a/ycl-platform/src/main/java/com/ycl/controller/cockpit/teamConstruction/TeamConstructionController.java +++ b/ycl-platform/src/main/java/com/ycl/controller/cockpit/teamConstruction/TeamConstructionController.java @@ -12,6 +12,7 @@ import com.ycl.controller.BaseController; import com.ycl.entity.cockpitManage.TeamConstruction; import com.ycl.service.cockpitManage.ITeamConstructionService; +import com.ycl.utils.EasyExcelUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -24,7 +25,7 @@ import javax.servlet.http.HttpServletResponse; import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; +import java.util.Arrays; /** * <p> @@ -58,27 +59,27 @@ return CommonResult.success(iTeamConstructionService .page(new Page<TeamConstruction>().setSize(size).setCurrent(current), new LambdaQueryWrapper<TeamConstruction>() .like(StringUtils.isNotBlank(departName), TeamConstruction::getName, departName) - .eq( status != null, TeamConstruction::getStatus, status) + .eq(status != null, TeamConstruction::getStatus, status) .eq(TeamConstruction::getIsDelete, isDelete))); } @PostMapping("/addition") @ApiOperation("娣诲姞") - @LogSave(operationType = "闃熶紞寤鸿绠$悊",contain = "娣诲姞") + @LogSave(operationType = "闃熶紞寤鸿绠$悊", contain = "娣诲姞") public CommonResult add(@RequestBody TeamConstruction teamConstruction) { return CommonResult.success(iTeamConstructionService.save(teamConstruction)); } @PutMapping("/modification") @ApiOperation("淇敼") - @LogSave(operationType = "闃熶紞寤鸿绠$悊",contain = "淇敼") + @LogSave(operationType = "闃熶紞寤鸿绠$悊", contain = "淇敼") public CommonResult modify(@RequestBody TeamConstruction teamConstruction) { return CommonResult.success(iTeamConstructionService.updateById(teamConstruction)); } @DeleteMapping("/deletion") @ApiOperation("鍒犻櫎") - @LogSave(operationType = "闃熶紞寤鸿绠$悊",contain = "鍒犻櫎") + @LogSave(operationType = "闃熶紞寤鸿绠$悊", contain = "鍒犻櫎") public CommonResult delete(@RequestParam Long id) { Integer isDelete = 1; TeamConstruction teamConstruction = new TeamConstruction(); @@ -86,44 +87,40 @@ teamConstruction.setId(id); return CommonResult.success(iTeamConstructionService.updateById(teamConstruction)); } + @ApiOperation(value = "鎵归噺鍒犻櫎杩濊绫诲瀷") + @DeleteMapping("/batch_delete") + @LogSave(operationType = "杩愯惀鍩虹璁剧疆",contain = "鎵归噺鍒犻櫎杩濊浜嬮」") + public CommonResult removeViolations(@RequestParam Long[] ids) { + return CommonResult.success(iTeamConstructionService.removeBatchByIds(Arrays.asList(ids))); + } @PostMapping("/export") @ApiOperation("瀵煎嚭") - @LogSave(operationType = "闃熶紞寤鸿绠$悊",contain = "瀵煎嚭") + @LogSave(operationType = "闃熶紞寤鸿绠$悊", contain = "瀵煎嚭") @ApiImplicitParams( { - @ApiImplicitParam(name = "size", required = true, value = "椤甸潰鏁伴噺"), - @ApiImplicitParam(name = "current", required = true, value = "椤电爜"), @ApiImplicitParam(name = "departName", value = "閮ㄩ棬鍚嶇О"), @ApiImplicitParam(name = "status", value = "鐘舵��")} ) @SneakyThrows - public void export(@RequestParam() Integer size, - @RequestParam() Integer current, - @RequestParam(name = "departName", required = false) String departName, - @RequestParam(name = "status", required = false) Integer status, - HttpServletResponse response) { + public void export( + @RequestParam(name = "departName", required = false) String departName, + @RequestParam(name = "status", required = false) Integer status, + HttpServletResponse response) { Integer isDelete = 0; - response.setContentType("application/vnd.ms-excel"); - response.setCharacterEncoding("utf-8"); - response.setHeader("Content-disposition", "attachment;filename=" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx"); - EasyExcel - .write(response.getOutputStream(), TeamConstruction.class) - .sheet("鏁版嵁") - .doWrite(iTeamConstructionService - .page(new Page<TeamConstruction>().setSize(size).setCurrent(current), new LambdaQueryWrapper<TeamConstruction>() - .like(StringUtils.isNotBlank(departName), TeamConstruction::getName, departName) - .eq(status != null, TeamConstruction::getStatus, status) - .eq(TeamConstruction::getIsDelete, isDelete)) - .getRecords()); - + String sheetName = "鏁版嵁"; + EasyExcelUtils.export(response, sheetName, TeamConstruction.class, iTeamConstructionService + .list(new LambdaQueryWrapper<TeamConstruction>() + .like(StringUtils.isNotBlank(departName), TeamConstruction::getName, departName) + .eq(status != null, TeamConstruction::getStatus, status) + .eq(TeamConstruction::getIsDelete, isDelete))); } @PostMapping("/import") @ApiOperation("瀵煎叆") @SneakyThrows - @LogSave(operationType = "闃熶紞寤鸿绠$悊",contain = "瀵煎叆") + @LogSave(operationType = "闃熶紞寤鸿绠$悊", contain = "瀵煎叆") public CommonResult export(MultipartFile multipartFile) { EasyExcel.read(multipartFile.getInputStream(), TeamConstruction.class, new ReadListener() { @Override -- Gitblit v1.8.0