|
@@ -0,0 +1,97 @@
|
|
|
+package cn.iocoder.yudao.module.pms.controller.admin;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDevicePageReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceSaveReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO;
|
|
|
+import cn.iocoder.yudao.module.pms.service.IotDeviceService;
|
|
|
+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 = "管理后台 - 设备台账")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/rq/iot-device")
|
|
|
+@Validated
|
|
|
+public class IotDeviceController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IotDeviceService iotDeviceService;
|
|
|
+
|
|
|
+ @PostMapping("/create")
|
|
|
+ @Operation(summary = "创建设备台账")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-device:create')")
|
|
|
+ public CommonResult<Long> createIotDevice(@Valid @RequestBody IotDeviceSaveReqVO createReqVO) {
|
|
|
+ return success(iotDeviceService.createIotDevice(createReqVO));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/update")
|
|
|
+ @Operation(summary = "更新设备台账")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-device:update')")
|
|
|
+ public CommonResult<Boolean> updateIotDevice(@Valid @RequestBody IotDeviceSaveReqVO updateReqVO) {
|
|
|
+ iotDeviceService.updateIotDevice(updateReqVO);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/delete")
|
|
|
+ @Operation(summary = "删除设备台账")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true)
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-device:delete')")
|
|
|
+ public CommonResult<Boolean> deleteIotDevice(@RequestParam("id") Long id) {
|
|
|
+ iotDeviceService.deleteIotDevice(id);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/get")
|
|
|
+ @Operation(summary = "获得设备台账")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-device:query')")
|
|
|
+ public CommonResult<IotDeviceRespVO> getIotDevice(@RequestParam("id") Long id) {
|
|
|
+ IotDeviceDO iotDevice = iotDeviceService.getIotDevice(id);
|
|
|
+ return success(BeanUtils.toBean(iotDevice, IotDeviceRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/page")
|
|
|
+ @Operation(summary = "获得设备台账分页")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-device:query')")
|
|
|
+ public CommonResult<PageResult<IotDeviceRespVO>> getIotDevicePage(@Valid IotDevicePageReqVO pageReqVO) {
|
|
|
+ PageResult<IotDeviceDO> pageResult = iotDeviceService.getIotDevicePage(pageReqVO);
|
|
|
+ return success(BeanUtils.toBean(pageResult, IotDeviceRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/export-excel")
|
|
|
+ @Operation(summary = "导出设备台账 Excel")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-device:export')")
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
+ public void exportIotDeviceExcel(@Valid IotDevicePageReqVO pageReqVO,
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ List<IotDeviceDO> list = iotDeviceService.getIotDevicePage(pageReqVO).getList();
|
|
|
+ // 导出 Excel
|
|
|
+ ExcelUtils.write(response, "设备台账.xls", "数据", IotDeviceRespVO.class,
|
|
|
+ BeanUtils.toBean(list, IotDeviceRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|