+
\ No newline at end of file
diff --git a/Frontend/vue-project/src/components/CatalogGenres.vue b/Frontend/vue-project/src/components/CatalogGenres.vue
index b8ac479..75ba887 100644
--- a/Frontend/vue-project/src/components/CatalogGenres.vue
+++ b/Frontend/vue-project/src/components/CatalogGenres.vue
@@ -83,6 +83,7 @@
+
Жанры
diff --git a/Frontend/vue-project/src/main.js b/Frontend/vue-project/src/main.js
index f2c32b6..3183483 100644
--- a/Frontend/vue-project/src/main.js
+++ b/Frontend/vue-project/src/main.js
@@ -3,11 +3,13 @@ import { createRouter, createWebHistory } from 'vue-router'
import App from './App.vue'
import Index from './components/Index.vue'
import CatalogGenres from './components/CatalogGenres.vue'
+import CatalogFilms from './components/CatalogFilms.vue'
const routes = [
{ path: '/', redirect: '/index' },
{ path: '/index', component: Index},
- { path: '/catalogs/genres', component: CatalogGenres}
+ { path: '/catalogs/genres', component: CatalogGenres},
+ { path: '/catalogs/films', component: CatalogFilms}
]
const router = createRouter({
diff --git a/Frontend/vue-project/src/models/Collection.js b/Frontend/vue-project/src/models/Collection.js
index 69163d5..8b087dd 100644
--- a/Frontend/vue-project/src/models/Collection.js
+++ b/Frontend/vue-project/src/models/Collection.js
@@ -1,26 +1,7 @@
export default class Collection {
constructor(data) {
- this._id = data?.id;
- this._name = data?.name;
- this._filmIds = data?.filmIds;
- }
-
- get id() {
- return this._id;
- }
-
- get name() {
- return this._name;
- }
-
- set name(value) {
- if (typeof value !== 'string' || value === null || value.length == 0) {
- throw 'New name value ' + value + ' is not a string or empty';
- }
- this._name = value;
- }
-
- get filmIds() {
- return this._filmIds;
+ this.id = data?.id;
+ this.name = data?.name;
+ this.filmIds = data?.filmIds;
}
}
\ No newline at end of file
diff --git a/Frontend/vue-project/src/models/Film.js b/Frontend/vue-project/src/models/Film.js
index aa7c7d0..85d13e2 100644
--- a/Frontend/vue-project/src/models/Film.js
+++ b/Frontend/vue-project/src/models/Film.js
@@ -1,26 +1,7 @@
export default class Film {
constructor(data) {
- this._id = data?.id;
- this._name = data?.name;
- this._genreIds = data?.genreIds;
- }
-
- get id() {
- return this._id;
- }
-
- get name() {
- return this._name;
- }
-
- set name(value) {
- if (typeof value !== 'string' || value === null || value.length == 0) {
- throw 'New name value ' + value + ' is not a string or empty';
- }
- this._name = value;
- }
-
- get genreIds() {
- return this._genreIds;
+ this.id = data?.id;
+ this.name = data?.name;
+ this.genreIds = data?.genreIds;
}
}
\ No newline at end of file
diff --git a/data.mv.db b/data.mv.db
index 2713b74..a570385 100644
Binary files a/data.mv.db and b/data.mv.db differ
diff --git a/src/main/java/ru/ulstu/is/lab1/DataBase/controller/FilmController.java b/src/main/java/ru/ulstu/is/lab1/DataBase/controller/FilmController.java
index 5ca4a30..63f6b6c 100644
--- a/src/main/java/ru/ulstu/is/lab1/DataBase/controller/FilmController.java
+++ b/src/main/java/ru/ulstu/is/lab1/DataBase/controller/FilmController.java
@@ -45,18 +45,8 @@ public class FilmController {
filmService.deleteAllFilms();
}
- @PostMapping("/add_genre/{id}")
- public FilmDTO addGenre(@PathVariable Long id, @RequestParam Long genre_id) {
- return new FilmDTO(filmService.addGenre(id, genre_id));
- }
-
- @DeleteMapping("/del_genre/{id}")
- public FilmDTO delGenre(@PathVariable Long id, @RequestParam Long genre_id) {
- return new FilmDTO(filmService.deleteGenre(id, genre_id));
- }
-
- @DeleteMapping("/del_genres/{id}")
- public FilmDTO delGenres(@PathVariable Long id) {
- return new FilmDTO(filmService.deleteGenres(id));
+ @PostMapping("/add_genres/{id}")
+ public FilmDTO addGenres(@PathVariable Long id, @RequestBody @Valid List genreIds) {
+ return new FilmDTO(filmService.addGenres(id, genreIds));
}
}
diff --git a/src/main/java/ru/ulstu/is/lab1/DataBase/controller/FilmDTO.java b/src/main/java/ru/ulstu/is/lab1/DataBase/controller/FilmDTO.java
index 2b18abd..bea8110 100644
--- a/src/main/java/ru/ulstu/is/lab1/DataBase/controller/FilmDTO.java
+++ b/src/main/java/ru/ulstu/is/lab1/DataBase/controller/FilmDTO.java
@@ -27,4 +27,6 @@ public class FilmDTO {
public List getGenreIds(){
return genreIds;
}
+ public void setId(long id){ this.id = id; }
+ public void setName(String name){ this.name = name; }
}
diff --git a/src/main/java/ru/ulstu/is/lab1/DataBase/controller/GenreDTO.java b/src/main/java/ru/ulstu/is/lab1/DataBase/controller/GenreDTO.java
index ad7efbb..9818312 100644
--- a/src/main/java/ru/ulstu/is/lab1/DataBase/controller/GenreDTO.java
+++ b/src/main/java/ru/ulstu/is/lab1/DataBase/controller/GenreDTO.java
@@ -17,9 +17,7 @@ public class GenreDTO {
public String getName(){
return name;
}
- public void setId(long id){
- this.id = id;
- }
+ public void setId(long id){ this.id = id; }
public void setName(String name){
this.name = name;
}
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 9895231..74bb293 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
@@ -69,43 +69,16 @@ public class FilmService {
}
@Transactional
- public Film addGenre(Long filmId, Long genreId) {
- Film film = findFilm(filmId);
- if (film == null) {
- throw new EntityNotFoundException(String.format("Film with id [%s] is not found", filmId));
- }
- final Genre genre = genreService.findGenre(genreId);
- if (genre == null) {
- throw new EntityNotFoundException(String.format("Genre with id [%s] is not found", genreId));
- }
-
- film.addGenre(genre);
- return filmRepository.save(film);
- }
-
- @Transactional
- public Film deleteGenre(Long filmId, Long genreId) {
+ public Film addGenres(Long filmId, List genreIds) {
Film film = findFilm(filmId);
if (film == null) {
throw new EntityNotFoundException(String.format("Film with id [%s] is not found", filmId));
}
- final Genre genre = genreService.findGenre(genreId);
- if (genre == null) {
- throw new EntityNotFoundException(String.format("Genre with id [%s] is not found", genreId));
- }
-
- film.removeGenre(genre);
- return filmRepository.save(film);
- }
-
- @Transactional
- public Film deleteGenres(Long filmId) {
- Film film = findFilm(filmId);
- if (film == null) {
- throw new EntityNotFoundException(String.format("Film with id [%s] is not found", filmId));
- }
-
film.removeGenres();
+ for(Long genreId : genreIds) {
+ final Genre genre = genreService.findGenre(genreId);
+ film.addGenre(genre);
+ }
return filmRepository.save(film);
}
}