diff --git a/buisnesslogic/src/main/java/com/plannaplan/entities/Course.java b/buisnesslogic/src/main/java/com/plannaplan/entities/Course.java new file mode 100644 index 0000000..b17983d --- /dev/null +++ b/buisnesslogic/src/main/java/com/plannaplan/entities/Course.java @@ -0,0 +1,41 @@ +package com.plannaplan.entities; + +import java.util.ArrayList; +import java.util.List; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.OneToMany; + +@Entity +public class Course { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + private String name; + private String symbol; + @OneToMany(mappedBy = "id") + private List groups = new ArrayList<>(); + + public Course() { + } + + public String getName() { + return name; + } + + public String getSymbol() { + return symbol; + } + + public void setSymbol(String symbol) { + this.symbol = symbol; + } + + public void setName(String name) { + this.name = name; + } + +} \ No newline at end of file diff --git a/buisnesslogic/src/main/java/com/plannaplan/entities/Groups.java b/buisnesslogic/src/main/java/com/plannaplan/entities/Groups.java index 7f4b6ea..016a6f2 100644 --- a/buisnesslogic/src/main/java/com/plannaplan/entities/Groups.java +++ b/buisnesslogic/src/main/java/com/plannaplan/entities/Groups.java @@ -15,7 +15,9 @@ public class Groups { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; - private Long courseId; + @ManyToOne + @JoinColumn(name = "course_id") + private Course courseId; private int time; private String room; private int capacity; @@ -76,11 +78,11 @@ public class Groups { this.time = time; } - public Long getCourseId() { + public Course getCourseId() { return courseId; } - public void setCourseId(Long courseId) { + public void setCourseId(Course courseId) { this.courseId = courseId; } } \ No newline at end of file diff --git a/buisnesslogic/src/main/java/com/plannaplan/repositories/CourseRepository.java b/buisnesslogic/src/main/java/com/plannaplan/repositories/CourseRepository.java new file mode 100644 index 0000000..df838d2 --- /dev/null +++ b/buisnesslogic/src/main/java/com/plannaplan/repositories/CourseRepository.java @@ -0,0 +1,11 @@ +package com.plannaplan.repositories; + +import com.plannaplan.entities.Course; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface CourseRepository extends JpaRepository { + +} \ No newline at end of file diff --git a/buisnesslogic/src/main/java/com/plannaplan/services/AssignmentService.java b/buisnesslogic/src/main/java/com/plannaplan/services/AssignmentService.java index a133d44..e914c65 100644 --- a/buisnesslogic/src/main/java/com/plannaplan/services/AssignmentService.java +++ b/buisnesslogic/src/main/java/com/plannaplan/services/AssignmentService.java @@ -9,7 +9,7 @@ import org.springframework.stereotype.Service; @Service public class AssignmentService implements EventCreator { @Autowired - AssignmentRepository repo; + private AssignmentRepository repo; @Override public void update() { diff --git a/buisnesslogic/src/main/java/com/plannaplan/services/CourseService.java b/buisnesslogic/src/main/java/com/plannaplan/services/CourseService.java new file mode 100644 index 0000000..008519b --- /dev/null +++ b/buisnesslogic/src/main/java/com/plannaplan/services/CourseService.java @@ -0,0 +1,12 @@ +package com.plannaplan.services; + +import com.plannaplan.repositories.CourseRepository; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class CourseService { + @Autowired + private CourseRepository repo; +} \ No newline at end of file diff --git a/buisnesslogic/src/main/java/com/plannaplan/services/LecturerService.java b/buisnesslogic/src/main/java/com/plannaplan/services/LecturerService.java index 3b2de4b..306ff1e 100644 --- a/buisnesslogic/src/main/java/com/plannaplan/services/LecturerService.java +++ b/buisnesslogic/src/main/java/com/plannaplan/services/LecturerService.java @@ -8,5 +8,5 @@ import org.springframework.stereotype.Service; @Service public class LecturerService { @Autowired - LecturerRepository repo; + private LecturerRepository repo; } \ No newline at end of file diff --git a/buisnesslogic/src/main/java/com/plannaplan/services/UserService.java b/buisnesslogic/src/main/java/com/plannaplan/services/UserService.java index 18ca809..8b7dc5f 100644 --- a/buisnesslogic/src/main/java/com/plannaplan/services/UserService.java +++ b/buisnesslogic/src/main/java/com/plannaplan/services/UserService.java @@ -9,7 +9,7 @@ import org.springframework.stereotype.Service; @Service public class UserService implements EventCreator { @Autowired - UserRepository repo; + private UserRepository repo; @Override public void update() {