package com.yuanchu.mom.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.mom.pojo.DeviceAccidentReport;
import com.yuanchu.mom.service.DeviceAccidentReportService;
import com.yuanchu.mom.utils.JackSonUtil;
import com.yuanchu.mom.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
/**
*
* 设备事故报告单 前端控制器
*
*
* @author 江苏鵷雏网络科技有限公司
* @since 2024-12-17 06:31:12
*/
@Api(tags = "设备事故报告单")
@AllArgsConstructor
@RestController
@RequestMapping("/deviceAccidentReport")
public class DeviceAccidentReportController {
private DeviceAccidentReportService deviceAccidentReportService;
/**
* 设备事故报告列表
* @param data
* @return
*/
@ApiOperation(value = "设备事故报告列表")
@PostMapping("/pageDeviceAccidentReport")
public Result> pageDeviceAccidentReport(@RequestBody Map data) throws Exception {
Page page = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("page")), Page.class);
DeviceAccidentReport deviceAccidentReport = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("entity")), DeviceAccidentReport.class);
return Result.success(deviceAccidentReportService.pageDeviceAccidentReport(page, deviceAccidentReport));
}
/**
* 查询设备事故报告
* @return
*/
@ApiOperation(value = "查询设备事故报告")
@GetMapping("/getDeviceAccidentReport")
public Result getDeviceAccidentReport(Integer accidentReportId){
return Result.success(deviceAccidentReportService.getById(accidentReportId));
}
/**
* 删除设备事故报告
* @return
*/
@ApiOperation(value = "删除设备事故报告")
@GetMapping("/delDeviceAccidentReport")
public Result delDeviceAccidentReport(Integer accidentReportId){
return Result.success(deviceAccidentReportService.removeById(accidentReportId));
}
/**
* 新增设备事故报告
* @return
*/
@ApiOperation(value = "新增设备事故报告")
@PostMapping("/addDeviceAccidentReport")
public Result addDeviceAccidentReport(@RequestBody DeviceAccidentReport deviceAccidentReport){
return Result.success(deviceAccidentReportService.addDeviceAccidentReport(deviceAccidentReport));
}
/**
* 导出设备事故报告
* @param accidentReportId 设备事故报告id
* @param response 响应
*/
@ApiOperation(value = "导出设备事故报告")
@GetMapping("/exportDeviceAccidentReport")
public Result exportDeviceAccidentReport(Integer accidentReportId, HttpServletResponse response) {
deviceAccidentReportService.exportDeviceAccidentReport(accidentReportId, response);
return Result.success();
}
}