青羊经侦大队-数据平台
安瑾然
2022-07-14 5b04d19edea32888efa9ee4881395a21da348e3f
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
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.entity.Report;
import com.example.jz.service.ReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
 
/**
 * 报案表(Report)表控制层
 *
 * @author 安瑾然
 * @since 2022-07-13 11:52:58
 */
@RestController
@RequestMapping("report")
@Api(value = "报案接口", tags = "报案接口")
public class ReportController extends ApiController {
    /**
     * 服务对象
     */
    @Resource
    private ReportService reportService;
 
    /**
     * 分页查询所有数据
     *
     * @param page   分页对象
     * @param report 查询实体
     * @return 所有数据
     */
    @GetMapping
    @ApiOperation(value = "分页查询所有数据")
    public R<IPage<Report>> selectAll(Page<Report> page, Report report) {
        return R.ok(reportService.page(page, new QueryWrapper<>(report)));
    }
 
    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    @ApiOperation(value = "通过主键查询单条数据")
    public R<Report> selectOne(@PathVariable Serializable id) {
        return R.ok(reportService.getById(id));
    }
 
    /**
     * 报案
     *
     * @param report 实体对象
     * @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));
    }
 
    /**
     * 审核通过并且关联案件id
     *
     * @param report 实体对象
     * @return 修改结果
     */
    @PostMapping("/audit")
    @ApiOperation(value = "审核通过")
    public R<Boolean> audit(@RequestBody Report report) {
        return R.ok(reportService.audit(report));
    }
}