Ignore:
Timestamp:
01/16/22 15:29:49 (3 years ago)
Author:
Petar Partaloski <ppartaloski@…>
Branches:
main
Children:
7bc8942
Parents:
7a0bf79
Message:

Controller, Repository and Service layer improvements, Entity updating

Location:
src/main/java/com/wediscussmovies/project/model
Files:
6 added
6 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/wediscussmovies/project/model/Discussion.java

    r7a0bf79 r2a5d6a3  
    99@Data
    1010@Entity
     11@Table (name="discussions")
    1112public class Discussion {
    1213    @Id
     
    3536    private Date date;
    3637
     38    @Column(name = "type", nullable = false)
     39    private DiscussionType type;
    3740    @OneToMany
    3841    private List<Reply> replies;
     42
     43    public Discussion() {
     44    }
     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
     64
    3965}
    4066
  • src/main/java/com/wediscussmovies/project/model/Genre.java

    r7a0bf79 r2a5d6a3  
    33import lombok.Data;
    44
    5 import javax.persistence.Column;
    6 import javax.persistence.Entity;
    7 import javax.persistence.GeneratedValue;
    8 import javax.persistence.Id;
     5import javax.persistence.*;
    96
    107@Data
    11 @Entity(name="genres")
     8@Entity
     9@Table(name="genres")
    1210public class Genre {
    1311    @Id
  • src/main/java/com/wediscussmovies/project/model/Movie.java

    r7a0bf79 r2a5d6a3  
    88import java.util.List;
    99@Data
    10 @Entity(name="movies")
     10@Entity
     11@Table (name="movies")
    1112public class Movie {
    1213    @Id
     
    6162    public static Comparator<Movie> comparatorTitle = Comparator.comparing(Movie::getTitle);
    6263
     64    public Movie() {
     65    }
     66
    6367    public Movie(String title, String description, String image_url, Date airing_date, float imdb_rating, Person director, List<Person> actors, List<Genre> genres) {
    6468        Title = title;
  • src/main/java/com/wediscussmovies/project/model/Person.java

    r7a0bf79 r2a5d6a3  
    55import javax.persistence.*;
    66import java.sql.Date;
     7import java.util.Comparator;
    78import java.util.List;
    89
    910@Data
    10 @Entity(name="persons")
     11@Entity
     12@Table(name="persons")
    1113public class Person {
    1214    @Id
     
    3436    @ManyToMany
    3537    private List<Movie> acts_in;
     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    }
     47
     48    public Person() {
     49    }
     50
     51    public static Comparator<Person> personComparatorByNameSurname = Comparator.comparing(Person::getName).thenComparing(Person::getSurname);
    3652}
    3753
  • src/main/java/com/wediscussmovies/project/model/Reply.java

    r7a0bf79 r2a5d6a3  
    55import javax.persistence.*;
    66import java.sql.Date;
     7import java.util.Optional;
    78
    89@Data
    9 @Entity(name="replies")
     10@Entity
     11@Table(name="replies")
    1012public class Reply {
    1113    @Id
     
    2729    @Column(name= "text", length = 1000, nullable = false)
    2830    private String text;
     31
     32    public Reply(Discussion discussion, User user, Date date, String text) {
     33        this.discussion = discussion;
     34        this.user = user;
     35        this.date = date;
     36        this.text = text;
     37    }
    2938}
    3039
  • src/main/java/com/wediscussmovies/project/model/User.java

    r7a0bf79 r2a5d6a3  
    77
    88@Data
    9 @Entity(name="users")
     9@Entity
     10@Table(name="users")
    1011public class User {
    1112    @Id
     
    3637    private List<Genre> likes_genres;
    3738
     39    public User(String username, String name, String surname, String email, String password) {
     40        this.username = username;
     41        this.name = name;
     42        this.surname = surname;
     43        this.email = email;
     44        this.password = password;
     45    }
     46
     47    public User() {
     48    }
    3849}
    3950
Note: See TracChangeset for help on using the changeset viewer.