优化creatorId

This commit is contained in:
zhou-hao 2020-10-26 12:50:54 +08:00
parent 3e0c6cb2bc
commit 5b193dd183
1 changed files with 5 additions and 3 deletions

View File

@ -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));
}
/**