package com.ruoyi.safety.controller;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
import com.ruoyi.framework.web.domain.AjaxResult;
|
import com.ruoyi.safety.pojo.SafetyInspectionRecord;
|
import com.ruoyi.safety.service.SafetyInspectionRecordService;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* Safety inspection record APIs.
|
*/
|
@RestController
|
@Api(tags = "safety-inspection-record")
|
@RequestMapping("/safety/inspection/record")
|
public class SafetyInspectionRecordController extends SafetyControllerSupport {
|
|
@Autowired
|
private SafetyInspectionRecordService recordService;
|
|
@Log(title = "safety-inspection-record-list", businessType = BusinessType.OTHER)
|
@ApiOperation("query safety inspection records by page")
|
@GetMapping("/list")
|
public AjaxResult list(Page<SafetyInspectionRecord> page,
|
SafetyInspectionRecord query,
|
@RequestParam(value = "startDate", required = false) String startDate,
|
@RequestParam(value = "endDate", required = false) String endDate,
|
@RequestParam(value = "pageNum", required = false) Long pageNum,
|
@RequestParam(value = "pageSize", required = false) Long pageSize) {
|
return AjaxResult.success(recordService.queryPage(buildPage(page, pageNum, pageSize), query, startDate, endDate));
|
}
|
|
@Log(title = "safety-inspection-record-add", businessType = BusinessType.INSERT)
|
@ApiOperation("add safety inspection record")
|
@PostMapping("/add")
|
public AjaxResult add(@RequestBody SafetyInspectionRecord record) {
|
return toAjax(recordService.saveSafety(record));
|
}
|
|
@Log(title = "safety-inspection-record-update", businessType = BusinessType.UPDATE)
|
@ApiOperation("update safety inspection record")
|
@PutMapping("/update")
|
public AjaxResult update(@RequestBody SafetyInspectionRecord record) {
|
return toAjax(recordService.updateSafety(record));
|
}
|
|
@Log(title = "safety-inspection-record-delete", businessType = BusinessType.DELETE)
|
@ApiOperation("delete safety inspection record")
|
@DeleteMapping("/delete/{id}")
|
public AjaxResult delete(@PathVariable Long id) {
|
return toAjax(recordService.deleteSafetyById(id));
|
}
|
|
@Log(title = "safety-inspection-record-sync", businessType = BusinessType.IMPORT)
|
@ApiOperation("sync mock subsystem inspection data")
|
@PostMapping("/sync")
|
public AjaxResult sync() {
|
List<SafetyInspectionRecord> records = recordService.syncMockSubsystemData();
|
Map<String, Object> data = new HashMap<String, Object>(2);
|
data.put("count", records.size());
|
data.put("records", records);
|
return AjaxResult.success(data);
|
}
|
}
|