添加功能
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 29s
Docker Build & Deploy / Deploy to Production (push) Successful in 6s

This commit is contained in:
孙诚
2025-12-29 20:30:15 +08:00
parent a13e1fe9e8
commit 0d94276a0d
22 changed files with 560706 additions and 138 deletions

View File

@@ -16,6 +16,11 @@ public interface IBaseRepository<T> where T : BaseEntity
/// </summary>
Task<T?> GetByIdAsync(long id);
/// <summary>
/// 根据ID获取单条数据
/// </summary>
Task<T[]> GetByIdsAsync(long[] ids);
/// <summary>
/// 添加数据
/// </summary>
@@ -76,6 +81,19 @@ public abstract class BaseRepository<T>(IFreeSql freeSql) : IBaseRepository<T> w
}
}
public virtual async Task<T[]> GetByIdsAsync(long[] ids)
{
try
{
var result = await FreeSql.Select<T>().Where(x => ids.Contains(x.Id)).ToListAsync();
return result.ToArray();
}
catch
{
return [];
}
}
public virtual async Task<bool> AddAsync(T entity)
{
try