Major refactor of reading from excel to db
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
package com.plannaplan.repositories;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.plannaplan.entities.Course;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
@ -10,5 +12,5 @@ import org.springframework.stereotype.Repository;
|
||||
@Repository
|
||||
public interface CourseRepository extends JpaRepository<Course, Long> {
|
||||
@Query("FROM Course WHERE name = ?1")
|
||||
Course findByName(@Param("name") String name);
|
||||
Optional<Course> findByName(@Param("name") String name);
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package com.plannaplan.repositories;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.plannaplan.entities.Groups;
|
||||
|
||||
@ -12,7 +13,7 @@ import org.springframework.stereotype.Repository;
|
||||
@Repository
|
||||
public interface GroupRepository extends JpaRepository<Groups, Long> {
|
||||
@Query("FROM Groups WHERE time = ?1 AND room = ?2 AND capacity = ?3")
|
||||
Groups find(@Param("time") int time, @Param("room") String room, @Param("capacity") int capacity);
|
||||
Optional<Groups> find(@Param("time") int time, @Param("room") String room, @Param("capacity") int capacity);
|
||||
|
||||
@Query("FROM Groups WHERE course_id = ?1")
|
||||
List<Groups> getByCourse(@Param("id") Long id);
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.plannaplan.repositories;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.plannaplan.entities.Lecturer;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
@ -10,5 +12,5 @@ import org.springframework.stereotype.Repository;
|
||||
@Repository
|
||||
public interface LecturerRepository extends JpaRepository<Lecturer, Long> {
|
||||
@Query("FROM Lecturer WHERE title = ?1 AND name = ?2 AND surname = ?3")
|
||||
Lecturer find(@Param("title") String title, @Param("name") String name, @Param("surname") String surname);
|
||||
Optional<Lecturer> find(@Param("title") String title, @Param("name") String name, @Param("surname") String surname);
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package com.plannaplan.repositories;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.plannaplan.entities.User;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
@ -7,10 +9,11 @@ import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
//if result could be null, should we wrapped in optional
|
||||
@Repository
|
||||
public interface UserRepository extends JpaRepository<User, Long> {
|
||||
@Query("FROM User WHERE email = ?1")
|
||||
User getByAuthority(@Param("authority") String authority);
|
||||
Optional<User> getByAuthority(@Param("authority") String authority);
|
||||
|
||||
@Query("FROM User WHERE token = ?1")
|
||||
User getByToken(@Param("token") String token);
|
||||
|
Reference in New Issue
Block a user