|
|
@@ -0,0 +1,71 @@
|
|
|
+package com.zswl.dataservice.controller.iot;
|
|
|
+
|
|
|
+import com.zswl.dataservice.model.mqtt.DeviceInfoAddParam;
|
|
|
+import com.zswl.dataservice.model.mqtt.DeviceInfoModel;
|
|
|
+import com.zswl.dataservice.model.mqtt.DeviceInfoSearchParam;
|
|
|
+import com.zswl.dataservice.service.iot.IotServiceImpl;
|
|
|
+import com.zswl.dataservice.service.mqtt.DeviceInfoService;
|
|
|
+import com.zswl.dataservice.utils.result.ResultContent;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.domain.Pageable;
|
|
|
+import org.springframework.data.web.PageableDefault;
|
|
|
+import org.springframework.util.Assert;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 设备管理 服务
|
|
|
+ *
|
|
|
+ * @author TRX
|
|
|
+ * @date 2024/3/21
|
|
|
+ */
|
|
|
+@RequestMapping("/iot")
|
|
|
+@RestController
|
|
|
+@Validated
|
|
|
+@Tag(name = "模版-物模型管理")
|
|
|
+public class IotController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ DeviceInfoService deviceInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ IotServiceImpl iotService;
|
|
|
+
|
|
|
+ @Parameter(in = ParameterIn.HEADER, name = "accessToken", required = false, description = "accessToken")
|
|
|
+ @Operation(summary = "添加设备")
|
|
|
+ @RequestMapping(value = "addDeviceInfo", method = {RequestMethod.POST})
|
|
|
+ public ResultContent addDeviceInfo(@RequestBody DeviceInfoAddParam param) {
|
|
|
+ Assert.hasText(param.getDeviceId(), "设备ID不能为空");
|
|
|
+ Assert.hasText(param.getDeviceName(), "设备名称不能为空");
|
|
|
+ return deviceInfoService.addDeviceInfo(param);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Parameter(in = ParameterIn.HEADER, name = "accessToken", required = false, description = "accessToken")
|
|
|
+ @Operation(summary = "设备列表-分页查询")
|
|
|
+ @RequestMapping(value = {"pageActivity"}, method = {RequestMethod.POST})
|
|
|
+ public ResultContent<Page<DeviceInfoModel>> pageActivity(@Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable, @Parameter(required = false) DeviceInfoSearchParam param) {
|
|
|
+ return deviceInfoService.pageDevice(pageable, param);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Parameter(in = ParameterIn.HEADER, name = "accessToken", required = false, description = "accessToken")
|
|
|
+ @Operation(summary = "删除设备")
|
|
|
+ @RequestMapping(value = "deleteDeviceInfo", method = {RequestMethod.GET})
|
|
|
+ public ResultContent deleteDeviceInfo(String deviceId) {
|
|
|
+ return deviceInfoService.deleteDeviceInfo(deviceId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Parameter(in = ParameterIn.HEADER, name = "accessToken", required = false, description = "accessToken")
|
|
|
+ @Operation(summary = "查询设备")
|
|
|
+ @RequestMapping(value = "getDeviceById", method = {RequestMethod.GET})
|
|
|
+ public ResultContent<DeviceInfoModel> getDeviceById(String deviceId) {
|
|
|
+ return deviceInfoService.getDeviceById(deviceId);
|
|
|
+ }
|
|
|
+}
|