青羊经侦大队-数据平台
wl
2022-07-29 53d6e1f54ec17280a4a20e8701787e814e74f135
src/main/java/com/example/jz/controller/ReportController.java
@@ -1,20 +1,23 @@
package com.example.jz.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.api.ApiController;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.jz.modle.R;
import com.example.jz.modle.dto.AddReportDto;
import com.example.jz.modle.dto.ReportParamDto;
import com.example.jz.modle.entity.Report;
import com.example.jz.modle.vo.ReportListVo;
import com.example.jz.service.ReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
 * 报案表(Report)表控制层
@@ -24,7 +27,7 @@
 */
@RestController
@RequestMapping("report")
@Api(value = "报案接口", tags = "报案接口")
@Api(value = "案件区-案件人员", tags = "案件区-案件人员")
public class ReportController extends ApiController {
    /**
     * 服务对象
@@ -35,14 +38,14 @@
    /**
     * 分页查询所有数据
     *
     * @param page   分页对象
     * @param report 查询实体
     * @param page           分页对象
     * @param reportParamDto 查询实体
     * @return 所有数据
     */
    @GetMapping
    @ApiOperation(value = "分页查询所有数据")
    public R<IPage<Report>> selectAll(Page<Report> page, Report report) {
        return R.ok(reportService.page(page, new QueryWrapper<>(report)));
    public R<IPage<ReportListVo>> selectAll(Page<ReportListVo> page, ReportParamDto reportParamDto) {
        return R.ok(reportService.getPage(page, reportParamDto));
    }
    /**
@@ -53,24 +56,20 @@
     */
    @GetMapping("{id}")
    @ApiOperation(value = "通过主键查询单条数据")
    public R<Report> selectOne(@PathVariable Serializable id) {
        return R.ok(reportService.getById(id));
    public R<ReportListVo> selectOne(@PathVariable Serializable id) {
        return R.ok(reportService.getReportListVoById(id));
    }
    /**
     * 报案
     *
     * @param report 实体对象
     * @param addReportDto 实体对象
     * @return 新增结果
     */
    @PostMapping
    @ApiOperation(value = "报案")
    public R<Boolean> insert(@RequestBody Report report) {
        report.setCtime(new Date());
        report.setStatus(0);
        //TODO 动态获取当前的用户id
        report.setUserId(1);
        return R.ok(reportService.save(report));
    public R<Boolean> insert(@RequestBody AddReportDto addReportDto) {
        return R.ok(reportService.addReport(addReportDto));
    }
    /**
@@ -84,5 +83,36 @@
    public R<Boolean> audit(@RequestBody Report report) {
        return R.ok(reportService.audit(report));
    }
    @ApiOperation(httpMethod = "PUT", value = "案件台-报案人员-编辑")
    @PutMapping("/updateReport")
    @ApiResponse(message = "执行成功", code = 200)
    public R updateReport(@RequestBody Report report) {
        reportService.updateById(report);
        return R.ok();
    }
    @ApiOperation(httpMethod = "DELETE", value = "案件台-报案人员-退群")
    @DeleteMapping("/leaveGroup")
    @ApiResponse(message = "执行成功", code = 200)
    public R leaveGroup(@RequestParam(value = "id") Integer id, @RequestParam(value = "groupId") Integer groupId) {
        reportService.leaveGroup(id, groupId);
        return R.ok();
    }
    @ApiOperation(httpMethod = "DELETE", value = "案件台-报案人员-删除")
    @DeleteMapping("/deleteReporter")
    @ApiResponse(message = "执行成功", code = 200)
    public R deleteReporter(@RequestParam(value = "id") Integer id) {
        reportService.removeById(id);
        return R.ok();
    }
    @ApiOperation(httpMethod = "POST", value = "案件台-报案人员-报案材料导出")
    @PostMapping("/exportReporter")
    @ApiResponse(message = "执行成功", code = 200)
    public void exportReport(@RequestParam(value = "id") Integer id, HttpServletResponse response) {
        reportService.exportReporter(id, response);
    }
}