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>
|
/// EtaAnalyConfigure
|
/// </summary>
|
[Route("Eta/EtaAnalyConfigure")]
|
[ApiDescriptionSettings("Eta", Name = "能效分析配置", Order = 1900)]
|
public class EtaAnalyConfigure_Controller : IDynamicApiController
|
{
|
private readonly Service.EtaAnalyConfigure _service = new Service.EtaAnalyConfigure();
|
|
|
#region Query
|
|
/// <summary>
|
///获取所有
|
/// </summary>
|
[Route("GetAll@V1.0")]
|
[HttpGet]
|
public List<EtaAnalyConfigureDto> GetAll()
|
{
|
var list = _service.GetAll();
|
var vm_list = list?.Select(x => x.Adapt<Model.EtaAnalyConfigure, EtaAnalyConfigureDto>()).ToList();
|
return vm_list;
|
}
|
|
/// <summary>
|
/// 通过 ID 获取
|
/// </summary>
|
[Route("GetByID@V1.0")]
|
[HttpGet]
|
public EtaAnalyConfigureDto GetByID([FromQuery][Required] IDInput input)
|
{
|
var model = _service.GetByID(input.ID);
|
return model?.Adapt<Model.EtaAnalyConfigure, EtaAnalyConfigureDto>();
|
}
|
|
/// <summary>
|
/// 通过 Ids 获取
|
/// </summary>
|
[Route("GetByIds@V1.0")]
|
[HttpGet]
|
public List<EtaAnalyConfigureDto> GetByIds([FromQuery] IdsInput input)
|
{
|
var ids = LongListHelper.ToList(input.Ids);
|
var list = _service.GetByIds(ids);
|
var vm_list = list?.Select(x => x.Adapt<Model.EtaAnalyConfigure, EtaAnalyConfigureDto>()).ToList();
|
return vm_list;
|
}
|
|
/// <summary>
|
/// 通过 CorpID 获取
|
/// </summary>
|
[Route("GetByCorpID")]
|
[HttpGet]
|
public EtaAnalyConfigureDto GetByCorpID([FromQuery] CorpIDInput input)
|
{
|
var model = _service.GetByCorpID(input.CorpID);
|
return model?.Adapt<Model.EtaAnalyConfigure, EtaAnalyConfigureDto>();
|
}
|
|
#endregion
|
|
#region Insert
|
|
/// <summary>
|
/// 插入一条
|
/// </summary>
|
[Route("Insert@V1.0")]
|
[HttpPost]
|
public long Insert([Required] AddEtaAnalyConfigureInput input)
|
{
|
if (input == null)
|
return default;
|
var model = input.Adapt<AddEtaAnalyConfigureInput, Model.EtaAnalyConfigure>();
|
var id = _service.Insert(model);
|
return id;
|
}
|
|
/// <summary>
|
/// 插入多条
|
/// </summary>
|
[Route("Inserts@V1.0")]
|
[HttpPost]
|
public bool Inserts([Required] List<AddEtaAnalyConfigureInput> inputList)
|
{
|
if (inputList == null || inputList.Count < 1)
|
return false;
|
var list = inputList.Select(x => x.Adapt<AddEtaAnalyConfigureInput, Model.EtaAnalyConfigure>()).ToList();
|
var bol = _service.Inserts(list);
|
return bol;
|
}
|
|
#endregion
|
|
#region Update
|
|
/// <summary>
|
/// 更新一条
|
/// </summary>
|
[Route("Update@V1.0")]
|
[HttpPut]
|
public bool Update([Required] UpdateEtaAnalyConfigureInput input)
|
{
|
if (input == null)
|
return false;
|
var model = _service.GetByID(input.ID);
|
if (model == null)
|
return false;
|
var rhs = new Model.EtaAnalyConfigure(model);
|
input.Adapt(rhs);
|
var bol = _service.Update(rhs);
|
return bol;
|
}
|
|
/// <summary>
|
/// 更新多条
|
/// </summary>
|
[Route("Updates@V1.0")]
|
[HttpPut]
|
public bool Updates([Required] List<UpdateEtaAnalyConfigureInput> inputList)
|
{
|
if (inputList == null || inputList.Count() < 1)
|
{
|
return false;
|
}
|
var modelList = _service.GetByIds(inputList.Select(x => x.ID).ToList());
|
if (modelList == null || modelList.Count < 1)
|
return false;
|
var rhsList = new List<Model.EtaAnalyConfigure>();
|
modelList.ForEach(x => {
|
var input = inputList.Find(t => t.ID == x.ID);
|
if (input != null)
|
{
|
var rhs = new Model.EtaAnalyConfigure(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(UpdateUseStatusInput intput)
|
{
|
var bol = _service.UpdateUseStatus(intput.ID, intput.UseStatus, UserManager.UserID, DateTime.Now);
|
return bol;
|
}
|
|
#endregion
|
|
#region Delete
|
|
/// <summary>
|
/// 通过 ID 删除
|
/// </summary>
|
[Route("DeleteByID@V1.0")]
|
[HttpDelete]
|
public DeleteReasonOutput DeleteByID([FromQuery][Required] IDInput input)
|
{
|
var bol = _service.DeleteByID(input.ID, out string msg);
|
return new DeleteReasonOutput() { Success = bol, Reason = msg };
|
}
|
|
#endregion
|
|
|
}
|
}
|