Changes in / [7fafead:7bc8942] in Git


Ignore:
Files:
1 added
180 deleted
23 edited

Legend:

Unmodified
Added
Removed
  • README.md

    r7fafead r7bc8942  
    33<div style="float: left; width: 60%;">
    44
    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/Зимски</h4><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>
    77<h4 style="display: block; font-weight: normal; text-align: justify; float: right">Под менторство на вонр. проф. д-р Вангел Ајановски и демонстр. м-р Ненад Анчев</h4><br>
    88<h4 style="display: block; font-weight: normal; text-align: justify; float: right">Започнат: Ноември 2021</h4><br><br>
     
    2323        <li>Мартин Николов (193113)</li>
    2424</ol>
    25 </div>
  • pom.xml

    r7fafead r7bc8942  
    4242            <groupId>org.postgresql</groupId>
    4343            <artifactId>postgresql</artifactId>
     44            <scope>runtime</scope>
    4445        </dependency>
    4546        <dependency>
     
    5859            <scope>test</scope>
    5960        </dependency>
    60 
    6161        <dependency>
    6262            <groupId>org.springframework.boot</groupId>
    6363            <artifactId>spring-boot-starter-data-jpa</artifactId>
     64            <version>RELEASE</version>
     65            <scope>compile</scope>
    6466        </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 
    7667    </dependencies>
    7768
  • src/main/java/com/wediscussmovies/project/model/Discussion.java

    r7fafead r7bc8942  
    11package com.wediscussmovies.project.model;
    22
    3 import com.wediscussmovies.project.model.enumerations.DiscussionType;
    43import lombok.Data;
    54
    65import javax.persistence.*;
    76import java.sql.Date;
    8 import java.util.Collection;
    97import java.util.List;
    10 import java.util.Objects;
    118
    129@Data
    1310@Entity
    14 @Table(name = "discussions", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies")
     11@Table (name="discussions")
    1512public class Discussion {
     13    @Id
     14    @GeneratedValue
     15    private int discussion_id;
    1616
    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;
    2120
    22     @Enumerated
    23     private DiscussionType type;
     21    @ManyToOne()
     22    @Column(name = "person_id")
     23    private Person person;
    2424
     25    @ManyToOne
     26    @Column(name = "user_id")
     27    private User user;
     28
     29    @Column(name = "text", length = 1000, nullable = false)
    2530    private String text;
    2631
     32    @Column(name = "title", length = 1000, nullable = false)
    2733    private String title;
    2834
     35    @Column(name = "date", nullable = false)
    2936    private Date date;
    3037
    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;
    6142
    6243    public Discussion() {
    6344    }
    6445
     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
    6564
    6665}
     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  
    11package com.wediscussmovies.project.model;
    22
     3import lombok.Data;
    34
    45import javax.persistence.*;
    5 import java.util.Collection;
    6 import lombok.Data;
    76
     7@Data
     8@Entity
     9@Table(name="genres")
     10public class Genre {
     11    @Id
     12    @GeneratedValue
     13    @Column(name="genre_id", nullable = false, unique = true)
     14    private int genre_id;
    815
    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;
    1318
    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;
    2421    }
    2522
    2623    public Genre() {
    2724    }
     25}
    2826
    29 }
     27/*
     28
     29create 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  
    55import javax.persistence.*;
    66import java.sql.Date;
    7 import java.util.Collection;
    87import java.util.Comparator;
    98import java.util.List;
    10 import java.util.Objects;
     9@Data
     10@Entity
     11@Table (name="movies")
     12public class Movie {
     13    @Id
     14    @GeneratedValue
     15    @Column(name="movie_id", nullable = false)
     16    private int movie_id;
    1117
     18    @Column(name="title", length = 150, unique = true, nullable = false)
     19    private String Title;
    1220
    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)
    2522    private String description;
    2623
    27     @Column(name = "image_url")
    28     private String imageUrl;
     24    @Column(name="image_url", length = 300, nullable = false)
     25    private String image_url;
    2926
     27    @Column(name="airing_date")
     28    private Date airing_date;
    3029
    31     @Column(name = "airing_date")
    32     private Date aringDate;
     30    @Column(name="imdb_rating")
     31    private float imdb_rating;
    3332
    34     @Column(name = "imdb_rating")
    35     private Double imbdRating;
     33    @Column(name="director_id")
     34    @ManyToOne
     35    private Person director;
    3636
    37     @ManyToMany
     37    @ManyToMany(mappedBy = "movie_actors")
     38    private List<Person> actors;
     39
     40    @ManyToMany(mappedBy = "movie_genres")
    3841    private List<Genre> genres;
    3942
    40     @ManyToMany
    41     private List<Person> likes;
    42 
    43     @ManyToMany
    44     private List<Person> actors;
    45 
    46 
    47 
    48 
    49     @ManyToOne
    50     @JoinColumn(name = "director_id")
    51     private Person director;
    52 
    53 
    54 
    55 
    56 
    57 
    5843    public boolean isFromGenre(Genre genre){
    59 
    60      return    genres
    61                 .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;
    6449    }
    6550    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;
    7256    }
    7357
    7458    public boolean isDirectedBy(Person p){
    75         return Objects.equals(director.getPersonId(), p.getPersonId());
     59        return director.getPerson_id() == p.getPerson_id();
    7660    }
    7761
    7862    public static Comparator<Movie> comparatorTitle = Comparator.comparing(Movie::getTitle);
    7963
    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 
    9464    public Movie() {
    9565    }
    9666
     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}
    9778
    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  
    11package com.wediscussmovies.project.model;
    22
    3 import com.wediscussmovies.project.model.enumerations.PersonType;
    43import lombok.Data;
    54
    65import javax.persistence.*;
    76import java.sql.Date;
    8 import java.util.Collection;
     7import java.util.Comparator;
    98import java.util.List;
    109
     10@Data
    1111@Entity
    12 @Table(name = "persons", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies")
    13 @Data
     12@Table(name="persons")
    1413public class Person {
    15     @GeneratedValue(strategy = GenerationType.IDENTITY)
    1614    @Id
    17     @Column(name = "person_id")
    18     private Long personId;
     15    @GeneratedValue
     16    private int person_id;
    1917
     18    @Column(name="name", length=100, nullable=false, unique=false)
    2019    private String name;
    2120
     21    @Column(name="surname", length=100, nullable=false, unique=false)
    2222    private String surname;
    2323
    24     @Enumerated
    25     private PersonType type;
     24    @Column(name="type", nullable = false)
     25    private PersonType personType;
    2626
    27     @Column(name = "date_of_birth")
    28     private Date birthDate;
     27    @Column(name="date_of_birth", nullable=false)
     28    private Date date_of_birth;
    2929
    30     @Column(name = "image_url")
    31     private String imageUrl;
     30    @Column(name="image_url", length=300, nullable=false, unique=false)
     31    private String image_url;
    3232
     33    @Column(name="description", length=300, nullable=false, unique=false)
    3334    private String description;
    3435
     36    @ManyToMany
     37    private List<Movie> acts_in;
    3538
     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    }
    3647
    3748    public Person() {
    3849    }
    3950
    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);
    4852}
     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  
    77import java.util.Optional;
    88
     9@Data
    910@Entity
    10 @Table(name = "replies", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies")
    11 @IdClass(RepliesEntityPK.class)
    12 @Data
     11@Table(name="replies")
    1312public class Reply {
    1413    @Id
    15     @Column(name = "discussion_id")
    16     private Long discussionId;
    17 
    18     @GeneratedValue(strategy = GenerationType.IDENTITY)
    19     @Id
     14    @GeneratedValue
    2015    @Column(name = "reply_id")
    21     private Long replyId;
    22 
    23     private String text;
    24 
    25     private Date date;
     16    private int reply_id;
    2617
    2718    @ManyToOne
    28     @JoinColumn(name = "discussion_id", referencedColumnName = "discussion_id", nullable = false,insertable = false, updatable = false)
     19    @Column(name = "discussion_id")
    2920    private Discussion discussion;
    3021
    3122    @ManyToOne
    32     @JoinColumn(name = "user_id")
     23    @Column(name = "user_id")
    3324    private User user;
    3425
     26    @Column(name = "date", nullable = false)
     27    private Date date;
    3528
    36 
     29    @Column(name= "text", length = 1000, nullable = false)
     30    private String text;
    3731
    3832    public Reply(Discussion discussion, User user, Date date, String text) {
     
    4135        this.date = date;
    4236        this.text = text;
    43 
    4437    }
    45 
    46     public Reply() {
    47 
    48     }
     38}
    4939
    5040
    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  
    11package com.wediscussmovies.project.model;
    22
     3import lombok.Data;
     4
    35import javax.persistence.*;
    4 import java.util.Collection;
    56import java.util.List;
    67
     8@Data
    79@Entity
    8 @Table(name = "users", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies")
     10@Table(name="users")
    911public class User {
    10     @GeneratedValue(strategy = GenerationType.IDENTITY)
    1112    @Id
    12     @Column(name = "user_id")
    13     private Long userId;
     13    @GeneratedValue
     14    @Column(name="user_id", nullable = false)
     15    private int user_id;
    1416
     17    @Column(name="username", length=50, nullable=false, unique=false)
    1518    private String username;
    1619
     20    @Column(name="name", length=50, nullable=false, unique=false)
    1721    private String name;
    1822
     23    @Column(name="surname", length=50, nullable=false, unique=false)
    1924    private String surname;
    2025
     26    @Column(name="email", length=50, nullable=false, unique=false)
    2127    private String email;
    2228
     29    @Column(name="password", length=100, nullable=false, unique=true)
    2330    private String password;
    2431
    25     @ManyToMany
    26     private List<Movie> movies;
     32    //TODO("RATES_MOVIE")
     33    @ManyToMany(mappedBy = "movie_likes")
     34    private List<Movie> likes_movie;
    2735
    28 
    29 
     36    @ManyToMany(mappedBy = "user_genres")
     37    private List<Genre> likes_genres;
    3038
    3139    public User(String username, String name, String surname, String email, String password) {
     
    4048    }
    4149}
     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  
    99@Repository
    1010public interface GenreRepository extends JpaRepository<Genre, Integer> {
    11     public List<Genre> findAllByGenre(String genre_type);
     11    public List<Genre> findAllByGenre_typeLike(String genre_type);
    1212}
  • src/main/java/com/wediscussmovies/project/repository/PersonRepository.java

    r7fafead r7bc8942  
    22
    33import com.wediscussmovies.project.model.Person;
    4 import com.wediscussmovies.project.model.enumerations.PersonType;
     4import com.wediscussmovies.project.model.PersonType;
    55import org.springframework.data.jpa.repository.JpaRepository;
    66import org.springframework.data.jpa.repository.Query;
  • src/main/java/com/wediscussmovies/project/service/GenreService.java

    r7fafead r7bc8942  
    22
    33import com.wediscussmovies.project.model.Genre;
    4 import org.springframework.stereotype.Service;
    54
    65import java.util.List;
    76import java.util.Optional;
    87
    9 @Service
    108public interface GenreService {
    119    public List<Genre> findAll();
  • src/main/java/com/wediscussmovies/project/service/MovieService.java

    r7fafead r7bc8942  
    99    public List<Movie> listAll();
    1010    public List<Movie> searchByTitle(String title);
    11     public Optional<Movie> findById(Long id);
     11    public Optional<Movie> findById(Integer id);
    1212    public Movie save(Movie movie);
    13     public void deleteById(Long id);
     13    public void deleteById(int id);
    1414}
  • src/main/java/com/wediscussmovies/project/service/PersonService.java

    r7fafead r7bc8942  
    77
    88public interface PersonService {
    9     List<Person> findAllDirectors();
    10     List<Person> findAllActors();
     9    public List<Person> findAllDirectors();
     10    public List<Person> findAllActors();
    1111    Optional<Person> findById(Integer person_id);
    1212    Optional<Person> findActorById(Integer id);
  • src/main/java/com/wediscussmovies/project/service/ReplyService.java

    r7fafead r7bc8942  
    88    public Reply save(Reply r);
    99    public void delete(Reply r);
    10     Optional<Reply> findById(Long id);
    11 
     10    Optional<Reply> findById(Integer id);
    1211}
  • src/main/java/com/wediscussmovies/project/service/impl/GenreServiceImpl.java

    r7fafead r7bc8942  
    2424    @Override
    2525    public List<Genre> findAllByType(String genre) {
    26         return genreRepository.findAllByGenre(genre);
     26        return genreRepository.findAllByGenre_typeLike(genre);
    2727    }
    2828
  • src/main/java/com/wediscussmovies/project/service/impl/MovieServiceImpl.java

    r7fafead r7bc8942  
    2323
    2424    @Override
    25     public Optional<Movie> findById(Long id) {
    26         return movieRepository.findById(1);
     25    public Optional<Movie> findById(Integer id) {
     26        return movieRepository.findById(id);
    2727    }
    2828
     
    3333
    3434    @Override
    35     public void deleteById(Long id) {
    36         movieRepository.deleteById(0);
     35    public void deleteById(int id) {
     36        movieRepository.deleteById(id);
    3737    }
    3838
  • src/main/java/com/wediscussmovies/project/service/impl/PersonServiceImpl.java

    r7fafead r7bc8942  
    22
    33import com.wediscussmovies.project.model.Person;
    4 import com.wediscussmovies.project.model.enumerations.PersonType;
     4import com.wediscussmovies.project.model.PersonType;
    55import com.wediscussmovies.project.repository.PersonRepository;
    66import com.wediscussmovies.project.service.PersonService;
     
    1313public class PersonServiceImpl implements PersonService {
    1414    private final PersonRepository personRepository;
    15 
    1615
    1716    public PersonServiceImpl(PersonRepository personRepository) {
  • src/main/java/com/wediscussmovies/project/service/impl/ReplyServiceImpl.java

    r7fafead r7bc8942  
    1717
    1818    @Override
    19     public Optional<Reply> findById(Long id) {
    20         return replyRepository.findById(1);
     19    public Optional<Reply> findById(Integer id) {
     20        return replyRepository.findById(id);
    2121    }
    2222
  • src/main/java/com/wediscussmovies/project/web/controller/DiscussionsController.java

    r7fafead r7bc8942  
    22
    33import com.wediscussmovies.project.model.*;
    4 import com.wediscussmovies.project.model.enumerations.DiscussionType;
    54import com.wediscussmovies.project.service.DiscussionService;
    65import com.wediscussmovies.project.service.MovieService;
     
    1413import java.sql.Date;
    1514import java.time.LocalDate;
    16 import java.util.ArrayList;
    1715import java.util.List;
    1816import java.util.Optional;
     
    103101            return "redirect:/login";
    104102        }
    105         Long movie_id = (Long) request.getSession().getAttribute("movieId");
     103        Integer movie_id = (Integer) request.getSession().getAttribute("movieId");
    106104        request.getSession().setAttribute("movieId", null);
    107105        Optional<Movie> movieOp = movieService.findById(movie_id);
    108106        if(movieOp.isEmpty())
    109107            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()));
    111109        discussionService.save(discussion);
    112110        return "redirect:/discussions";
     
    137135        if(personOp.isEmpty())
    138136            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()));
    140138        discussionService.save(discussion);
    141139        return "redirect:/discussions";
  • src/main/java/com/wediscussmovies/project/web/controller/MovieController.java

    r7fafead r7bc8942  
    11package com.wediscussmovies.project.web.controller;
    22
    3 import com.wediscussmovies.project.exception.MovieIdNotFoundException;
    43import com.wediscussmovies.project.model.Genre;
    54import com.wediscussmovies.project.model.Movie;
    65import com.wediscussmovies.project.model.Person;
     6import com.wediscussmovies.project.model.exception.MovieIdNotFoundException;
    77import com.wediscussmovies.project.service.GenreService;
    88import com.wediscussmovies.project.service.MovieService;
     
    5959
    6060    @PostMapping("/{id}/delete")
    61     public String addMovie(@PathVariable Long id){
     61    public String addMovie(@PathVariable int id){
    6262        Optional<Movie> movie = movieService.findById(id);
    6363        if(movie.isPresent()){
    64             movieService.deleteById(movie.get().getId());
     64            movieService.deleteById(movie.get().getMovie_id());
    6565        }
    6666        return "redirect:/movies";
     
    7272                               @RequestParam String image_url,
    7373                               @RequestParam Date airing_date,
    74                                @RequestParam Double rating,
     74                               @RequestParam Float rating,
    7575                               @RequestParam Integer director_id,
    7676                               @RequestParam List<Integer> actors,
     
    131131    @PostMapping("/edit/confirm")
    132132    public String editMoviePost(
    133                                 @RequestParam Long movie_id,
     133                                @RequestParam Integer movie_id,
    134134                                @RequestParam String title,
    135135                               @RequestParam String description,
    136136                               @RequestParam String image_url,
    137137                               @RequestParam Date airing_date,
    138                                @RequestParam Double rating,
     138                               @RequestParam Float rating,
    139139                               @RequestParam Integer director_id,
    140140                               @RequestParam List<Integer> actors,
     
    203203        movie.setTitle(title);
    204204        movie.setDescription(description);
    205         movie.setAringDate(airing_date);
    206         movie.setImageUrl(image_url);
    207         movie.setImbdRating(rating);
     205        movie.setAiring_date(airing_date);
     206        movie.setImage_url(image_url);
     207        movie.setImdb_rating(rating);
    208208
    209209        movieService.save(movie);
     
    213213
    214214    @GetMapping("/{id}/edit")
    215     public String editMovie(@PathVariable Long id, Model model){
     215    public String editMovie(@PathVariable Integer id, Model model){
    216216        Movie movie = movieService.findById(id).orElseThrow(() -> new MovieIdNotFoundException(id));
    217217        model.addAttribute("directors", personService.findAllDirectors());
  • src/main/java/com/wediscussmovies/project/web/controller/PersonsController.java

    r7fafead r7bc8942  
    22
    33import com.wediscussmovies.project.model.Person;
    4 import com.wediscussmovies.project.model.enumerations.PersonType;
     4import com.wediscussmovies.project.model.PersonType;
    55import com.wediscussmovies.project.service.PersonService;
    66import org.springframework.stereotype.Controller;
     
    3838                    boolean add = true;
    3939                    for(Person a: actorsByName){
    40                         if(a.getPersonId() == p.getPersonId()){
     40                        if(a.getPerson_id() == p.getPerson_id()){
    4141                            add=false;
    4242                            break;
     
    5050            actors = actorsByName;
    5151        }
    52        // actors.sort(Person.personComparatorByNameSurname);
     52        actors.sort(Person.personComparatorByNameSurname);
    5353        model.addAttribute("actors", actors);
    5454        model.addAttribute("contentTemplate", "actorsList");
     
    7171                    boolean add = true;
    7272                    for(Person a: directorsByName){
    73                         if(a.getPersonId() == p.getPersonId()){
     73                        if(a.getPerson_id() == p.getPerson_id()){
    7474                            add=false;
    7575                            break;
     
    8383            directors = directorsByName;
    8484        }
    85      //   directors.sort(Person.personComparatorByNameSurname);
     85        directors.sort(Person.personComparatorByNameSurname);
    8686        model.addAttribute("directors", directors);
    8787        model.addAttribute("contentTemplate", "directorsList");
  • src/main/java/com/wediscussmovies/project/web/controller/ReplyController.java

    r7fafead r7bc8942  
    1919
    2020    @GetMapping("/edit/{id}")
    21     public String getReplyEdit(@PathVariable Long id, Model model){
     21    public String getReplyEdit(@PathVariable Integer id, Model model){
    2222        Optional<Reply> reply = replyService.findById(id);
    2323        if(reply.isEmpty())
     
    2929
    3030    @PostMapping("/edit/confirm/{id}")
    31     public String getReplyEdit(@PathVariable Long id, @RequestParam String text){
     31    public String getReplyEdit(@PathVariable Integer id, @RequestParam String text){
    3232        Optional<Reply> replyOp = replyService.findById(id);
    3333        if(replyOp.isEmpty())
     
    3737        reply.setText(text);
    3838        replyService.save(reply);
    39         return "redirect:/discussions/"+reply.getDiscussion().getId();
     39        return "redirect:/discussions/"+reply.getDiscussion().getDiscussion_id();
    4040    }
    4141}
  • src/main/resources/application.properties

    r7fafead r7bc8942  
    1 spring.profiles.active=prod
     1
Note: See TracChangeset for help on using the changeset viewer.