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));
|
}
|
}
|