|
|
@@ -0,0 +1,98 @@
|
|
|
+package cn.iocoder.yudao.module.pms.controller.admin.qhse.danger;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.danger.vo.IotDangerSourcePageReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.danger.vo.IotDangerSourceRespVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.danger.vo.IotDangerSourceSaveReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.danger.IotDangerSourceDO;
|
|
|
+import cn.iocoder.yudao.module.pms.service.qhse.danger.IotDangerSourceService;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+import java.io.IOException;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import javax.validation.Valid;
|
|
|
+
|
|
|
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
|
|
+
|
|
|
+
|
|
|
+@Tag(name = "管理后台 - 危险源")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/rq/iot-danger-source")
|
|
|
+@Validated
|
|
|
+public class IotDangerSourceController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IotDangerSourceService iotDangerSourceService;
|
|
|
+
|
|
|
+ @PostMapping("/create")
|
|
|
+ @Operation(summary = "创建危险源")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-danger-source:create')")
|
|
|
+ public CommonResult<Long> createIotDangerSource(@Valid @RequestBody IotDangerSourceSaveReqVO createReqVO) {
|
|
|
+ return success(iotDangerSourceService.createIotDangerSource(createReqVO));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/update")
|
|
|
+ @Operation(summary = "更新危险源")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-danger-source:update')")
|
|
|
+ public CommonResult<Boolean> updateIotDangerSource(@Valid @RequestBody IotDangerSourceSaveReqVO updateReqVO) {
|
|
|
+ iotDangerSourceService.updateIotDangerSource(updateReqVO);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/delete")
|
|
|
+ @Operation(summary = "删除危险源")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true)
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-danger-source:delete')")
|
|
|
+ public CommonResult<Boolean> deleteIotDangerSource(@RequestParam("id") Long id) {
|
|
|
+ iotDangerSourceService.deleteIotDangerSource(id);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/get")
|
|
|
+ @Operation(summary = "获得危险源")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-danger-source:query')")
|
|
|
+ public CommonResult<IotDangerSourceRespVO> getIotDangerSource(@RequestParam("id") Long id) {
|
|
|
+ IotDangerSourceDO iotDangerSource = iotDangerSourceService.getIotDangerSource(id);
|
|
|
+ return success(BeanUtils.toBean(iotDangerSource, IotDangerSourceRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/page")
|
|
|
+ @Operation(summary = "获得危险源分页")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-danger-source:query')")
|
|
|
+ public CommonResult<PageResult<IotDangerSourceRespVO>> getIotDangerSourcePage(@Valid IotDangerSourcePageReqVO pageReqVO) {
|
|
|
+ PageResult<IotDangerSourceDO> pageResult = iotDangerSourceService.getIotDangerSourcePage(pageReqVO);
|
|
|
+ return success(BeanUtils.toBean(pageResult, IotDangerSourceRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/export-excel")
|
|
|
+ @Operation(summary = "导出危险源 Excel")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-danger-source:export')")
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
+ public void exportIotDangerSourceExcel(@Valid IotDangerSourcePageReqVO pageReqVO,
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ List<IotDangerSourceDO> list = iotDangerSourceService.getIotDangerSourcePage(pageReqVO).getList();
|
|
|
+ // 导出 Excel
|
|
|
+ ExcelUtils.write(response, "危险源.xls", "数据", IotDangerSourceRespVO.class,
|
|
|
+ BeanUtils.toBean(list, IotDangerSourceRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|