refactor code, add more flexibility for filtering transactions by periods of time

This commit is contained in:
mirrerror
2023-11-21 12:46:55 +02:00
parent c13056ae7f
commit a484e8e6d2
8 changed files with 28 additions and 34 deletions

View File

@@ -5,6 +5,7 @@ import com.faf223.expensetrackerfaf.model.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.query.Procedure;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.util.List;
@@ -16,15 +17,19 @@ public interface IncomeRepository extends JpaRepository<Income, Long> {
List<Income> findByDateBetween(LocalDate start, LocalDate end);
@Transactional(readOnly = true)
@Procedure(procedureName = "get_incomes_by_month")
List<Income> filterByMonth(int month);
@Transactional(readOnly = true)
@Procedure(procedureName = "get_last_week_incomes")
List<Income> findLastWeek();
@Transactional(readOnly = true)
@Procedure(procedureName = "get_last_month_incomes")
List<Income> findLastMonth();
@Transactional(readOnly = true)
@Procedure(procedureName = "get_incomes_by_year_interval")
List<Income> filterByYearInterval(int start, int end);
}