- Timestamp:
- 07/28/22 21:12:41 (2 years ago)
- Branches:
- main
- Children:
- 4a64cf0
- Parents:
- 0e62f4d
- Location:
- springapp/src/main/java/mk/profesori/springapp
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
springapp/src/main/java/mk/profesori/springapp/Controller/MainController.java
r0e62f4d r7cb8c3c 5 5 6 6 import org.springframework.beans.factory.annotation.Autowired; 7 import org.springframework.web.bind.annotation.CrossOrigin; 7 8 import org.springframework.web.bind.annotation.PathVariable; 8 9 import org.springframework.web.bind.annotation.RequestMapping; … … 19 20 20 21 @RestController 22 @CrossOrigin(origins = "http://192.168.0.17:3000") 21 23 public class MainController { 22 24 -
springapp/src/main/java/mk/profesori/springapp/Model/City.java
r0e62f4d r7cb8c3c 12 12 import javax.persistence.Table; 13 13 14 import com.fasterxml.jackson.annotation.JsonManagedReference; 14 import com.fasterxml.jackson.annotation.JsonIdentityInfo; 15 import com.fasterxml.jackson.annotation.ObjectIdGenerators; 15 16 16 17 @Entity 17 18 @Table(name = "city") 19 @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "cityId") 18 20 public class City { 19 21 … … 29 31 private Set<University> universities = new HashSet<>(); 30 32 31 // getters33 // getters 32 34 public Long getCityId() { 33 35 return cityId; … … 38 40 } 39 41 40 @JsonManagedReference41 42 public Set<University> getUniversities() { 42 43 return universities; 43 44 } 44 45 45 46 } -
springapp/src/main/java/mk/profesori/springapp/Model/CustomUserDetails.java
r0e62f4d r7cb8c3c 22 22 import org.springframework.security.core.userdetails.UserDetails; 23 23 24 import com.fasterxml.jackson.annotation.JsonManagedReference; 24 import com.fasterxml.jackson.annotation.JsonIdentityInfo; 25 import com.fasterxml.jackson.annotation.ObjectIdGenerators; 25 26 26 27 import lombok.EqualsAndHashCode; … … 34 35 @NoArgsConstructor 35 36 @Entity 37 @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id") 36 38 public class CustomUserDetails implements UserDetails { 37 39 … … 40 42 @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "user_sequence") 41 43 private Long id; 42 private String fullName; // opcionalno, smee da e prazno44 private String fullName; // opcionalno, smee da e prazno 43 45 private String username; 44 46 private String email; … … 97 99 } 98 100 99 @JsonManagedReference100 101 List<Post> getAuthoredPosts() { 101 102 return this.authoredPosts; 102 103 } 103 104 104 105 } -
springapp/src/main/java/mk/profesori/springapp/Model/Faculty.java
r0e62f4d r7cb8c3c 14 14 import javax.persistence.Table; 15 15 16 import com.fasterxml.jackson.annotation.Json BackReference;17 import com.fasterxml.jackson.annotation. JsonManagedReference;16 import com.fasterxml.jackson.annotation.JsonIdentityInfo; 17 import com.fasterxml.jackson.annotation.ObjectIdGenerators; 18 18 19 19 @Entity 20 20 @Table(name = "faculty") 21 @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "facultyId") 21 22 public class Faculty { 22 23 … … 39 40 private Set<StudyProgramme> studyProgrammes = new HashSet<>(); 40 41 41 // getters42 // getters 42 43 public Long getFacultyId() { 43 44 return facultyId; … … 48 49 } 49 50 50 @JsonBackReference51 51 public University getUniversity() { 52 52 return university; 53 53 } 54 54 55 @JsonManagedReference56 55 public Set<Professor> getProfessors() { 57 56 return professors; 58 57 } 59 58 60 @JsonManagedReference61 59 public Set<StudyProgramme> getStudyProgrammes() { 62 60 return studyProgrammes; 63 61 } 64 62 65 63 } -
springapp/src/main/java/mk/profesori/springapp/Model/Opinion.java
r0e62f4d r7cb8c3c 9 9 import javax.persistence.ManyToOne; 10 10 11 import com.fasterxml.jackson.annotation.JsonBackReference;12 13 11 @Entity 14 12 @DiscriminatorValue("opinion") 15 public class Opinion extends Post {13 public class Opinion extends Post { 16 14 17 15 @ManyToOne … … 26 24 } 27 25 28 //getters and setters 29 @JsonBackReference 26 // getters and setters 30 27 public Professor getTargetProfessor() { 31 28 return targetProfessor; -
springapp/src/main/java/mk/profesori/springapp/Model/Post.java
r0e62f4d r7cb8c3c 19 19 import javax.persistence.OneToMany; 20 20 21 import com.fasterxml.jackson.annotation.Json BackReference;22 import com.fasterxml.jackson.annotation. JsonManagedReference;21 import com.fasterxml.jackson.annotation.JsonIdentityInfo; 22 import com.fasterxml.jackson.annotation.ObjectIdGenerators; 23 23 24 @Entity(name ="post")24 @Entity(name = "post") 25 25 @Inheritance(strategy = InheritanceType.SINGLE_TABLE) 26 @DiscriminatorColumn(name ="post_type",27 discriminatorType = DiscriminatorType.STRING)26 @DiscriminatorColumn(name = "post_type", discriminatorType = DiscriminatorType.STRING) 27 @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "postId") 28 28 public class Post { 29 29 30 30 @Id 31 31 @GeneratedValue(strategy = GenerationType.IDENTITY) 32 32 @Column(name = "id") 33 33 private Long postId; 34 34 35 35 @Column(name = "title") 36 36 private String title; 37 37 38 @Column(name = "content", columnDefinition ="TEXT")38 @Column(name = "content", columnDefinition = "TEXT") 39 39 private String content; 40 40 41 41 @ManyToOne 42 42 @JoinColumn(name = "custom_user_details_id") 43 43 private CustomUserDetails author; 44 44 45 45 @Column(name = "time_posted") 46 46 private LocalDateTime timePosted; … … 58 58 @JoinColumn(name = "parent_post_id", nullable = true) 59 59 private Post parent; 60 60 61 61 @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL) 62 62 private List<Post> children = new ArrayList<>(); 63 63 64 // getters and setters64 // getters and setters 65 65 public Long getPostId() { 66 66 return postId; … … 86 86 this.content = content; 87 87 } 88 89 @JsonBackReference 88 90 89 public CustomUserDetails getAuthor() { 91 90 return author; … … 128 127 } 129 128 130 @JsonBackReference131 129 public Post getParent() { 132 130 return parent; … … 137 135 } 138 136 139 @JsonManagedReference140 137 public List<Post> getChildren() { 141 138 return children; … … 160 157 this.children = children; 161 158 } 162 159 163 160 } -
springapp/src/main/java/mk/profesori/springapp/Model/Professor.java
r0e62f4d r7cb8c3c 2 2 3 3 import java.util.ArrayList; 4 import java.util.HashSet;5 4 import java.util.List; 6 import java.util.Set;7 8 5 import javax.persistence.CascadeType; 9 6 import javax.persistence.Column; … … 17 14 import javax.persistence.Table; 18 15 19 import com.fasterxml.jackson.annotation.Json BackReference;20 import com.fasterxml.jackson.annotation. JsonManagedReference;16 import com.fasterxml.jackson.annotation.JsonIdentityInfo; 17 import com.fasterxml.jackson.annotation.ObjectIdGenerators; 21 18 22 19 @Entity 23 20 @Table(name = "professor") 21 @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "professorId") 24 22 public class Professor { 25 23 … … 39 37 private List<Opinion> relatedOpinions = new ArrayList<Opinion>(); 40 38 41 // getters39 // getters 42 40 public Long getProfessorId() { 43 41 return professorId; … … 48 46 } 49 47 50 @JsonBackReference51 48 public Faculty getFaculty() { 52 49 return faculty; 53 50 } 54 51 55 @JsonManagedReference56 52 public List<Opinion> getRelatedOpinions() { 57 53 return relatedOpinions; -
springapp/src/main/java/mk/profesori/springapp/Model/Section.java
r0e62f4d r7cb8c3c 14 14 import javax.persistence.OneToOne; 15 15 16 import com.fasterxml.jackson.annotation.Json BackReference;17 import com.fasterxml.jackson.annotation. JsonManagedReference;16 import com.fasterxml.jackson.annotation.JsonIdentityInfo; 17 import com.fasterxml.jackson.annotation.ObjectIdGenerators; 18 18 19 19 @Entity 20 @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "sectionId") 20 21 public class Section { 21 22 22 23 @Id 23 24 @GeneratedValue(strategy = GenerationType.IDENTITY) … … 35 36 private StudyProgramme relatedStudyProgramme; 36 37 37 // getters and setters38 // getters and setters 38 39 public Long getSectionId() { 39 40 return sectionId; … … 44 45 } 45 46 46 @JsonManagedReference47 47 public List<_Thread> getThreads() { 48 48 return threads; … … 53 53 } 54 54 55 @JsonBackReference56 55 public StudyProgramme getRelatedStudyProgramme() { 57 56 return relatedStudyProgramme; … … 67 66 this.relatedStudyProgramme = relatedStudyProgramme; 68 67 } 69 68 70 69 } -
springapp/src/main/java/mk/profesori/springapp/Model/StudyProgramme.java
r0e62f4d r7cb8c3c 15 15 import javax.persistence.Table; 16 16 17 import com.fasterxml.jackson.annotation.Json BackReference;18 import com.fasterxml.jackson.annotation. JsonManagedReference;17 import com.fasterxml.jackson.annotation.JsonIdentityInfo; 18 import com.fasterxml.jackson.annotation.ObjectIdGenerators; 19 19 20 20 @Entity 21 21 @Table(name = "study_programme") 22 @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "studyProgrammeId") 22 23 public class StudyProgramme { 23 24 … … 43 44 private Section relatedSection; 44 45 45 // getters46 // getters 46 47 public Long getStudyProgrammeId() { 47 48 return studyProgrammeId; … … 56 57 } 57 58 58 @JsonBackReference59 59 public Faculty getFaculty() { 60 60 return faculty; 61 61 } 62 62 63 @JsonManagedReference64 63 public Set<Subject> getSubjects() { 65 64 return subjects; 66 65 } 67 66 68 @JsonManagedReference69 67 public Section getRelatedSection() { 70 68 return relatedSection; -
springapp/src/main/java/mk/profesori/springapp/Model/Subject.java
r0e62f4d r7cb8c3c 2 2 3 3 import java.util.ArrayList; 4 import java.util.HashSet;5 4 import java.util.List; 6 import java.util.Set;7 8 5 import javax.persistence.CascadeType; 9 6 import javax.persistence.Column; … … 17 14 import javax.persistence.Table; 18 15 19 import com.fasterxml.jackson.annotation.Json BackReference;20 import com.fasterxml.jackson.annotation. JsonManagedReference;16 import com.fasterxml.jackson.annotation.JsonIdentityInfo; 17 import com.fasterxml.jackson.annotation.ObjectIdGenerators; 21 18 22 19 @Entity 23 20 @Table(name = "subject") 21 @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "subjectId") 24 22 public class Subject { 25 23 … … 39 37 private List<_Thread> threads = new ArrayList<>(); 40 38 41 // getters39 // getters 42 40 public Long getSubjectId() { 43 41 return subjectId; … … 48 46 } 49 47 50 @JsonBackReference51 48 public StudyProgramme getStudyProgramme() { 52 49 return studyProgramme; 53 50 } 54 51 55 @JsonManagedReference56 52 public List<_Thread> getThreads() { 57 53 return threads; 58 54 } 59 55 60 56 } -
springapp/src/main/java/mk/profesori/springapp/Model/University.java
r0e62f4d r7cb8c3c 14 14 import javax.persistence.Table; 15 15 16 import com.fasterxml.jackson.annotation.Json BackReference;17 import com.fasterxml.jackson.annotation. JsonManagedReference;16 import com.fasterxml.jackson.annotation.JsonIdentityInfo; 17 import com.fasterxml.jackson.annotation.ObjectIdGenerators; 18 18 19 19 @Entity 20 @Table(name="university") 20 @Table(name = "university") 21 @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "universityId") 21 22 public class University { 22 23 … … 36 37 private Set<Faculty> faculties = new HashSet<>(); 37 38 38 // getters39 // getters 39 40 public Long getUniversityId() { 40 41 return universityId; … … 45 46 } 46 47 47 @JsonBackReference48 48 public City getCity() { 49 49 return city; 50 50 } 51 51 52 @JsonManagedReference53 52 public Set<Faculty> getFaculties() { 54 53 return faculties; 55 54 } 56 55 57 56 } -
springapp/src/main/java/mk/profesori/springapp/Model/_Thread.java
r0e62f4d r7cb8c3c 11 11 import javax.persistence.JoinColumn; 12 12 import javax.persistence.ManyToOne; 13 14 import com.fasterxml.jackson.annotation.JsonBackReference;15 13 16 14 @Entity … … 39 37 } 40 38 41 // getters39 // getters 42 40 public List<String> getTags() { 43 41 return tags; 44 42 } 45 43 46 @JsonBackReference47 44 public Section getParentSection() { 48 45 return parentSection; 49 46 } 50 47 51 @JsonBackReference52 48 public Subject getTargetSubject() { 53 49 return targetSubject; 54 50 } 55 51 56 52 } -
springapp/src/main/java/mk/profesori/springapp/Repository/UniversityRepository.java
r0e62f4d r7cb8c3c 7 7 8 8 import mk.profesori.springapp.Model.City; 9 import mk.profesori.springapp.Model.Faculty;10 9 import mk.profesori.springapp.Model.University; 11 10 12 11 @Repository 13 public interface UniversityRepository extends CrudRepository<University, Long> {12 public interface UniversityRepository extends CrudRepository<University, Long> { 14 13 15 14 public List<University> findAll(); 15 16 16 public University findByUniversityId(Long id); 17 17 18 public List<University> findByCity(City city); 18 19 } -
springapp/src/main/java/mk/profesori/springapp/Security/SecurityConfiguration.java
r0e62f4d r7cb8c3c 1 1 package mk.profesori.springapp.Security; 2 2 3 import org.springframework.beans.factory.annotation.Autowired;4 3 import org.springframework.context.annotation.Bean; 5 4 import org.springframework.context.annotation.Configuration; … … 28 27 29 28 @Bean 30 public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) throws Exception { 29 public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) 30 throws Exception { 31 31 return authenticationConfiguration.getAuthenticationManager(); 32 32 } 33 33 34 34 @Bean 35 35 protected SecurityFilterChain filterChain(HttpSecurity http) throws Exception { 36 36 http 37 .csrf().disable() //PRIVREMENO 38 .authorizeRequests() 37 .cors() 38 .and() 39 .csrf().disable() // PRIVREMENO 40 .authorizeRequests() 39 41 .antMatchers("/registration/**") 40 42 .permitAll() 41 .anyRequest()42 .authenticated().and()43 .formLogin();44 43 .anyRequest() 44 .permitAll().and() // bese .authenticated() 45 .formLogin(); 46 45 47 return http.build(); 46 48 }
Note:
See TracChangeset
for help on using the changeset viewer.