feat: add interfaces of repositories for all models
This commit is contained in:
parent
98c889a0cc
commit
4d64662f16
1
app/.gitignore
vendored
1
app/.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
HELP.md
|
||||
data.mv.db
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
|
BIN
app/data.mv.db
BIN
app/data.mv.db
Binary file not shown.
@ -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);
|
||||
}
|
@ -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);
|
||||
|
||||
}
|
@ -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> {
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
@ -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);
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
@ -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);
|
||||
}
|
@ -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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user