File tree Expand file tree Collapse file tree 4 files changed +18
-1
lines changed
src/main/kotlin/eom/improve/kafkaboot Expand file tree Collapse file tree 4 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -17,4 +17,7 @@ interface FilmController {
17
17
18
18
@PostMapping(" /save" )
19
19
fun saveFilm (@Valid @RequestBody toBeSavedFilm : Film ) : Mono <Film >
20
+
21
+ @DeleteMapping(" /delete/{filmId}" )
22
+ fun deleteFilm (@PathVariable filmId : Int ) : Mono <Void >
20
23
}
Original file line number Diff line number Diff line change @@ -8,7 +8,6 @@ import org.springframework.web.bind.annotation.ResponseBody
8
8
import org.springframework.web.bind.annotation.RestControllerAdvice
9
9
import org.springframework.web.bind.support.WebExchangeBindException
10
10
import org.springframework.web.server.ServerWebExchange
11
- import reactor.core.publisher.Flux
12
11
import reactor.core.publisher.Mono
13
12
import reactor.kotlin.core.publisher.toMono
14
13
import java.util.stream.Collectors
@@ -32,4 +31,7 @@ class GlobalExceptionHandler {
32
31
).toMono()
33
32
}
34
33
// need to implement error logging publish to kafka
34
+ // detail message = WebExchangeBindException.message
35
+
36
+
35
37
}
Original file line number Diff line number Diff line change @@ -26,4 +26,8 @@ class FilmControllerImpl(
26
26
.flatMap { toBeSavedFilm.toMono() }
27
27
}
28
28
29
+ override fun deleteFilm (filmId : Int ) : Mono <Void > {
30
+ return filmService.deleteFilm(filmId)
31
+ }
32
+
29
33
}
Original file line number Diff line number Diff line change @@ -22,4 +22,12 @@ class FilmService(
22
22
fun saveFilm (toBeSavedFilm : FilmEntity ) : Mono <FilmEntity > {
23
23
return filmRepository.save(toBeSavedFilm);
24
24
}
25
+
26
+ fun deleteFilm (filmId : Int ) : Mono <Void > {
27
+ // need to implement cascade delete for table data that set foreign key
28
+ return filmRepository.findById(filmId)
29
+ .switchIfEmpty(Mono .error(RuntimeException (" Not registered film" )))
30
+ .flatMap { filmRepository.deleteById(filmId) }
31
+ .then()
32
+ }
25
33
}
You can’t perform that action at this time.
0 commit comments