namespace IStation.Application
|
{
|
/// <summary>
|
/// 输水调度配置
|
/// </summary>
|
[AllowAnonymous]
|
[Route("OpenApi/Dispatch/Config")]
|
[ApiDescriptionSettings("Schedule", Name = "调度配置", Order = 1)]
|
public class ScheduleConfig_Controller : IDynamicApiController, ITransient
|
{
|
private readonly Service.ScheduleConfig _service_schedule_config = new();
|
|
/// <summary>
|
/// 获取配置
|
/// </summary>
|
[Route("Get")]
|
[HttpGet]
|
[NonUnify]
|
public ChScheduleConfigDto Get()
|
{
|
var request_id = Yw.YitIdHelper.NextId();
|
var log_title = "调度配置";
|
ScheduleLog.Info(request_id, log_title, "获取!");
|
var schedule_config = _service_schedule_config.Get();
|
if (schedule_config == null)
|
{
|
ScheduleLog.Info(request_id, log_title, "获取:ScheduleConfig文件缺失!");
|
return default;
|
}
|
var dto = schedule_config.Adapt<Model.ChScheduleConfig, ChScheduleConfigDto>();
|
return dto;
|
}
|
|
|
/// <summary>
|
/// 保存配置
|
/// </summary>
|
[AllowAnonymous]
|
[Route("Save")]
|
[HttpPost]
|
[NonUnify]
|
public SaveChScheduleConfigOutput Save([Required] ChScheduleConfigInput input)
|
{
|
if (input == null)
|
{
|
return new SaveChScheduleConfigOutput() { Result = false, Msg = "入参不能为空!" };
|
}
|
|
var request_id = Yw.YitIdHelper.NextId();
|
var log_title = "调度配置";
|
ScheduleLog.Info(request_id, log_title, "保存!");
|
ScheduleLog.Debug(request_id, log_title, JsonHelper.Object2Json(input));
|
|
var schedule_config = input.Adapt<ChScheduleConfigInput, Model.ChScheduleConfig>();
|
var bol = _service_schedule_config.Save(schedule_config);
|
if (!bol)
|
{
|
ScheduleLog.Info(request_id, log_title, $"保存失败:Save()");
|
return new SaveChScheduleConfigOutput() { Result = false, Msg = "保存失败:Save()" };
|
}
|
|
ScheduleLog.Info(request_id, log_title, $"保存成功!");
|
return new SaveChScheduleConfigOutput() { Result = true, Msg = "保存成功!" };
|
}
|
|
}
|
}
|