feat: added service method
This commit is contained in:
parent
3595da2004
commit
e50a3f1387
2 changed files with 8 additions and 0 deletions
|
@ -7,6 +7,7 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface ExpenseRepository extends JpaRepository<Expense, Long>, JpaSpecificationExecutor<Expense> {
|
||||
|
@ -16,4 +17,7 @@ public interface ExpenseRepository extends JpaRepository<Expense, Long>, JpaSpec
|
|||
|
||||
@Query("SELECT e FROM Expense e JOIN e.debtors d WHERE d.id = :personId")
|
||||
Set<Expense> findDebtorsExpensesByPersonId(@Param("personId") Long personId);
|
||||
|
||||
@Query("SELECT e FROM Expense e WHERE YEAR(e.date) = :year")
|
||||
List<Expense> findAllByYear(@Param("year") int year);
|
||||
}
|
|
@ -54,4 +54,8 @@ public class ExpenseService {
|
|||
return (int) repository.count();
|
||||
}
|
||||
|
||||
public List<Expense> findAllByYear(final int year ) {
|
||||
return this.repository.findAllByYear(year);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue