package com.ruoyi.project.quality.report.controller;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.ruoyi.framework.web.domain.AjaxResult;
|
import com.ruoyi.project.quality.report.domain.InspectionReport;
|
import com.ruoyi.project.quality.report.service.IInspectionReportService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.Arrays;
|
|
/**
|
* 检测报告 Controller
|
*/
|
@RestController
|
@RequestMapping("/quality/inspectionReport")
|
public class InspectionReportController {
|
|
@Autowired
|
private IInspectionReportService inspectionReportService;
|
|
/**
|
* 查询检测报告列表
|
*/
|
@GetMapping("/listPage")
|
public AjaxResult listPage(Page<InspectionReport> page, InspectionReport report) {
|
IPage<InspectionReport> iPage = inspectionReportService.listPage(page, report);
|
return AjaxResult.success(iPage);
|
}
|
|
/**
|
* 获取检测报告详细信息
|
*/
|
@GetMapping("/{id}")
|
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
return AjaxResult.success(inspectionReportService.getById(id));
|
}
|
|
/**
|
* 新增检测报告
|
*/
|
@PostMapping
|
public AjaxResult add(@RequestBody InspectionReport report) {
|
// 默认状态为正常
|
if (report.getStatus() == null) {
|
report.setStatus("NORMAL");
|
}
|
return AjaxResult.success(inspectionReportService.save(report));
|
}
|
|
/**
|
* 修改检测报告
|
*/
|
@PutMapping
|
public AjaxResult edit(@RequestBody InspectionReport report) {
|
return AjaxResult.success(inspectionReportService.updateById(report));
|
}
|
|
/**
|
* 注销(软删除)检测报告
|
*/
|
@DeleteMapping("/{ids}")
|
public AjaxResult remove(@PathVariable Long[] ids) {
|
for (Long id : ids) {
|
InspectionReport report = new InspectionReport();
|
report.setId(id);
|
report.setStatus("CANCELLED");
|
inspectionReportService.updateById(report);
|
}
|
return AjaxResult.success();
|
}
|
}
|