diff --git a/Frontend/vue-project/src/components/CatalogFilms.vue b/Frontend/vue-project/src/components/CatalogFilms.vue index 6dae233..0db422f 100644 --- a/Frontend/vue-project/src/components/CatalogFilms.vue +++ b/Frontend/vue-project/src/components/CatalogFilms.vue @@ -33,13 +33,13 @@ }, methods: { addGenre(filmId) { - let genreId = document.getElementById('genre').value; - let response = axios.post(`http://localhost:8080/film/add_genre/${filmId}`); + let genreId = document.getElementById('genres').value; + let response = axios.post(`http://localhost:8080/film/add_genre/${filmId}?genre_id=${genreId}`); console.log(response); }, delGenre(filmId) { - let genreId = document.getElementById('genre').value; - let response = axios.delete(`http://localhost:8080/film/del_genre/${filmId}`); + let genreId = document.getElementById('genres').value; + let response = axios.delete(`http://localhost:8080/film/del_genre/${filmId}?genre_id=${genreId}`); console.log(response); }, itemsGenres(genreIds) { @@ -87,7 +87,7 @@ :selectedItems="this.selectedItemsGenres">
- +
- +
+ + +
\ No newline at end of file diff --git a/data.mv.db b/data.mv.db index a977f73..f110373 100644 Binary files a/data.mv.db and b/data.mv.db differ diff --git a/src/main/java/ru/ulstu/is/lab1/DataBase/service/FilmService.java b/src/main/java/ru/ulstu/is/lab1/DataBase/service/FilmService.java index f4f9866..b912be8 100644 --- a/src/main/java/ru/ulstu/is/lab1/DataBase/service/FilmService.java +++ b/src/main/java/ru/ulstu/is/lab1/DataBase/service/FilmService.java @@ -71,13 +71,10 @@ public class FilmService { @Transactional public Film addGenre(Long filmId, Long genreId) { - final Optional filmOpt = filmRepository.findById(filmId); - - if (filmOpt.isEmpty()) { + Film film = findFilm(filmId); + if (film == null) { throw new EntityNotFoundException(String.format("Film with id [%s] is not found", filmId)); - } - Film film = filmOpt.get(); - + } final Genre genre = genreService.findGenre(genreId); if (genre == null) { throw new EntityNotFoundException(String.format("Genre with id [%s] is not found", genreId)); @@ -89,13 +86,10 @@ public class FilmService { @Transactional public Film deleteGenre(Long filmId, Long genreId) { - final Optional filmOpt = filmRepository.findById(filmId); - - if (filmOpt.isEmpty()) { + Film film = findFilm(filmId); + if (film == null) { throw new EntityNotFoundException(String.format("Film with id [%s] is not found", filmId)); } - Film film = filmOpt.get(); - final Genre genre = genreService.findGenre(genreId); if (genre == null) { throw new EntityNotFoundException(String.format("Genre with id [%s] is not found", genreId));