using Microsoft.AspNetCore.Mvc;
|
using System.Net;
|
using System.Net.Http.Headers;
|
using Microsoft.Extensions.Hosting.Internal;
|
using Microsoft.AspNetCore.Http.Extensions;
|
using IStation.Untity;
|
using Furion.DynamicApiController;
|
using System.ComponentModel.DataAnnotations;
|
using Mapster;
|
|
|
namespace IStation.Application
|
{
|
/// <summary>
|
/// MonitorFluctConfigure
|
/// </summary>
|
[Route("Monitor/MonitorFluctConfigure")]
|
[ApiDescriptionSettings("Monitor", Name = "监测波动配置", Order = 500)]
|
public class MonitorFluctAnalyConfigure_Controller : IDynamicApiController
|
{
|
private readonly Service.MonitorFluctConfigure _service = new Service.MonitorFluctConfigure();
|
|
#region Query
|
|
|
/// <summary>
|
/// 通过 CorpID 获取
|
/// </summary>
|
[Route("GetByCorpID@V1.0")]
|
[HttpGet]
|
public List<MonitorFluctConfigureDto> GetByCorpID([FromQuery][Required] CorpIDInput input)
|
{
|
var list = _service.GetByCorpID(input.CorpID);
|
var vm_list = list?.Select(x => x.Adapt<Model.MonitorFluctConfigure, MonitorFluctConfigureDto>()).ToList();
|
return vm_list;
|
}
|
|
/// <summary>
|
/// 通过 ID 获取
|
/// </summary>
|
[Route("GetByID@V1.0")]
|
[HttpGet]
|
public MonitorFluctConfigureDto GetByID([FromQuery][Required] IDUnderCorpInput input)
|
{
|
var model = _service.GetByID(input.CorpID, input.ID);
|
return model?.Adapt<Model.MonitorFluctConfigure, MonitorFluctConfigureDto>();
|
}
|
|
/// <summary>
|
/// 通过 Ids 获取
|
/// </summary>
|
[Route("GetByIds@V1.0")]
|
[HttpGet]
|
public List<MonitorFluctConfigureDto> GetByIds([FromQuery][Required] IdsUnderCorpInput input)
|
{
|
var ids = LongListHelper.ToList(input.Ids);
|
var list = _service.GetByIds(input.CorpID, ids);
|
var vm_list = list?.Select(x => x.Adapt<Model.MonitorFluctConfigure, MonitorFluctConfigureDto>()).ToList();
|
return vm_list;
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取
|
/// </summary>
|
[Route("GetByMonitorPointID@V1.0")]
|
[HttpGet]
|
public List<MonitorFluctConfigureDto> GetByMonitorPointID
|
(
|
[Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")]
|
long CorpID,
|
[Required, Range(1, long.MaxValue, ErrorMessage = "MonitorPointID 必须大于0")]
|
long MonitorPointID
|
)
|
{
|
var list = _service.GetByMonitorPointID(CorpID, MonitorPointID);
|
var vm_list = list?.Select(x => x.Adapt<Model.MonitorFluctConfigure, MonitorFluctConfigureDto>()).ToList();
|
return vm_list;
|
}
|
|
/// <summary>
|
/// 通过 SignalID 获取
|
/// </summary>
|
[Route("GetBySignalID@V1.0")]
|
[HttpGet]
|
public MonitorFluctConfigureDto GetBySignalID
|
(
|
[Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")]
|
long CorpID,
|
[Required, Range(1, long.MaxValue, ErrorMessage = "MonitorPointID 必须大于0")]
|
long MonitorPointID,
|
[Required, Range(1, long.MaxValue, ErrorMessage = "SignalID 必须大于0")]
|
long SignalID
|
)
|
{
|
var model = _service.GetBySignalID(CorpID, MonitorPointID, SignalID);
|
return model?.Adapt<Model.MonitorFluctConfigure, MonitorFluctConfigureDto>();
|
}
|
|
|
#endregion
|
|
#region Insert
|
|
/// <summary>
|
/// 插入一条
|
/// </summary>
|
[Route("Insert@V1.0")]
|
[HttpPost]
|
public long Insert(AddMonitorFluctConfigureInput input)
|
{
|
if (input == null)
|
return default;
|
var model = input.Adapt<AddMonitorFluctConfigureInput, Model.MonitorFluctConfigure>();
|
var id = _service.Insert(model);
|
return id;
|
}
|
|
/// <summary>
|
/// 插入多条
|
/// </summary>
|
[Route("Inserts@V1.0")]
|
[HttpPost]
|
public bool Inserts(List<AddMonitorFluctConfigureInput> inputList)
|
{
|
if (inputList == null || inputList.Count < 1)
|
return false;
|
var list = inputList.Select(x => x.Adapt<AddMonitorFluctConfigureInput, Model.MonitorFluctConfigure>()).ToList();
|
var bol = _service.Inserts(list);
|
return bol;
|
}
|
|
#endregion
|
|
#region Update
|
|
/// <summary>
|
/// 更新一条
|
/// </summary>
|
[Route("Update@V1.0")]
|
[HttpPut]
|
public bool Update(UpdateMonitorFluctConfigureInput input)
|
{
|
if (input == null)
|
return false;
|
var model = _service.GetByID(input.CorpID, input.ID);
|
if (model == null)
|
return false;
|
var rhs = new Model.MonitorFluctConfigure(model);
|
input.Adapt(rhs);
|
var bol = _service.Update(rhs);
|
return bol;
|
}
|
|
/// <summary>
|
/// 更新多条
|
/// </summary>
|
[Route("Updates@V1.0")]
|
[HttpPut]
|
public bool Updates(List<UpdateMonitorFluctConfigureInput> inputList)
|
{
|
if (inputList == null || inputList.Count() < 1)
|
{
|
return false;
|
}
|
var corpIds = inputList.Select(x => x.CorpID).Distinct().ToList();
|
if (corpIds.Count > 1)
|
return false;
|
var modelList = _service.GetByIds(corpIds[0], inputList.Select(x => x.ID).ToList());
|
if (modelList == null || modelList.Count < 1)
|
return false;
|
var rhsList = new List<Model.MonitorFluctConfigure>();
|
modelList.ForEach(x =>
|
{
|
var input = inputList.Find(t => t.ID == x.ID);
|
if (input != null)
|
{
|
var rhs = new Model.MonitorFluctConfigure(x);
|
input.Adapt(rhs);
|
rhsList.Add(rhs);
|
}
|
});
|
if (rhsList.Count < 1)
|
return false;
|
var bol = _service.Updates(rhsList);
|
return bol;
|
}
|
|
/// <summary>
|
/// 更新使用状态
|
/// </summary>
|
[Route("UpdateUseStatus@V1.0")]
|
[HttpPut]
|
public bool UpdateUseStatus([Required] UpdateUseStatusUnderCorpInput input)
|
{
|
var bol = _service.UpdateUseStatus(input.CorpID, input.ID, input.UseStatus);
|
return bol;
|
}
|
|
#endregion
|
|
#region Delete
|
|
/// <summary>
|
/// 删除
|
/// </summary>
|
[Route("DeleteByID@V1.0")]
|
[HttpDelete]
|
public DeleteReasonOutput DeleteByID([FromQuery][Required] IDUnderCorpInput input)
|
{
|
var bol = _service.DeleteByID(input.CorpID, input.ID, out string Msg);
|
return new DeleteReasonOutput() { Success = bol, Reason = Msg };
|
}
|
|
#endregion
|
|
}
|
}
|