2026-01-09 14:03:01 +08:00
|
|
|
|
namespace Repository;
|
|
|
|
|
|
|
|
|
|
|
|
public interface IBudgetArchiveRepository : IBaseRepository<BudgetArchive>
|
|
|
|
|
|
{
|
2026-01-12 22:29:39 +08:00
|
|
|
|
Task<BudgetArchive?> GetArchiveAsync(int year, int month);
|
|
|
|
|
|
|
2026-01-09 14:03:01 +08:00
|
|
|
|
Task<List<BudgetArchive>> GetListAsync(int year, int month);
|
2026-01-15 20:00:41 +08:00
|
|
|
|
|
|
|
|
|
|
Task<List<BudgetArchive>> GetArchivesByYearAsync(int year);
|
2026-01-09 14:03:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class BudgetArchiveRepository(
|
|
|
|
|
|
IFreeSql freeSql
|
|
|
|
|
|
) : BaseRepository<BudgetArchive>(freeSql), IBudgetArchiveRepository
|
|
|
|
|
|
{
|
2026-01-12 22:29:39 +08:00
|
|
|
|
public async Task<BudgetArchive?> GetArchiveAsync(int year, int month)
|
2026-01-09 14:03:01 +08:00
|
|
|
|
{
|
|
|
|
|
|
return await FreeSql.Select<BudgetArchive>()
|
2026-01-12 22:29:39 +08:00
|
|
|
|
.Where(a => a.Year == year &&
|
2026-01-09 14:03:01 +08:00
|
|
|
|
a.Month == month)
|
|
|
|
|
|
.ToOneAsync();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<List<BudgetArchive>> GetListAsync(int year, int month)
|
|
|
|
|
|
{
|
|
|
|
|
|
return await FreeSql.Select<BudgetArchive>()
|
2026-01-12 22:29:39 +08:00
|
|
|
|
.Where(a => a.Year == year && a.Month == month)
|
2026-01-09 14:03:01 +08:00
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
}
|
2026-01-15 20:00:41 +08:00
|
|
|
|
|
|
|
|
|
|
public async Task<List<BudgetArchive>> GetArchivesByYearAsync(int year)
|
|
|
|
|
|
{
|
|
|
|
|
|
return await FreeSql.Select<BudgetArchive>()
|
|
|
|
|
|
.Where(a => a.Year == year)
|
|
|
|
|
|
.OrderBy(a => a.Month)
|
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
}
|
2026-01-09 14:03:01 +08:00
|
|
|
|
}
|