refactor code, add more flexibility for filtering transactions by periods of time
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user