Browse Source

优化creatorId

zhou-hao 4 years ago
parent
commit
5b193dd183

+ 5 - 3
jetlinks-manager/device-manager/src/main/java/org/jetlinks/community/device/web/DeviceInstanceController.java

@@ -14,6 +14,7 @@ import org.hswebframework.web.api.crud.entity.PagerResult;
 import org.hswebframework.web.api.crud.entity.QueryNoPagingOperation;
 import org.hswebframework.web.api.crud.entity.QueryOperation;
 import org.hswebframework.web.api.crud.entity.QueryParamEntity;
+import org.hswebframework.web.authorization.Authentication;
 import org.hswebframework.web.authorization.annotation.*;
 import org.hswebframework.web.bean.FastBeanCopier;
 import org.hswebframework.web.crud.web.reactive.ReactiveServiceCrudController;
@@ -166,9 +167,10 @@ public class DeviceInstanceController implements
     @PostMapping
     @Operation(summary = "新建设备")
     public Mono<DeviceInstanceEntity> add(@RequestBody Mono<DeviceInstanceEntity> payload) {
-        return payload.flatMap(entity -> service.insert(Mono.just(entity))
-            .onErrorMap(DuplicateKeyException.class, err -> new BusinessException("设备ID已存在", err))
-            .thenReturn(entity));
+        return Mono
+            .zip(payload, Authentication.currentReactive(), this::applyAuthentication)
+            .flatMap(entity -> service.insert(Mono.just(entity)).thenReturn(entity))
+            .onErrorMap(DuplicateKeyException.class, err -> new BusinessException("设备ID已存在", err));
     }
 
     /**