|
|
@@ -0,0 +1,94 @@
|
|
|
+package cn.iocoder.yudao.module.pms.controller.admin.qhse.law;
|
|
|
+
|
|
|
+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.law.vo.QhseLawPageReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.law.vo.QhseLawRespVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.law.vo.QhseLawSaveReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.law.QhseLawDO;
|
|
|
+import cn.iocoder.yudao.module.pms.service.qhse.law.QhseLawService;
|
|
|
+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-law")
|
|
|
+@Validated
|
|
|
+public class QhseLawController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private QhseLawService qhseLawService;
|
|
|
+
|
|
|
+ @PostMapping("/create")
|
|
|
+ @Operation(summary = "创建QHSE法规及行业标准")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:qhse-law:create')")
|
|
|
+ public CommonResult<Long> createQhseLaw(@Valid @RequestBody QhseLawSaveReqVO createReqVO) {
|
|
|
+ return success(qhseLawService.createQhseLaw(createReqVO));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/update")
|
|
|
+ @Operation(summary = "更新QHSE法规及行业标准")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:qhse-law:update')")
|
|
|
+ public CommonResult<Boolean> updateQhseLaw(@Valid @RequestBody QhseLawSaveReqVO updateReqVO) {
|
|
|
+ qhseLawService.updateQhseLaw(updateReqVO);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/delete")
|
|
|
+ @Operation(summary = "删除QHSE法规及行业标准")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true)
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:qhse-law:delete')")
|
|
|
+ public CommonResult<Boolean> deleteQhseLaw(@RequestParam("id") Long id) {
|
|
|
+ qhseLawService.deleteQhseLaw(id);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/get")
|
|
|
+ @Operation(summary = "获得QHSE法规及行业标准")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:qhse-law:query')")
|
|
|
+ public CommonResult<QhseLawRespVO> getQhseLaw(@RequestParam("id") Long id) {
|
|
|
+ QhseLawDO qhseLaw = qhseLawService.getQhseLaw(id);
|
|
|
+ return success(BeanUtils.toBean(qhseLaw, QhseLawRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/page")
|
|
|
+ @Operation(summary = "获得QHSE法规及行业标准分页")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:qhse-law:query')")
|
|
|
+ public CommonResult<PageResult<QhseLawRespVO>> getQhseLawPage(@Valid QhseLawPageReqVO pageReqVO) {
|
|
|
+ PageResult<QhseLawDO> pageResult = qhseLawService.getQhseLawPage(pageReqVO);
|
|
|
+ return success(BeanUtils.toBean(pageResult, QhseLawRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/export-excel")
|
|
|
+ @Operation(summary = "导出QHSE法规及行业标准 Excel")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:qhse-law:export')")
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
+ public void exportQhseLawExcel(@Valid QhseLawPageReqVO pageReqVO,
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ List<QhseLawDO> list = qhseLawService.getQhseLawPage(pageReqVO).getList();
|
|
|
+ // 导出 Excel
|
|
|
+ ExcelUtils.write(response, "QHSE法规及行业标准.xls", "数据", QhseLawRespVO.class,
|
|
|
+ BeanUtils.toBean(list, QhseLawRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|