Changeset 0e62f4d


Ignore:
Timestamp:
07/27/22 22:28:59 (2 years ago)
Author:
unknown <mlviktor23@…>
Branches:
main
Children:
7cb8c3c
Parents:
b7ec74e
Message:

updated model (added Post, Opinion, Thread and Section entities)

Location:
springapp/src/main/java/mk/profesori/springapp/Model
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • springapp/src/main/java/mk/profesori/springapp/Model/CustomUserDetails.java

    rb7ec74e r0e62f4d  
    11package mk.profesori.springapp.Model;
    22
     3import java.util.ArrayList;
    34import java.util.Collection;
    45import java.util.Collections;
    56import java.util.HashSet;
     7import java.util.List;
    68import java.util.Set;
    79
     
    1921import org.springframework.security.core.authority.SimpleGrantedAuthority;
    2022import org.springframework.security.core.userdetails.UserDetails;
     23
     24import com.fasterxml.jackson.annotation.JsonManagedReference;
    2125
    2226import lombok.EqualsAndHashCode;
     
    4650    @OneToMany(mappedBy = "customUserDetails", cascade = CascadeType.ALL)
    4751    private Set<ConfirmationToken> confirmationTokens = new HashSet<>();
     52    @OneToMany(mappedBy = "author", cascade = CascadeType.ALL)
     53    private List<Post> authoredPosts = new ArrayList<>();
    4854
    4955    public CustomUserDetails(String fullName, String username, String email, String password, UserRole userRole) {
     
    9096        return enabled;
    9197    }
     98
     99    @JsonManagedReference
     100    List<Post> getAuthoredPosts() {
     101        return this.authoredPosts;
     102    }
    92103   
    93104}
  • springapp/src/main/java/mk/profesori/springapp/Model/Professor.java

    rb7ec74e r0e62f4d  
    11package mk.profesori.springapp.Model;
    22
     3import java.util.ArrayList;
    34import java.util.HashSet;
     5import java.util.List;
    46import java.util.Set;
    57
     8import javax.persistence.CascadeType;
    69import javax.persistence.Column;
    710import javax.persistence.Entity;
     
    1518
    1619import com.fasterxml.jackson.annotation.JsonBackReference;
     20import com.fasterxml.jackson.annotation.JsonManagedReference;
    1721
    1822@Entity
     
    3236    private Faculty faculty;
    3337
     38    @OneToMany(mappedBy = "targetProfessor", cascade = CascadeType.ALL)
     39    private List<Opinion> relatedOpinions = new ArrayList<Opinion>();
     40
    3441    //getters
    3542    public Long getProfessorId() {
     
    4552        return faculty;
    4653    }
     54
     55    @JsonManagedReference
     56    public List<Opinion> getRelatedOpinions() {
     57        return relatedOpinions;
     58    }
    4759}
  • springapp/src/main/java/mk/profesori/springapp/Model/StudyProgramme.java

    rb7ec74e r0e62f4d  
    1212import javax.persistence.ManyToOne;
    1313import javax.persistence.OneToMany;
     14import javax.persistence.OneToOne;
    1415import javax.persistence.Table;
    1516
     
    3940    private Set<Subject> subjects = new HashSet<>();
    4041
     42    @OneToOne(mappedBy = "relatedStudyProgramme")
     43    private Section relatedSection;
     44
    4145    //getters
    4246    public Long getStudyProgrammeId() {
     
    6165        return subjects;
    6266    }
     67
     68    @JsonManagedReference
     69    public Section getRelatedSection() {
     70        return relatedSection;
     71    }
    6372}
  • springapp/src/main/java/mk/profesori/springapp/Model/Subject.java

    rb7ec74e r0e62f4d  
    11package mk.profesori.springapp.Model;
    22
     3import java.util.ArrayList;
    34import java.util.HashSet;
     5import java.util.List;
    46import java.util.Set;
    57
     8import javax.persistence.CascadeType;
    69import javax.persistence.Column;
    710import javax.persistence.Entity;
     
    1518
    1619import com.fasterxml.jackson.annotation.JsonBackReference;
     20import com.fasterxml.jackson.annotation.JsonManagedReference;
    1721
    1822@Entity
     
    3236    private StudyProgramme studyProgramme;
    3337
     38    @OneToMany(mappedBy = "targetSubject", cascade = CascadeType.ALL)
     39    private List<_Thread> threads = new ArrayList<>();
     40
    3441    //getters
    3542    public Long getSubjectId() {
     
    4552        return studyProgramme;
    4653    }
     54
     55    @JsonManagedReference
     56    public List<_Thread> getThreads() {
     57        return threads;
     58    }
    4759   
    4860}
Note: See TracChangeset for help on using the changeset viewer.