ЛР4 полность работают фильмы и жанры
This commit is contained in:
parent
b07faa67c5
commit
361d0a65ff
@ -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">
|
||||
</DataTable>
|
||||
<div class="mb-3">
|
||||
<label for="genres" class="form-label">Добавить жанр</label>
|
||||
<label for="genres" class="form-label">Жанры</label>
|
||||
<select class="form-select" id="genres" required>
|
||||
<option disabled value="">Выберите жанр</option>
|
||||
<option v-for="genre in this.genres"
|
||||
@ -96,7 +96,11 @@
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<button class="btn btn-outline-secondary" type="button" id="addGenreButton"
|
||||
@click.prevent="addGenre(data.id)">Добавить</button>
|
||||
<div class="d-flex justify-content-between">
|
||||
<button class="btn btn-outline-secondary" type="button" id="addGenreButton"
|
||||
@click.prevent="addGenre(data.id)">Добавить</button>
|
||||
<button class="btn btn-outline-secondary" type="button" id="delGenreButton"
|
||||
@click.prevent="delGenre(data.id)">Удалить</button>
|
||||
</div>
|
||||
</Modal>
|
||||
</template>
|
BIN
data.mv.db
BIN
data.mv.db
Binary file not shown.
@ -71,13 +71,10 @@ public class FilmService {
|
||||
|
||||
@Transactional
|
||||
public Film addGenre(Long filmId, Long genreId) {
|
||||
final Optional<Film> 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<Film> 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));
|
||||
|
Loading…
Reference in New Issue
Block a user