Skip to content

Commit cf9541a

Browse files
committed
修改不存在的数据返回404错误
1 parent 23e3da2 commit cf9541a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/web/reactive/ReactiveServiceSaveController.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.hswebframework.web.authorization.annotation.Authorize;
1010
import org.hswebframework.web.authorization.annotation.SaveAction;
1111
import org.hswebframework.web.crud.service.ReactiveCrudService;
12+
import org.hswebframework.web.exception.NotFoundException;
1213
import org.springframework.web.bind.annotation.*;
1314
import reactor.core.publisher.Flux;
1415
import reactor.core.publisher.Mono;
@@ -174,6 +175,11 @@ default Mono<Boolean> update(@PathVariable K id, @RequestBody Mono<E> payload) {
174175
.flatMap(auth -> payload.map(entity -> applyAuthentication(entity, auth)))
175176
.switchIfEmpty(payload)
176177
.flatMap(entity -> getService().updateById(id, Mono.just(entity)))
178+
.doOnNext(i -> {
179+
if (i == 0) {
180+
throw new NotFoundException();
181+
}
182+
})
177183
.thenReturn(true);
178184

179185
}

0 commit comments

Comments
 (0)