wl
2022-09-20 4e260f558428dd81c4dd8981a965cdaa0ebf12de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
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.platform.zf.EnforcelawReport;
import com.ycl.entity.platform.zf.VideowarmEventsreport;
import com.ycl.service.platform.zf.IVideowarmEventsreportService;
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;
import java.util.stream.Collectors;
 
/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author wl
 * @since 2022-09-16
 */
@RestController
@RequestMapping("/videowarm-eventsreport")
@Api(value = "VideowarmEventsreportController",tags = "违规情况")
public class VideowarmEventsreportController extends BaseController {
 
    @Autowired
    IVideowarmEventsreportService iVideowarmEventsreportService;
 
    @GetMapping("/search")
    @ApiOperation("查询全部违规情况详情")
    public CommonResult getAll(@RequestParam(required = false) String startTime,
                               @RequestParam(required = false) String endTime,
                               @RequestParam(required = false) String eventName,
                               @RequestParam(required = false) String eventType,
                               @RequestParam(required = false) String eventLocation,
                               @RequestParam(required = false) String eventRegion,
                               @RequestParam(required = false) Integer current,
                               @RequestParam(required = false) Integer size
    ) {
        Page<VideowarmEventsreport> page = new Page<>();
        page.setCurrent(current);
        page.setSize(size);
        return CommonResult.success(iVideowarmEventsreportService.selectPageVo(page,startTime,endTime,eventName,eventType,eventLocation,eventRegion));
    }
    @GetMapping("/search/one")
    @ApiOperation("查询违规情况详情")
    public CommonResult getOne(@RequestParam Integer id) {
        return CommonResult.success(iVideowarmEventsreportService.getOne(new QueryWrapper<VideowarmEventsreport>().eq("id", id)));
    }
 
    @PostMapping("/add")
    @ApiOperation("添加违规情况详情")
    public CommonResult add(@RequestBody VideowarmEventsreport videowarmEventsreport) {
        return CommonResult.success(iVideowarmEventsreportService.save(videowarmEventsreport));
    }
 
    @DeleteMapping("/delete")
    @ApiOperation("删除违规情况详情")
    public CommonResult remove(@RequestParam Integer id) {
        return CommonResult.success(iVideowarmEventsreportService.removeById(id));
    }
 
    @PutMapping("/update")
    @ApiOperation("修改违规情况详情")
    public CommonResult modify(@RequestBody VideowarmEventsreport videowarmEventsreport) {
        return CommonResult.success(iVideowarmEventsreportService.updateById(videowarmEventsreport));
    }
 
    @GetMapping("/download")
    @ApiOperation("导出")
    @SneakyThrows
    public void downloadExcel(@RequestParam(required = false) String startTime,
                              @RequestParam(required = false) String endTime,
                              @RequestParam(required = false) String eventName,
                              @RequestParam(required = false) String eventType,
                              @RequestParam(required = false) String eventLocation,
                              @RequestParam(required = false) String eventRegion,
                              HttpServletResponse response) {
        QueryWrapper<VideowarmEventsreport> VideowarmEventsreportQueryWrapper = new QueryWrapper<>();
        if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)) {
            VideowarmEventsreportQueryWrapper.between("cTime", startTime, endTime);
        }
        if (StringUtils.isNotBlank(eventName)) {
            VideowarmEventsreportQueryWrapper.eq("eventName", eventName);
        }
        if (StringUtils.isNotBlank(eventType)) {
            VideowarmEventsreportQueryWrapper.eq("eventType", eventType);
        }
        if (StringUtils.isNotBlank(eventLocation)) {
            VideowarmEventsreportQueryWrapper.eq("eventLocation", eventLocation);
        }
        if (StringUtils.isNotBlank(eventRegion)) {
            VideowarmEventsreportQueryWrapper.eq("eventRegion", eventRegion);
        }
        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(), VideowarmEventsreport.class).sheet("列表").doWrite(iVideowarmEventsreportService.list(VideowarmEventsreportQueryWrapper));
    }
}