fix
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
namespace WebApi.Controllers;
|
||||
using Application;
|
||||
|
||||
namespace WebApi.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class ConfigController(
|
||||
IConfigService configService
|
||||
IConfigApplication configApplication
|
||||
) : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
@@ -11,16 +13,8 @@ public class ConfigController(
|
||||
/// </summary>
|
||||
public async Task<BaseResponse<string>> GetConfig(string key)
|
||||
{
|
||||
try
|
||||
{
|
||||
var config = await configService.GetConfigByKeyAsync<string>(key);
|
||||
var value = config ?? string.Empty;
|
||||
return value.Ok("配置获取成功");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return $"获取{key}配置失败: {ex.Message}".Fail<string>();
|
||||
}
|
||||
var value = await configApplication.GetConfigAsync(key);
|
||||
return value.Ok("配置获取成功");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -28,14 +22,7 @@ public class ConfigController(
|
||||
/// </summary>
|
||||
public async Task<BaseResponse> SetConfig(string key, string value)
|
||||
{
|
||||
try
|
||||
{
|
||||
await configService.SetConfigByKeyAsync(key, value);
|
||||
return "配置设置成功".Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return $"设置{key}配置失败: {ex.Message}".Fail();
|
||||
}
|
||||
await configApplication.SetConfigAsync(key, value);
|
||||
return "配置设置成功".Ok();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user