| | |
| | | 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.api.R; |
| | | 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 makejava |
| | | * @author 安瑾然 |
| | | * @since 2022-07-13 11:52:58 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("report") |
| | | @Api(value = "报案接口", tags = "报案接口") |
| | | public class ReportController extends ApiController { |
| | | /** |
| | | * 服务对象 |
| | |
| | | /** |
| | | * 分页查询所有数据 |
| | | * |
| | | * @param page 分页对象 |
| | | * @param page 分页对象 |
| | | * @param report 查询实体 |
| | | * @return 所有数据 |
| | | */ |
| | | @GetMapping |
| | | public R selectAll(Page<Report> page, Report report) { |
| | | return success(this.reportService.page(page, new QueryWrapper<>(report))); |
| | | @ApiOperation(value = "分页查询所有数据") |
| | | public R<IPage<Report>> selectAll(Page<Report> page, Report report) { |
| | | return R.ok(reportService.page(page, new QueryWrapper<>(report))); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return 单条数据 |
| | | */ |
| | | @GetMapping("{id}") |
| | | public R selectOne(@PathVariable Serializable id) { |
| | | return success(this.reportService.getById(id)); |
| | | @ApiOperation(value = "通过主键查询单条数据") |
| | | public R<Report> selectOne(@PathVariable Serializable id) { |
| | | return R.ok(reportService.getById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 新增数据 |
| | | * 报案 |
| | | * |
| | | * @param report 实体对象 |
| | | * @return 新增结果 |
| | | */ |
| | | @PostMapping |
| | | public R insert(@RequestBody Report report) { |
| | | return success(this.reportService.save(report)); |
| | | @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 修改结果 |
| | | */ |
| | | @PutMapping |
| | | public R update(@RequestBody Report report) { |
| | | return success(this.reportService.updateById(report)); |
| | | } |
| | | |
| | | /** |
| | | * 删除数据 |
| | | * |
| | | * @param idList 主键结合 |
| | | * @return 删除结果 |
| | | */ |
| | | @DeleteMapping |
| | | public R delete(@RequestParam("idList") List<Long> idList) { |
| | | return success(this.reportService.removeByIds(idList)); |
| | | @PostMapping("/audit") |
| | | @ApiOperation(value = "审核通过") |
| | | public R<Boolean> audit(@RequestBody Report report) { |
| | | return R.ok(reportService.audit(report)); |
| | | } |
| | | } |
| | | |