package com.ycl.controller.zf; import com.alibaba.excel.EasyExcel; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ycl.api.CommonResult; import com.ycl.controller.BaseController; import com.ycl.entity.zf.EnforceLawReport; import com.ycl.service.zf.IEnforcelawReportService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.SneakyThrows; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.net.URLEncoder; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; /** *

* 违规事项处置管理:包含违法(违建)情况上报、立案、派遣、处置、核查、结案 前端控制器 *

* * @author wl * @since 2022-09-14 */ @RestController @RequestMapping("/enforcelaw-report") @Api(tags = "城市违建") public class EnforcelawReportController extends BaseController { @Autowired IEnforcelawReportService enforcelawReportService; @GetMapping("/search") @ApiOperation("查询全部城市违建详情") public CommonResult getAll(@RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime, @RequestParam(required = false) String community, @RequestParam(required = false) String status, @RequestParam(required = false) String partiesName, @RequestParam(required = false) String partiesID, @RequestParam(required = false) Integer current, @RequestParam(required = false) Integer size ) { Page enforcelawReportPage = new Page<>(); enforcelawReportPage.setCurrent(current); enforcelawReportPage.setSize(size); return CommonResult.success(enforcelawReportService.selectPageVo(enforcelawReportPage,startTime,endTime,community,status,partiesName,partiesID)); } @GetMapping("/search/one") @ApiOperation("查询城市违建详情") public CommonResult getOne(@RequestParam Integer id) { return CommonResult.success(enforcelawReportService.getOne(new QueryWrapper().eq("id", id))); } @PostMapping("/add") @ApiOperation("添加城市违建详情") public CommonResult add(@RequestBody EnforceLawReport enforcelawReport) { return CommonResult.success(enforcelawReportService.save(enforcelawReport)); } @DeleteMapping("/delete") @ApiOperation("删除城市违建详情") public CommonResult remove(@RequestParam Integer id) { return CommonResult.success(enforcelawReportService.removeById(id)); } @PutMapping("/update") @ApiOperation("修改城市违建详情") public CommonResult modify(@RequestBody EnforceLawReport enforcelawReport) { return CommonResult.success(enforcelawReportService.updateById(enforcelawReport)); } @GetMapping("/download") @ApiOperation("导出") @SneakyThrows public void downloadExcel(@RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime, @RequestParam(required = false) String community, @RequestParam(required = false) String status, @RequestParam(required = false) String partiesName, @RequestParam(required = false) String partiesID, HttpServletResponse response) { QueryWrapper enforcelawReportQueryWrapper = new QueryWrapper<>(); if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)) { enforcelawReportQueryWrapper.between("cTime", startTime, endTime); } if (StringUtils.isNotBlank(community)) { enforcelawReportQueryWrapper.eq("community", community); } if (StringUtils.isNotBlank(status)) { enforcelawReportQueryWrapper.eq("status", status); } if (StringUtils.isNotBlank(partiesName)) { enforcelawReportQueryWrapper.eq("partiesName", partiesName); } if (StringUtils.isNotBlank(partiesID)) { enforcelawReportQueryWrapper.eq("partiesID", partiesID); } response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setCharacterEncoding("utf-8"); response.setHeader("Content-disposition", "attachment;filename=" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + URLEncoder.encode("城市违建" + ".xlsx", "utf-8")); EasyExcel.write(response.getOutputStream(), EnforceLawReport.class).sheet("列表").doWrite(enforcelawReportService.list(enforcelawReportQueryWrapper)); } }