File tree 1 file changed +11
-4
lines changed
src/main/kotlin/eom/improve/kafkaboot/service
1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ class FilmService(
35
35
fun deleteFilm (filmId : Int ) : Mono <Void > {
36
36
// need to implement cascade delete(maybe soft) for table data that set foreign key
37
37
return filmRepository.findById(filmId)
38
- .switchIfEmpty(Mono .error( RuntimeException (" Not registered film" )))
38
+ .switchIfEmpty(RuntimeException (" Not registered film" ).toMono( ))
39
39
.flatMap { filmEn ->
40
40
inventoryRepository.findAllByFilmId(filmEn.filmId)
41
41
.flatMap { inventoryEn ->
@@ -49,9 +49,16 @@ class FilmService(
49
49
}
50
50
.flatMap { rentalEn ->
51
51
rentalRepository.deleteByRentalId(rentalEn.rentalId)
52
- }
53
- }.then()
52
+ }.then(inventoryEn.toMono())
53
+ }
54
+ .flatMap { inventoryEn ->
55
+ println (inventoryEn.inventoryId)
56
+ inventoryRepository.deleteByInventoryId(inventoryEn.inventoryId)
57
+ }
58
+ .then(filmEn.toMono())
59
+ }
60
+ .flatMap { filmEn ->
61
+ filmRepository.deleteByFilmId(filmEn.filmId)
54
62
}
55
-
56
63
}
57
64
}
You can’t perform that action at this time.
0 commit comments