diff --git a/app/.gitignore b/app/.gitignore index 549e00a..f990c01 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -1,4 +1,5 @@ HELP.md +data.mv.db target/ !.mvn/wrapper/maven-wrapper.jar !**/src/main/**/target/ diff --git a/app/data.mv.db b/app/data.mv.db index 1add6d4..32ca0ed 100644 Binary files a/app/data.mv.db and b/app/data.mv.db differ diff --git a/app/src/main/java/putBit/app/repositories/AchievementRepository.java b/app/src/main/java/putBit/app/repositories/AchievementRepository.java new file mode 100644 index 0000000..6482c40 --- /dev/null +++ b/app/src/main/java/putBit/app/repositories/AchievementRepository.java @@ -0,0 +1,19 @@ +package putBit.app.repositories; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import putBit.app.models.Achievement; +import putBit.app.models.Benefit; +import putBit.app.models.ExamResult; + +import java.util.List; +import java.util.Optional; +import java.util.UUID; + +public interface AchievementRepository extends JpaRepository { + + Optional> findAchievementsByUserId(int userId); + + Optional> findAchievementsByUserIdNot(int userId); +} diff --git a/app/src/main/java/putBit/app/repositories/BenefitRepository.java b/app/src/main/java/putBit/app/repositories/BenefitRepository.java new file mode 100644 index 0000000..c6a759e --- /dev/null +++ b/app/src/main/java/putBit/app/repositories/BenefitRepository.java @@ -0,0 +1,14 @@ +package putBit.app.repositories; + +import org.springframework.data.jpa.repository.JpaRepository; +import putBit.app.models.Benefit; + +import java.util.List; +import java.util.Optional; + +public interface BenefitRepository extends JpaRepository { + Optional> findBenefitsByUserId(int userId); + + Optional> findBenefitsByUserIdNot(int userId); + +} diff --git a/app/src/main/java/putBit/app/repositories/ExamRepository.java b/app/src/main/java/putBit/app/repositories/ExamRepository.java new file mode 100644 index 0000000..e5e42b1 --- /dev/null +++ b/app/src/main/java/putBit/app/repositories/ExamRepository.java @@ -0,0 +1,11 @@ +package putBit.app.repositories; + +import org.springframework.data.jpa.repository.JpaRepository; +import putBit.app.models.Exam; +import putBit.app.models.User; + +import java.util.Optional; + +public interface ExamRepository extends JpaRepository { + +} diff --git a/app/src/main/java/putBit/app/repositories/ExamResultRepository.java b/app/src/main/java/putBit/app/repositories/ExamResultRepository.java new file mode 100644 index 0000000..2b6ee74 --- /dev/null +++ b/app/src/main/java/putBit/app/repositories/ExamResultRepository.java @@ -0,0 +1,13 @@ +package putBit.app.repositories; + +import org.springframework.data.jpa.repository.JpaRepository; +import putBit.app.models.Exam; +import putBit.app.models.ExamResult; +import putBit.app.models.User; + +import java.util.List; +import java.util.Optional; + +public interface ExamResultRepository extends JpaRepository { + Optional> findByUser(User user); +} diff --git a/app/src/main/java/putBit/app/repositories/OrderRepository.java b/app/src/main/java/putBit/app/repositories/OrderRepository.java new file mode 100644 index 0000000..271f94b --- /dev/null +++ b/app/src/main/java/putBit/app/repositories/OrderRepository.java @@ -0,0 +1,18 @@ +package putBit.app.repositories; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import putBit.app.models.Order; +import putBit.app.models.Training; + +import java.util.List; +import java.util.Optional; + +public interface OrderRepository extends JpaRepository { + @Query(value = "select o.* from orders where " + + "o.user_id = (select u.id from users u where " + + "u.name LIKE %:name% or u.snils like %:snils%) " , nativeQuery = true) + Optional> findByUserInfo(@Param("snils")String snils, @Param("name")String name); + +} diff --git a/app/src/main/java/putBit/app/repositories/TrainingExamRepository.java b/app/src/main/java/putBit/app/repositories/TrainingExamRepository.java new file mode 100644 index 0000000..3376040 --- /dev/null +++ b/app/src/main/java/putBit/app/repositories/TrainingExamRepository.java @@ -0,0 +1,16 @@ +package putBit.app.repositories; + +import org.springframework.data.jpa.repository.JpaRepository; +import putBit.app.models.Benefit; +import putBit.app.models.Order; +import putBit.app.models.TrainingExam; + +import java.util.List; +import java.util.Optional; + +public interface TrainingExamRepository extends JpaRepository { + + Optional> findExamsByTrainingId(int userId); + + Optional> findExamsByTrainingIdNot(int userId); +} diff --git a/app/src/main/java/putBit/app/repositories/TrainingRepository.java b/app/src/main/java/putBit/app/repositories/TrainingRepository.java new file mode 100644 index 0000000..20db99e --- /dev/null +++ b/app/src/main/java/putBit/app/repositories/TrainingRepository.java @@ -0,0 +1,13 @@ +package putBit.app.repositories; + +import org.springframework.data.jpa.repository.JpaRepository; +import putBit.app.models.Training; +import putBit.app.models.User; + +import java.util.List; +import java.util.Optional; + +public interface TrainingRepository extends JpaRepository { + + Optional> findByNumContainingOrTitleContaining(String num, String title); +} diff --git a/app/src/main/java/putBit/app/repositories/UserRepository.java b/app/src/main/java/putBit/app/repositories/UserRepository.java new file mode 100644 index 0000000..a3b6798 --- /dev/null +++ b/app/src/main/java/putBit/app/repositories/UserRepository.java @@ -0,0 +1,15 @@ +package putBit.app.repositories; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import putBit.app.models.User; + +import java.util.List; +import java.util.Optional; +import java.util.UUID; + +public interface UserRepository extends JpaRepository { + + Optional findByEmailAndPassword(String email, String password); +}