|
@@ -0,0 +1,94 @@
|
|
|
|
|
+package cn.iocoder.yudao.module.pms.controller.admin.qhse.accident;
|
|
|
|
|
+
|
|
|
|
|
+import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
|
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
|
|
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.accident.vo.QhseAccidentCasePageReqVO;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.accident.vo.QhseAccidentCaseRespVO;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.accident.vo.QhseAccidentCaseSaveReqVO;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.accident.QhseAccidentCaseDO;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.service.qhse.accident.QhseAccidentCaseService;
|
|
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
+import javax.validation.Valid;
|
|
|
|
|
+import java.io.IOException;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
|
|
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
|
|
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+@Tag(name = "管理后台 - QHSE事故案例")
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("/rq/qhse-accident-case")
|
|
|
|
|
+@Validated
|
|
|
|
|
+public class QhseAccidentCaseController {
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private QhseAccidentCaseService qhseAccidentCaseService;
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/create")
|
|
|
|
|
+ @Operation(summary = "创建QHSE事故案例")
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:qhse-accident-case:create')")
|
|
|
|
|
+ public CommonResult<Long> createQhseAccidentCase(@Valid @RequestBody QhseAccidentCaseSaveReqVO createReqVO) {
|
|
|
|
|
+ return success(qhseAccidentCaseService.createQhseAccidentCase(createReqVO));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PutMapping("/update")
|
|
|
|
|
+ @Operation(summary = "更新QHSE事故案例")
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:qhse-accident-case:update')")
|
|
|
|
|
+ public CommonResult<Boolean> updateQhseAccidentCase(@Valid @RequestBody QhseAccidentCaseSaveReqVO updateReqVO) {
|
|
|
|
|
+ qhseAccidentCaseService.updateQhseAccidentCase(updateReqVO);
|
|
|
|
|
+ return success(true);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @DeleteMapping("/delete")
|
|
|
|
|
+ @Operation(summary = "删除QHSE事故案例")
|
|
|
|
|
+ @Parameter(name = "id", description = "编号", required = true)
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:qhse-accident-case:delete')")
|
|
|
|
|
+ public CommonResult<Boolean> deleteQhseAccidentCase(@RequestParam("id") Long id) {
|
|
|
|
|
+ qhseAccidentCaseService.deleteQhseAccidentCase(id);
|
|
|
|
|
+ return success(true);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/get")
|
|
|
|
|
+ @Operation(summary = "获得QHSE事故案例")
|
|
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:qhse-accident-case:query')")
|
|
|
|
|
+ public CommonResult<QhseAccidentCaseRespVO> getQhseAccidentCase(@RequestParam("id") Long id) {
|
|
|
|
|
+ QhseAccidentCaseDO qhseAccidentCase = qhseAccidentCaseService.getQhseAccidentCase(id);
|
|
|
|
|
+ return success(BeanUtils.toBean(qhseAccidentCase, QhseAccidentCaseRespVO.class));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/page")
|
|
|
|
|
+ @Operation(summary = "获得QHSE事故案例分页")
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:qhse-accident-case:query')")
|
|
|
|
|
+ public CommonResult<PageResult<QhseAccidentCaseRespVO>> getQhseAccidentCasePage(@Valid QhseAccidentCasePageReqVO pageReqVO) {
|
|
|
|
|
+ PageResult<QhseAccidentCaseDO> pageResult = qhseAccidentCaseService.getQhseAccidentCasePage(pageReqVO);
|
|
|
|
|
+ return success(BeanUtils.toBean(pageResult, QhseAccidentCaseRespVO.class));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/export-excel")
|
|
|
|
|
+ @Operation(summary = "导出QHSE事故案例 Excel")
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:qhse-accident-case:export')")
|
|
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
|
|
+ public void exportQhseAccidentCaseExcel(@Valid QhseAccidentCasePageReqVO pageReqVO,
|
|
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
|
|
+ List<QhseAccidentCaseDO> list = qhseAccidentCaseService.getQhseAccidentCasePage(pageReqVO).getList();
|
|
|
|
|
+ // 导出 Excel
|
|
|
|
|
+ ExcelUtils.write(response, "QHSE事故案例.xls", "数据", QhseAccidentCaseRespVO.class,
|
|
|
|
|
+ BeanUtils.toBean(list, QhseAccidentCaseRespVO.class));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|