fix
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 4m27s
Docker Build & Deploy / Deploy to Production (push) Successful in 7s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 1s
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 4m27s
Docker Build & Deploy / Deploy to Production (push) Successful in 7s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 1s
This commit is contained in:
52
Repository/HolidayRepository.cs
Normal file
52
Repository/HolidayRepository.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
namespace Repository;
|
||||
|
||||
/// <summary>
|
||||
/// 节假日仓储接口
|
||||
/// </summary>
|
||||
public interface IHolidayRepository : IBaseRepository<Holiday>
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据年份获取节假日列表
|
||||
/// </summary>
|
||||
Task<List<Holiday>> GetByYearAsync(int year);
|
||||
|
||||
/// <summary>
|
||||
/// 根据日期范围获取节假日列表
|
||||
/// </summary>
|
||||
Task<List<Holiday>> GetByDateRangeAsync(string startDate, string endDate);
|
||||
|
||||
/// <summary>
|
||||
/// 根据年份删除节假日数据(用于刷新)
|
||||
/// </summary>
|
||||
Task<bool> DeleteByYearAsync(int year);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 节假日仓储实现
|
||||
/// </summary>
|
||||
public class HolidayRepository(IFreeSql freeSql)
|
||||
: BaseRepository<Holiday>(freeSql), IHolidayRepository
|
||||
{
|
||||
public async Task<List<Holiday>> GetByYearAsync(int year)
|
||||
{
|
||||
return await freeSql.Select<Holiday>()
|
||||
.Where(h => h.Year == year)
|
||||
.OrderBy(h => h.Date)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<List<Holiday>> GetByDateRangeAsync(string startDate, string endDate)
|
||||
{
|
||||
return await freeSql.Select<Holiday>()
|
||||
.Where(h => h.Date.CompareTo(startDate) >= 0 && h.Date.CompareTo(endDate) <= 0)
|
||||
.OrderBy(h => h.Date)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteByYearAsync(int year)
|
||||
{
|
||||
return await freeSql.Delete<Holiday>()
|
||||
.Where(h => h.Year == year)
|
||||
.ExecuteAffrowsAsync() > 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user