...
|
...
|
@@ -40,6 +40,7 @@ import org.springframework.web.bind.annotation.ResponseStatus; |
40
|
40
|
import org.springframework.web.bind.annotation.RestController;
|
41
|
41
|
import org.springframework.web.context.request.async.DeferredResult;
|
42
|
42
|
import org.thingsboard.common.util.JacksonUtil;
|
|
43
|
+import org.thingsboard.rule.engine.api.TbNodeException;
|
43
|
44
|
import org.thingsboard.rule.engine.api.msg.DeviceCredentialsUpdateNotificationMsg;
|
44
|
45
|
import org.thingsboard.server.common.data.*;
|
45
|
46
|
import org.thingsboard.server.common.data.audit.ActionType;
|
...
|
...
|
@@ -371,6 +372,23 @@ public class DeviceController extends BaseController { |
371
|
372
|
}
|
372
|
373
|
}
|
373
|
374
|
|
|
375
|
+
|
|
376
|
+ @PostMapping("/batch/customer/device/")
|
|
377
|
+ @ApiOperation("批量私有设备")
|
|
378
|
+ @PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
|
379
|
+ public ResponseEntity<String> batchCustomerDevice(
|
|
380
|
+ @ApiParam(value = "设备ID") @RequestParam(value = "deviceIds", required = false)List<String> deviceIds) throws ThingsboardException {
|
|
381
|
+ for (String deviceId:deviceIds) {
|
|
382
|
+
|
|
383
|
+ try {
|
|
384
|
+ unassignDeviceFromCustomer(deviceId);
|
|
385
|
+ } catch (ThingsboardException e) {
|
|
386
|
+ throw new ThingsboardException(e.getErrorCode());
|
|
387
|
+ }
|
|
388
|
+ }
|
|
389
|
+ return ResponseEntity.ok("私有成功");
|
|
390
|
+ }
|
|
391
|
+
|
374
|
392
|
@ApiOperation(value = "Unassign device from customer (unassignDeviceFromCustomer)",
|
375
|
393
|
notes = "Clears assignment of the device to customer. Customer will not be able to query device afterwards." + TENANT_AUTHORITY_PARAGRAPH)
|
376
|
394
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
...
|
...
|
@@ -407,6 +425,22 @@ public class DeviceController extends BaseController { |
407
|
425
|
}
|
408
|
426
|
}
|
409
|
427
|
|
|
428
|
+
|
|
429
|
+ @PostMapping("/batch/customer/public/device/")
|
|
430
|
+ @ApiOperation("批量公开设备")
|
|
431
|
+ @PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
|
432
|
+ public ResponseEntity<String> batchCustomerPublicDevice(
|
|
433
|
+ @ApiParam(value = "设备ID") @RequestParam(value = "deviceIds", required = false)List<String> deviceIds) throws ThingsboardException {
|
|
434
|
+ for (String deviceId:deviceIds) {
|
|
435
|
+ try {
|
|
436
|
+ assignDeviceToPublicCustomer(deviceId);
|
|
437
|
+ } catch (ThingsboardException e) {
|
|
438
|
+ throw new ThingsboardException(e.getErrorCode());
|
|
439
|
+ }
|
|
440
|
+ }
|
|
441
|
+ return ResponseEntity.ok("公开成功");
|
|
442
|
+ }
|
|
443
|
+
|
410
|
444
|
@ApiOperation(value = "Make device publicly available (assignDeviceToPublicCustomer)",
|
411
|
445
|
notes = "Device will be available for non-authorized (not logged-in) users. " +
|
412
|
446
|
"This is useful to create dashboards that you plan to share/embed on a publicly available website. " +
|
...
|
...
|
|