|
@@ -0,0 +1,97 @@
|
|
|
|
+package cn.iocoder.yudao.module.pms.controller.admin;
|
|
|
|
+
|
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.vo.IotTreePageReqVO;
|
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.vo.IotTreeRespVO;
|
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.vo.IotTreeSaveReqVO;
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.IotTreeDO;
|
|
|
|
+import cn.iocoder.yudao.module.pms.service.IotTreeService;
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+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 javax.validation.constraints.*;
|
|
|
|
+import javax.validation.*;
|
|
|
|
+import javax.servlet.http.*;
|
|
|
|
+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 static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+@Tag(name = "管理后台 - pms树")
|
|
|
|
+@RestController
|
|
|
|
+@RequestMapping("/rq/iot-tree")
|
|
|
|
+@Validated
|
|
|
|
+public class IotTreeController {
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private IotTreeService iotTreeService;
|
|
|
|
+
|
|
|
|
+ @PostMapping("/create")
|
|
|
|
+ @Operation(summary = "创建pms树")
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-tree:create')")
|
|
|
|
+ public CommonResult<Long> createIotTree(@Valid @RequestBody IotTreeSaveReqVO createReqVO) {
|
|
|
|
+ return success(iotTreeService.createIotTree(createReqVO));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PutMapping("/update")
|
|
|
|
+ @Operation(summary = "更新pms树")
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-tree:update')")
|
|
|
|
+ public CommonResult<Boolean> updateIotTree(@Valid @RequestBody IotTreeSaveReqVO updateReqVO) {
|
|
|
|
+ iotTreeService.updateIotTree(updateReqVO);
|
|
|
|
+ return success(true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @DeleteMapping("/delete")
|
|
|
|
+ @Operation(summary = "删除pms树")
|
|
|
|
+ @Parameter(name = "id", description = "编号", required = true)
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-tree:delete')")
|
|
|
|
+ public CommonResult<Boolean> deleteIotTree(@RequestParam("id") Long id) {
|
|
|
|
+ iotTreeService.deleteIotTree(id);
|
|
|
|
+ return success(true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/get")
|
|
|
|
+ @Operation(summary = "获得pms树")
|
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-tree:query')")
|
|
|
|
+ public CommonResult<IotTreeRespVO> getIotTree(@RequestParam("id") Long id) {
|
|
|
|
+ IotTreeDO iotTree = iotTreeService.getIotTree(id);
|
|
|
|
+ return success(BeanUtils.toBean(iotTree, IotTreeRespVO.class));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/page")
|
|
|
|
+ @Operation(summary = "获得pms树分页")
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-tree:query')")
|
|
|
|
+ public CommonResult<PageResult<IotTreeRespVO>> getIotTreePage(@Valid IotTreePageReqVO pageReqVO) {
|
|
|
|
+ PageResult<IotTreeDO> pageResult = iotTreeService.getIotTreePage(pageReqVO);
|
|
|
|
+ return success(BeanUtils.toBean(pageResult, IotTreeRespVO.class));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/export-excel")
|
|
|
|
+ @Operation(summary = "导出pms树 Excel")
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-tree:export')")
|
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
|
+ public void exportIotTreeExcel(@Valid IotTreePageReqVO pageReqVO,
|
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
|
+ List<IotTreeDO> list = iotTreeService.getIotTreePage(pageReqVO).getList();
|
|
|
|
+ // 导出 Excel
|
|
|
|
+ ExcelUtils.write(response, "pms树.xls", "数据", IotTreeRespVO.class,
|
|
|
|
+ BeanUtils.toBean(list, IotTreeRespVO.class));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|