feat: add interfaces of repositories for all models

This commit is contained in:
Володя 2024-12-07 15:49:28 +04:00
parent 98c889a0cc
commit 4d64662f16
10 changed files with 120 additions and 0 deletions

1
app/.gitignore vendored
View File

@ -1,4 +1,5 @@
HELP.md HELP.md
data.mv.db
target/ target/
!.mvn/wrapper/maven-wrapper.jar !.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/ !**/src/main/**/target/

Binary file not shown.

View File

@ -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<Achievement, Integer> {
Optional<List<Achievement>> findAchievementsByUserId(int userId);
Optional<List<Benefit>> findAchievementsByUserIdNot(int userId);
}

View File

@ -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<Benefit, Integer> {
Optional<List<Benefit>> findBenefitsByUserId(int userId);
Optional<List<Benefit>> findBenefitsByUserIdNot(int userId);
}

View File

@ -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<Exam, Integer> {
}

View File

@ -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<ExamResult, Integer> {
Optional<List<ExamResult>> findByUser(User user);
}

View File

@ -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<Order, Integer> {
@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<List<Order>> findByUserInfo(@Param("snils")String snils, @Param("name")String name);
}

View File

@ -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<TrainingExam, Integer> {
Optional<List<TrainingExam>> findExamsByTrainingId(int userId);
Optional<List<TrainingExam>> findExamsByTrainingIdNot(int userId);
}

View File

@ -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<TrainingRepository, Integer> {
Optional<List<Training>> findByNumContainingOrTitleContaining(String num, String title);
}

View File

@ -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<User, Integer> {
Optional<User> findByEmailAndPassword(String email, String password);
}