This commit is contained in:
SunCheng
2026-02-10 17:49:19 +08:00
parent 3e18283e52
commit d052ae5197
104 changed files with 10369 additions and 3000 deletions

View File

@@ -0,0 +1,53 @@
namespace Application;
/// <summary>
/// 配置应用服务接口
/// </summary>
public interface IConfigApplication
{
/// <summary>
/// 获取配置值
/// </summary>
Task<string> GetConfigAsync(string key);
/// <summary>
/// 设置配置值
/// </summary>
Task SetConfigAsync(string key, string value);
}
/// <summary>
/// 配置应用服务实现
/// </summary>
public class ConfigApplication(
IConfigService configService,
ILogger<ConfigApplication> logger
) : IConfigApplication
{
public async Task<string> GetConfigAsync(string key)
{
if (string.IsNullOrWhiteSpace(key))
{
throw new ValidationException("配置键不能为空");
}
var value = await configService.GetConfigByKeyAsync<string>(key);
return value ?? string.Empty;
}
public async Task SetConfigAsync(string key, string value)
{
if (string.IsNullOrWhiteSpace(key))
{
throw new ValidationException("配置键不能为空");
}
var success = await configService.SetConfigByKeyAsync(key, value);
if (!success)
{
throw new BusinessException($"设置配置 {key} 失败");
}
logger.LogInformation("配置 {Key} 已更新", key);
}
}