Changes in / [7fafead:7bc8942] in Git
- Files:
-
- 1 added
- 180 deleted
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
README.md
r7fafead r7bc8942 3 3 <div style="float: left; width: 60%;"> 4 4 5 <img src="/img/logo.png" style="display: block; float:left; height: auto; width: 30%;" align="right" alt="q">6 <h4 style="display: block; font-weight: normal; text-align: justify; float: right">Предмет: Бази на податоци 2021/2022/Зимски</h 4><br>5 <img src="/img/logo.png" style="display: block; float:left; height: auto; width: 30%;" align="right"> 6 <h4 style="display: block; font-weight: normal; text-align: justify; float: right">Предмет: Бази на податоци 2021/2022/Зимски</h2><br> 7 7 <h4 style="display: block; font-weight: normal; text-align: justify; float: right">Под менторство на вонр. проф. д-р Вангел Ајановски и демонстр. м-р Ненад Анчев</h4><br> 8 8 <h4 style="display: block; font-weight: normal; text-align: justify; float: right">Започнат: Ноември 2021</h4><br><br> … … 23 23 <li>Мартин Николов (193113)</li> 24 24 </ol> 25 </div> -
pom.xml
r7fafead r7bc8942 42 42 <groupId>org.postgresql</groupId> 43 43 <artifactId>postgresql</artifactId> 44 <scope>runtime</scope> 44 45 </dependency> 45 46 <dependency> … … 58 59 <scope>test</scope> 59 60 </dependency> 60 61 61 <dependency> 62 62 <groupId>org.springframework.boot</groupId> 63 63 <artifactId>spring-boot-starter-data-jpa</artifactId> 64 <version>RELEASE</version> 65 <scope>compile</scope> 64 66 </dependency> 65 <dependency>66 <groupId>org.springframework.boot</groupId>67 <artifactId>spring-boot-actuator</artifactId>68 </dependency>69 <dependency>70 <groupId>com.h2database</groupId>71 <artifactId>h2</artifactId>72 </dependency>73 74 75 76 67 </dependencies> 77 68 -
src/main/java/com/wediscussmovies/project/model/Discussion.java
r7fafead r7bc8942 1 1 package com.wediscussmovies.project.model; 2 2 3 import com.wediscussmovies.project.model.enumerations.DiscussionType;4 3 import lombok.Data; 5 4 6 5 import javax.persistence.*; 7 6 import java.sql.Date; 8 import java.util.Collection;9 7 import java.util.List; 10 import java.util.Objects;11 8 12 9 @Data 13 10 @Entity 14 @Table (name = "discussions", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies")11 @Table (name="discussions") 15 12 public class Discussion { 13 @Id 14 @GeneratedValue 15 private int discussion_id; 16 16 17 @GeneratedValue(strategy = GenerationType.IDENTITY) 18 @Id 19 @Column(name = "discussion_id") 20 private Long id; 17 @ManyToOne 18 @Column(name = "movie_id") 19 private Movie movie; 21 20 22 @Enumerated 23 private DiscussionType type; 21 @ManyToOne() 22 @Column(name = "person_id") 23 private Person person; 24 24 25 @ManyToOne 26 @Column(name = "user_id") 27 private User user; 28 29 @Column(name = "text", length = 1000, nullable = false) 25 30 private String text; 26 31 32 @Column(name = "title", length = 1000, nullable = false) 27 33 private String title; 28 34 35 @Column(name = "date", nullable = false) 29 36 private Date date; 30 37 31 32 33 34 35 @ManyToOne 36 @JoinColumn(name = "user_id", referencedColumnName = "user_id", nullable = false) 37 private User user; 38 39 @ManyToOne 40 @JoinColumn(name = "movie_id", referencedColumnName = "movie_id") 41 private Movie movie; 42 43 @ManyToOne 44 @JoinColumn(name = "person_id", referencedColumnName = "person_id") 45 private Person person; 46 47 48 49 50 51 52 public Discussion(DiscussionType type, String text, String title, Date date, User user, Movie movie, Person person, List<Reply> replies) { 53 this.type = type; 54 this.text = text; 55 this.title = title; 56 this.date = date; 57 this.user = user; 58 this.movie = movie; 59 this.person = person; 60 } 38 @Column(name = "type", nullable = false) 39 private DiscussionType type; 40 @OneToMany 41 private List<Reply> replies; 61 42 62 43 public Discussion() { 63 44 } 64 45 46 public Discussion(String title, String text, User user, Movie movie, Date valueOf) { 47 this.title = title; 48 this.text = text; 49 this.user = user; 50 this.date = valueOf; 51 this.movie = movie; 52 this.type = DiscussionType.M; 53 } 54 55 public Discussion(String title, String text, User user, Person person, Date valueOf) { 56 this.title = title; 57 this.text = text; 58 this.user = user; 59 this.date = valueOf; 60 this.person = person; 61 this.type = DiscussionType.P; 62 } 63 65 64 66 65 } 66 67 68 /* 69 create table discussions( 70 discussion_id serial primary key, 71 type char(1) not null, 72 text varchar(1000) not null, 73 title varchar(250) not null, 74 date date not null, 75 user_id integer not null, 76 movie_id integer, 77 person_id integer, 78 constraint fk_user_created foreign key (user_id) references users(user_id) 79 on delete cascade on update cascade, 80 constraint ck_type_discussion check( (type = 'M' and movie_id notnull and person_id isnull) 81 or (type='P' and person_id notnull and movie_id isnull)), 82 constraint fk_discussion_movie foreign key (movie_id) references movies(movie_id) 83 on delete cascade on update cascade, 84 constraint fk_discussion_person foreign key (person_id) references persons(person_id) 85 on delete cascade on update cascade 86 ); 87 88 */ -
src/main/java/com/wediscussmovies/project/model/Genre.java
r7fafead r7bc8942 1 1 package com.wediscussmovies.project.model; 2 2 3 import lombok.Data; 3 4 4 5 import javax.persistence.*; 5 import java.util.Collection;6 import lombok.Data;7 6 7 @Data 8 @Entity 9 @Table(name="genres") 10 public class Genre { 11 @Id 12 @GeneratedValue 13 @Column(name="genre_id", nullable = false, unique = true) 14 private int genre_id; 8 15 9 @Entity 10 @Table(name = "genres", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies") 11 @Data 12 public class Genre { 16 @Column(name="genre_type", length = 100, nullable = false, unique = true) 17 private String genre_type; 13 18 14 @GeneratedValue(strategy = GenerationType.IDENTITY) 15 @Id 16 @Column(name = "genre_id") 17 private Long id; 18 19 @Column(name = "genre_type") 20 private String genre; 21 22 public Genre(String genre) { 23 this.genre = genre; 19 public Genre(String genreName) { 20 this.genre_type = genreName; 24 21 } 25 22 26 23 public Genre() { 27 24 } 25 } 28 26 29 } 27 /* 28 29 create table genres( 30 genre_id serial primary key, 31 genre_type varchar(100) not null unique 32 ); 33 34 */ -
src/main/java/com/wediscussmovies/project/model/Movie.java
r7fafead r7bc8942 5 5 import javax.persistence.*; 6 6 import java.sql.Date; 7 import java.util.Collection;8 7 import java.util.Comparator; 9 8 import java.util.List; 10 import java.util.Objects; 9 @Data 10 @Entity 11 @Table (name="movies") 12 public class Movie { 13 @Id 14 @GeneratedValue 15 @Column(name="movie_id", nullable = false) 16 private int movie_id; 11 17 18 @Column(name="title", length = 150, unique = true, nullable = false) 19 private String Title; 12 20 13 @Entity 14 @Table(name = "movies", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies") 15 @Data 16 public class Movie { 17 18 @GeneratedValue(strategy = GenerationType.IDENTITY) 19 @Id 20 @Column(name = "movie_id") 21 private Long id; 22 23 private String title; 24 21 @Column(name="description", nullable = false, length = 1000) 25 22 private String description; 26 23 27 @Column(name = "image_url")28 private String image Url;24 @Column(name="image_url", length = 300, nullable = false) 25 private String image_url; 29 26 27 @Column(name="airing_date") 28 private Date airing_date; 30 29 31 @Column(name = "airing_date")32 private Date aringDate;30 @Column(name="imdb_rating") 31 private float imdb_rating; 33 32 34 @Column(name = "imdb_rating") 35 private Double imbdRating; 33 @Column(name="director_id") 34 @ManyToOne 35 private Person director; 36 36 37 @ManyToMany 37 @ManyToMany(mappedBy = "movie_actors") 38 private List<Person> actors; 39 40 @ManyToMany(mappedBy = "movie_genres") 38 41 private List<Genre> genres; 39 42 40 @ManyToMany41 private List<Person> likes;42 43 @ManyToMany44 private List<Person> actors;45 46 47 48 49 @ManyToOne50 @JoinColumn(name = "director_id")51 private Person director;52 53 54 55 56 57 58 43 public boolean isFromGenre(Genre genre){ 59 60 return genres61 .stream()62 .anyMatch(g -> Objects.equals(g.getId(), genre.getId()));63 44 for(Genre g: genres){ 45 if(g.getGenre_id() == genre.getGenre_id()) 46 return true; 47 } 48 return false; 64 49 } 65 50 public boolean hasActor(Person p){ 66 return 67 actors 68 .stream() 69 .anyMatch(a -> Objects.equals(a.getPersonId(), p.getPersonId())); 70 71 51 for(Person person: actors){ 52 if(person.getPerson_id() == p.getPerson_id()) 53 return true; 54 } 55 return false; 72 56 } 73 57 74 58 public boolean isDirectedBy(Person p){ 75 return Objects.equals(director.getPersonId(), p.getPersonId());59 return director.getPerson_id() == p.getPerson_id(); 76 60 } 77 61 78 62 public static Comparator<Movie> comparatorTitle = Comparator.comparing(Movie::getTitle); 79 63 80 81 public Movie( String title, String description, String imageUrl, Date aringDate, Double imbdRating,Person director, List<Person> actors, List<Genre> genres) {82 83 this.title = title;84 this.description = description;85 this.imageUrl = imageUrl;86 this.aringDate = aringDate;87 this.imbdRating = imbdRating;88 this.genres = genres;89 this.likes = likes;90 this.actors = actors;91 this.director = director;92 }93 94 64 public Movie() { 95 65 } 96 66 67 public Movie(String title, String description, String image_url, Date airing_date, float imdb_rating, Person director, List<Person> actors, List<Genre> genres) { 68 Title = title; 69 this.description = description; 70 this.image_url = image_url; 71 this.airing_date = airing_date; 72 this.imdb_rating = imdb_rating; 73 this.director = director; 74 this.actors = actors; 75 this.genres = genres; 76 } 77 } 97 78 98 } 79 80 /* 81 82 create table movies( 83 movie_id serial primary key, 84 title varchar(150) not null unique, 85 description varchar(1000) not null, 86 image_url varchar(300) not null, 87 airing_date date not null, 88 imdb_rating float, 89 director_id integer, 90 constraint fk_movie_director foreign key (director_id) references persons(person_id) 91 on delete cascade on update cascade, 92 constraint ck_person_is_director check( check_constraint_person(director_id) = 'D') 93 ); 94 */ -
src/main/java/com/wediscussmovies/project/model/Person.java
r7fafead r7bc8942 1 1 package com.wediscussmovies.project.model; 2 2 3 import com.wediscussmovies.project.model.enumerations.PersonType;4 3 import lombok.Data; 5 4 6 5 import javax.persistence.*; 7 6 import java.sql.Date; 8 import java.util.Co llection;7 import java.util.Comparator; 9 8 import java.util.List; 10 9 10 @Data 11 11 @Entity 12 @Table(name = "persons", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies") 13 @Data 12 @Table(name="persons") 14 13 public class Person { 15 @GeneratedValue(strategy = GenerationType.IDENTITY)16 14 @Id 17 @ Column(name = "person_id")18 private Long personId;15 @GeneratedValue 16 private int person_id; 19 17 18 @Column(name="name", length=100, nullable=false, unique=false) 20 19 private String name; 21 20 21 @Column(name="surname", length=100, nullable=false, unique=false) 22 22 private String surname; 23 23 24 @ Enumerated25 private PersonType type;24 @Column(name="type", nullable = false) 25 private PersonType personType; 26 26 27 @Column(name = "date_of_birth")28 private Date birthDate;27 @Column(name="date_of_birth", nullable=false) 28 private Date date_of_birth; 29 29 30 @Column(name = "image_url")31 private String image Url;30 @Column(name="image_url", length=300, nullable=false, unique=false) 31 private String image_url; 32 32 33 @Column(name="description", length=300, nullable=false, unique=false) 33 34 private String description; 34 35 36 @ManyToMany 37 private List<Movie> acts_in; 35 38 39 public Person(String name, String surname, PersonType personType, Date date_of_birth, String image_url, String description) { 40 this.name = name; 41 this.surname = surname; 42 this.personType = personType; 43 this.date_of_birth = date_of_birth; 44 this.image_url = image_url; 45 this.description = description; 46 } 36 47 37 48 public Person() { 38 49 } 39 50 40 public Person(String name, String surname, PersonType type, Date date_of_birth, String image_url, String description) { 41 this.name = name; 42 this.surname = surname; 43 this.type = type; 44 this.birthDate = date_of_birth; 45 this.imageUrl = image_url; 46 this.description = description; 47 } 51 public static Comparator<Person> personComparatorByNameSurname = Comparator.comparing(Person::getName).thenComparing(Person::getSurname); 48 52 } 53 54 55 /* 56 create table persons( 57 person_id serial primary key, 58 name varchar(100) not null, 59 surname varchar(100) not null, 60 type char(1) not null, 61 date_of_birth date not null, 62 image_url varchar(300) not null, 63 description varchar(300) not null, 64 constraint ck_type check (type ='A' or type='D') 65 ); 66 */ -
src/main/java/com/wediscussmovies/project/model/Reply.java
r7fafead r7bc8942 7 7 import java.util.Optional; 8 8 9 @Data 9 10 @Entity 10 @Table(name = "replies", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies") 11 @IdClass(RepliesEntityPK.class) 12 @Data 11 @Table(name="replies") 13 12 public class Reply { 14 13 @Id 15 @Column(name = "discussion_id") 16 private Long discussionId; 17 18 @GeneratedValue(strategy = GenerationType.IDENTITY) 19 @Id 14 @GeneratedValue 20 15 @Column(name = "reply_id") 21 private Long replyId; 22 23 private String text; 24 25 private Date date; 16 private int reply_id; 26 17 27 18 @ManyToOne 28 @ JoinColumn(name = "discussion_id", referencedColumnName = "discussion_id", nullable = false,insertable = false, updatable = false)19 @Column(name = "discussion_id") 29 20 private Discussion discussion; 30 21 31 22 @ManyToOne 32 @ JoinColumn(name = "user_id")23 @Column(name = "user_id") 33 24 private User user; 34 25 26 @Column(name = "date", nullable = false) 27 private Date date; 35 28 36 29 @Column(name= "text", length = 1000, nullable = false) 30 private String text; 37 31 38 32 public Reply(Discussion discussion, User user, Date date, String text) { … … 41 35 this.date = date; 42 36 this.text = text; 43 44 37 } 45 46 public Reply() { 47 48 } 38 } 49 39 50 40 51 } 41 /* 42 43 create table replies( 44 discussion_id integer, 45 reply_id serial, 46 text varchar(1000) not null, 47 date date not null, 48 user_id integer not null, 49 constraint pk_replies primary key(discussion_id,reply_id), 50 constraint fk_user_create_reply foreign key (user_id) references users(user_id) 51 on delete cascade on update cascade, 52 constraint fk_reply_discussion foreign key (discussion_id) references discussions(discussion_id) 53 on delete cascade on update cascade 54 55 56 ); 57 */ -
src/main/java/com/wediscussmovies/project/model/User.java
r7fafead r7bc8942 1 1 package com.wediscussmovies.project.model; 2 2 3 import lombok.Data; 4 3 5 import javax.persistence.*; 4 import java.util.Collection;5 6 import java.util.List; 6 7 8 @Data 7 9 @Entity 8 @Table(name = "users", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies")10 @Table(name="users") 9 11 public class User { 10 @GeneratedValue(strategy = GenerationType.IDENTITY)11 12 @Id 12 @Column(name = "user_id") 13 private Long userId; 13 @GeneratedValue 14 @Column(name="user_id", nullable = false) 15 private int user_id; 14 16 17 @Column(name="username", length=50, nullable=false, unique=false) 15 18 private String username; 16 19 20 @Column(name="name", length=50, nullable=false, unique=false) 17 21 private String name; 18 22 23 @Column(name="surname", length=50, nullable=false, unique=false) 19 24 private String surname; 20 25 26 @Column(name="email", length=50, nullable=false, unique=false) 21 27 private String email; 22 28 29 @Column(name="password", length=100, nullable=false, unique=true) 23 30 private String password; 24 31 25 @ManyToMany 26 private List<Movie> movies; 32 //TODO("RATES_MOVIE") 33 @ManyToMany(mappedBy = "movie_likes") 34 private List<Movie> likes_movie; 27 35 28 29 36 @ManyToMany(mappedBy = "user_genres") 37 private List<Genre> likes_genres; 30 38 31 39 public User(String username, String name, String surname, String email, String password) { … … 40 48 } 41 49 } 50 51 52 /* 53 create table users( 54 user_id serial primary key, 55 username varchar(50) not null unique, 56 name varchar(50) not null, 57 surname varchar(50) not null, 58 email varchar(100) not null unique, 59 password varchar(30) not null, 60 constraint ck_password check(length(password) >= 9) 61 ); 62 */ -
src/main/java/com/wediscussmovies/project/repository/GenreRepository.java
r7fafead r7bc8942 9 9 @Repository 10 10 public interface GenreRepository extends JpaRepository<Genre, Integer> { 11 public List<Genre> findAllByGenre (String genre_type);11 public List<Genre> findAllByGenre_typeLike(String genre_type); 12 12 } -
src/main/java/com/wediscussmovies/project/repository/PersonRepository.java
r7fafead r7bc8942 2 2 3 3 import com.wediscussmovies.project.model.Person; 4 import com.wediscussmovies.project.model. enumerations.PersonType;4 import com.wediscussmovies.project.model.PersonType; 5 5 import org.springframework.data.jpa.repository.JpaRepository; 6 6 import org.springframework.data.jpa.repository.Query; -
src/main/java/com/wediscussmovies/project/service/GenreService.java
r7fafead r7bc8942 2 2 3 3 import com.wediscussmovies.project.model.Genre; 4 import org.springframework.stereotype.Service;5 4 6 5 import java.util.List; 7 6 import java.util.Optional; 8 7 9 @Service10 8 public interface GenreService { 11 9 public List<Genre> findAll(); -
src/main/java/com/wediscussmovies/project/service/MovieService.java
r7fafead r7bc8942 9 9 public List<Movie> listAll(); 10 10 public List<Movie> searchByTitle(String title); 11 public Optional<Movie> findById( Longid);11 public Optional<Movie> findById(Integer id); 12 12 public Movie save(Movie movie); 13 public void deleteById( Longid);13 public void deleteById(int id); 14 14 } -
src/main/java/com/wediscussmovies/project/service/PersonService.java
r7fafead r7bc8942 7 7 8 8 public interface PersonService { 9 List<Person> findAllDirectors();10 List<Person> findAllActors();9 public List<Person> findAllDirectors(); 10 public List<Person> findAllActors(); 11 11 Optional<Person> findById(Integer person_id); 12 12 Optional<Person> findActorById(Integer id); -
src/main/java/com/wediscussmovies/project/service/ReplyService.java
r7fafead r7bc8942 8 8 public Reply save(Reply r); 9 9 public void delete(Reply r); 10 Optional<Reply> findById(Long id); 11 10 Optional<Reply> findById(Integer id); 12 11 } -
src/main/java/com/wediscussmovies/project/service/impl/GenreServiceImpl.java
r7fafead r7bc8942 24 24 @Override 25 25 public List<Genre> findAllByType(String genre) { 26 return genreRepository.findAllByGenre (genre);26 return genreRepository.findAllByGenre_typeLike(genre); 27 27 } 28 28 -
src/main/java/com/wediscussmovies/project/service/impl/MovieServiceImpl.java
r7fafead r7bc8942 23 23 24 24 @Override 25 public Optional<Movie> findById( Longid) {26 return movieRepository.findById( 1);25 public Optional<Movie> findById(Integer id) { 26 return movieRepository.findById(id); 27 27 } 28 28 … … 33 33 34 34 @Override 35 public void deleteById( Longid) {36 movieRepository.deleteById( 0);35 public void deleteById(int id) { 36 movieRepository.deleteById(id); 37 37 } 38 38 -
src/main/java/com/wediscussmovies/project/service/impl/PersonServiceImpl.java
r7fafead r7bc8942 2 2 3 3 import com.wediscussmovies.project.model.Person; 4 import com.wediscussmovies.project.model. enumerations.PersonType;4 import com.wediscussmovies.project.model.PersonType; 5 5 import com.wediscussmovies.project.repository.PersonRepository; 6 6 import com.wediscussmovies.project.service.PersonService; … … 13 13 public class PersonServiceImpl implements PersonService { 14 14 private final PersonRepository personRepository; 15 16 15 17 16 public PersonServiceImpl(PersonRepository personRepository) { -
src/main/java/com/wediscussmovies/project/service/impl/ReplyServiceImpl.java
r7fafead r7bc8942 17 17 18 18 @Override 19 public Optional<Reply> findById( Longid) {20 return replyRepository.findById( 1);19 public Optional<Reply> findById(Integer id) { 20 return replyRepository.findById(id); 21 21 } 22 22 -
src/main/java/com/wediscussmovies/project/web/controller/DiscussionsController.java
r7fafead r7bc8942 2 2 3 3 import com.wediscussmovies.project.model.*; 4 import com.wediscussmovies.project.model.enumerations.DiscussionType;5 4 import com.wediscussmovies.project.service.DiscussionService; 6 5 import com.wediscussmovies.project.service.MovieService; … … 14 13 import java.sql.Date; 15 14 import java.time.LocalDate; 16 import java.util.ArrayList;17 15 import java.util.List; 18 16 import java.util.Optional; … … 103 101 return "redirect:/login"; 104 102 } 105 Long movie_id = (Long) request.getSession().getAttribute("movieId");103 Integer movie_id = (Integer) request.getSession().getAttribute("movieId"); 106 104 request.getSession().setAttribute("movieId", null); 107 105 Optional<Movie> movieOp = movieService.findById(movie_id); 108 106 if(movieOp.isEmpty()) 109 107 return "redirect:/movies"; 110 Discussion discussion = new Discussion( DiscussionType.M,text, title, Date.valueOf(LocalDate.now()),user,movieOp.get(),null,new ArrayList<>());108 Discussion discussion = new Discussion(title, text, user, movieOp.get(), Date.valueOf(LocalDate.now())); 111 109 discussionService.save(discussion); 112 110 return "redirect:/discussions"; … … 137 135 if(personOp.isEmpty()) 138 136 return "redirect:/discussions"; 139 Discussion discussion = new Discussion( DiscussionType.P,title, text,Date.valueOf(LocalDate.now()),user,null,personOp.get(),new ArrayList<>());137 Discussion discussion = new Discussion(title, text, user, personOp.get(), Date.valueOf(LocalDate.now())); 140 138 discussionService.save(discussion); 141 139 return "redirect:/discussions"; -
src/main/java/com/wediscussmovies/project/web/controller/MovieController.java
r7fafead r7bc8942 1 1 package com.wediscussmovies.project.web.controller; 2 2 3 import com.wediscussmovies.project.exception.MovieIdNotFoundException;4 3 import com.wediscussmovies.project.model.Genre; 5 4 import com.wediscussmovies.project.model.Movie; 6 5 import com.wediscussmovies.project.model.Person; 6 import com.wediscussmovies.project.model.exception.MovieIdNotFoundException; 7 7 import com.wediscussmovies.project.service.GenreService; 8 8 import com.wediscussmovies.project.service.MovieService; … … 59 59 60 60 @PostMapping("/{id}/delete") 61 public String addMovie(@PathVariable Longid){61 public String addMovie(@PathVariable int id){ 62 62 Optional<Movie> movie = movieService.findById(id); 63 63 if(movie.isPresent()){ 64 movieService.deleteById(movie.get().get Id());64 movieService.deleteById(movie.get().getMovie_id()); 65 65 } 66 66 return "redirect:/movies"; … … 72 72 @RequestParam String image_url, 73 73 @RequestParam Date airing_date, 74 @RequestParam Doublerating,74 @RequestParam Float rating, 75 75 @RequestParam Integer director_id, 76 76 @RequestParam List<Integer> actors, … … 131 131 @PostMapping("/edit/confirm") 132 132 public String editMoviePost( 133 @RequestParam Longmovie_id,133 @RequestParam Integer movie_id, 134 134 @RequestParam String title, 135 135 @RequestParam String description, 136 136 @RequestParam String image_url, 137 137 @RequestParam Date airing_date, 138 @RequestParam Doublerating,138 @RequestParam Float rating, 139 139 @RequestParam Integer director_id, 140 140 @RequestParam List<Integer> actors, … … 203 203 movie.setTitle(title); 204 204 movie.setDescription(description); 205 movie.setA ringDate(airing_date);206 movie.setImage Url(image_url);207 movie.setIm bdRating(rating);205 movie.setAiring_date(airing_date); 206 movie.setImage_url(image_url); 207 movie.setImdb_rating(rating); 208 208 209 209 movieService.save(movie); … … 213 213 214 214 @GetMapping("/{id}/edit") 215 public String editMovie(@PathVariable Longid, Model model){215 public String editMovie(@PathVariable Integer id, Model model){ 216 216 Movie movie = movieService.findById(id).orElseThrow(() -> new MovieIdNotFoundException(id)); 217 217 model.addAttribute("directors", personService.findAllDirectors()); -
src/main/java/com/wediscussmovies/project/web/controller/PersonsController.java
r7fafead r7bc8942 2 2 3 3 import com.wediscussmovies.project.model.Person; 4 import com.wediscussmovies.project.model. enumerations.PersonType;4 import com.wediscussmovies.project.model.PersonType; 5 5 import com.wediscussmovies.project.service.PersonService; 6 6 import org.springframework.stereotype.Controller; … … 38 38 boolean add = true; 39 39 for(Person a: actorsByName){ 40 if(a.getPerson Id() == p.getPersonId()){40 if(a.getPerson_id() == p.getPerson_id()){ 41 41 add=false; 42 42 break; … … 50 50 actors = actorsByName; 51 51 } 52 //actors.sort(Person.personComparatorByNameSurname);52 actors.sort(Person.personComparatorByNameSurname); 53 53 model.addAttribute("actors", actors); 54 54 model.addAttribute("contentTemplate", "actorsList"); … … 71 71 boolean add = true; 72 72 for(Person a: directorsByName){ 73 if(a.getPerson Id() == p.getPersonId()){73 if(a.getPerson_id() == p.getPerson_id()){ 74 74 add=false; 75 75 break; … … 83 83 directors = directorsByName; 84 84 } 85 //directors.sort(Person.personComparatorByNameSurname);85 directors.sort(Person.personComparatorByNameSurname); 86 86 model.addAttribute("directors", directors); 87 87 model.addAttribute("contentTemplate", "directorsList"); -
src/main/java/com/wediscussmovies/project/web/controller/ReplyController.java
r7fafead r7bc8942 19 19 20 20 @GetMapping("/edit/{id}") 21 public String getReplyEdit(@PathVariable Longid, Model model){21 public String getReplyEdit(@PathVariable Integer id, Model model){ 22 22 Optional<Reply> reply = replyService.findById(id); 23 23 if(reply.isEmpty()) … … 29 29 30 30 @PostMapping("/edit/confirm/{id}") 31 public String getReplyEdit(@PathVariable Longid, @RequestParam String text){31 public String getReplyEdit(@PathVariable Integer id, @RequestParam String text){ 32 32 Optional<Reply> replyOp = replyService.findById(id); 33 33 if(replyOp.isEmpty()) … … 37 37 reply.setText(text); 38 38 replyService.save(reply); 39 return "redirect:/discussions/"+reply.getDiscussion().get Id();39 return "redirect:/discussions/"+reply.getDiscussion().getDiscussion_id(); 40 40 } 41 41 } -
src/main/resources/application.properties
r7fafead r7bc8942 1 spring.profiles.active=prod 1
Note:
See TracChangeset
for help on using the changeset viewer.