private and course

This commit is contained in:
Filip Izydorczyk 2020-07-25 10:56:11 +02:00
parent 7db0d57a99
commit 44b6b794e0
7 changed files with 72 additions and 6 deletions

View File

@ -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> 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;
}
}

View File

@ -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;
}
}

View File

@ -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<Course, Long> {
}

View File

@ -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() {

View File

@ -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;
}

View File

@ -8,5 +8,5 @@ import org.springframework.stereotype.Service;
@Service
public class LecturerService {
@Autowired
LecturerRepository repo;
private LecturerRepository repo;
}

View File

@ -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() {