添加配置管理功能,包括获取和设置配置值的接口及实现
This commit is contained in:
19
Repository/ConfigRepository.cs
Normal file
19
Repository/ConfigRepository.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace Repository;
|
||||
|
||||
public interface IConfigRepository : IBaseRepository<ConfigEntity>
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据Key获取配置
|
||||
/// </summary>
|
||||
Task<ConfigEntity?> GetByKeyAsync(string key);
|
||||
}
|
||||
|
||||
public class ConfigRepository(IFreeSql freeSql) : BaseRepository<ConfigEntity>(freeSql), IConfigRepository
|
||||
{
|
||||
public async Task<ConfigEntity?> GetByKeyAsync(string key)
|
||||
{
|
||||
return await FreeSql.Select<ConfigEntity>()
|
||||
.Where(c => c.Key == key)
|
||||
.FirstAsync();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user