Added endpoints
This commit is contained in:
@ -22,6 +22,10 @@ public class Course {
|
||||
public Course() {
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
@ -44,4 +44,7 @@ public class Lecturer {
|
||||
this.surname = surname;
|
||||
}
|
||||
|
||||
public Lecturer() {
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package com.plannaplan.repositories;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.plannaplan.entities.Groups;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
@ -11,4 +13,8 @@ import org.springframework.stereotype.Repository;
|
||||
public interface GroupRepository extends JpaRepository<Groups, Long> {
|
||||
@Query(value = "SELECT * FROM groups WHERE time = :time AND room = :room AND capacity = :capacity ", nativeQuery = true)
|
||||
Groups find(@Param("time") int time, @Param("room") String room, @Param("capacity") int capacity);
|
||||
|
||||
@Query(value = "SELECT * FROM groups WHERE course_id = :id", nativeQuery = true)
|
||||
List<Groups> getByCourse(@Param("id") Long id);
|
||||
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package com.plannaplan.services;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.plannaplan.entities.Course;
|
||||
import com.plannaplan.repositories.CourseRepository;
|
||||
|
||||
@ -15,6 +17,10 @@ public class CourseService {
|
||||
return this.repo.findByName(name);
|
||||
}
|
||||
|
||||
public List<Course> getAllCourses() {
|
||||
return this.repo.findAll();
|
||||
}
|
||||
|
||||
public void save(Course course) {
|
||||
this.repo.save(course);
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.plannaplan.services;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.plannaplan.entities.Groups;
|
||||
import com.plannaplan.repositories.GroupRepository;
|
||||
|
||||
@ -18,6 +20,10 @@ public class GroupService {
|
||||
return this.repo.find(time, room, capacity);
|
||||
}
|
||||
|
||||
public List<Groups> getGroupsByCourse(Long id) {
|
||||
return this.repo.getByCourse(id);
|
||||
}
|
||||
|
||||
public void save(Groups group) {
|
||||
this.repo.save(group);
|
||||
}
|
||||
|
Reference in New Issue
Block a user