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>
|
/// SimPaymentRecord
|
/// </summary>
|
[Route("Product/SimPaymentRecord")]
|
[ApiDescriptionSettings("Product", Name = "SIM卡缴费记录", Order = 1000)]
|
public class SimPaymentRecord_Controller : IDynamicApiController
|
{
|
private readonly Service.SimPaymentRecord _service = new Service.SimPaymentRecord();
|
|
#region Query
|
|
/// <summary>
|
/// 通过 CorpID 获取
|
/// </summary>
|
[Route("GetByCorpID@V1.0")]
|
[HttpGet]
|
public List<SimPaymentRecordDto> GetByCorpID([FromQuery][Required] CorpIDInput input)
|
{
|
var list = _service.GetByCorpID(input.CorpID);
|
var vm_list = list?.Select(x => x.Adapt<Model.SimPaymentRecord, SimPaymentRecordDto>()).ToList();
|
return vm_list;
|
}
|
|
/// <summary>
|
/// 通过 ID 获取
|
/// </summary>
|
[Route("GetByID@V1.0")]
|
[HttpGet]
|
public SimPaymentRecordDto GetByID([FromQuery][Required] IDUnderCorpInput input)
|
{
|
var model = _service.GetByID(input.CorpID, input.ID);
|
return model?.Adapt<Model.SimPaymentRecord, SimPaymentRecordDto>();
|
}
|
|
/// <summary>
|
/// 通过 Ids 获取
|
/// </summary>
|
[Route("GetByIds@V1.0")]
|
[HttpGet]
|
public List<SimPaymentRecordDto> 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.SimPaymentRecord, SimPaymentRecordDto>()).ToList();
|
return vm_list;
|
}
|
|
/// <summary>
|
/// 通过 CardID 获取
|
/// </summary>
|
[Route("GetByCardID@V1.0")]
|
[HttpGet]
|
public List<SimPaymentRecordDto> GetByCardID([FromQuery] CardIDUnderCorpInput input)
|
{
|
var list = _service.GetByCardID(input.CorpID, input.CardID);
|
var vmList = list?.Select(x => new SimPaymentRecordDto(x)).ToList();
|
return vmList;
|
}
|
|
/// <summary>
|
/// 通过 CardIds 获取
|
/// </summary>
|
[Route("GetByCardIds@V1.0")]
|
[HttpGet]
|
public List<SimPaymentRecordDto> GetByCardIds([FromQuery] CardIdsUnderCorpInput input)
|
{
|
var productIds = LongListHelper.ToList(input.CardIds);
|
var list = _service.GetByCardIds(input.CorpID, productIds);
|
var vmList = list?.Select(x => new SimPaymentRecordDto(x)).ToList();
|
return vmList;
|
}
|
|
/// <summary>
|
/// 通过 BelongType and BelongID获取
|
/// </summary>
|
[Route("GetByBelongTypeAndBelongID@V1.0")]
|
[HttpGet]
|
public List<SimPaymentRecordDto> GetByBelongTypeAndBelongID([FromQuery][Required] BelongUnderCorpInput input)
|
{
|
var list = _service.GetByBelongTypeAndBelongID(input.CorpID, input.BelongType, input.BelongID);
|
var vmList = list?.Select(x => new SimPaymentRecordDto(x)).ToList();
|
return vmList;
|
}
|
|
#endregion
|
|
#region Insert
|
|
/// <summary>
|
/// 插入一条
|
/// </summary>
|
[Route("Insert@V1.0")]
|
[HttpPost]
|
public long Insert(AddSimPaymentRecordInput input)
|
{
|
if (input == null)
|
return default;
|
var model = input.Adapt<AddSimPaymentRecordInput, Model.SimPaymentRecord>();
|
var id = _service.Insert(model);
|
return id;
|
}
|
|
/// <summary>
|
/// 插入多条
|
/// </summary>
|
[Route("Inserts@V1.0")]
|
[HttpPost]
|
public bool Inserts(List<AddSimPaymentRecordInput> inputList)
|
{
|
if (inputList == null || inputList.Count < 1)
|
return false;
|
var list = inputList.Select(x => x.Adapt<AddSimPaymentRecordInput, Model.SimPaymentRecord>()).ToList();
|
var bol = _service.Inserts(list);
|
return bol;
|
}
|
|
#endregion
|
|
#region Update
|
|
/// <summary>
|
/// 更新一条
|
/// </summary>
|
[Route("Update@V1.0")]
|
[HttpPut]
|
public bool Update(UpdateSimPaymentRecordInput input)
|
{
|
if (input == null)
|
return false;
|
var model = _service.GetByID(input.CorpID, input.ID);
|
if (model == null)
|
return false;
|
var rhs = new Model.SimPaymentRecord(model);
|
input.Adapt(rhs);
|
var bol = _service.Update(rhs);
|
return bol;
|
}
|
|
/// <summary>
|
/// 更新多条
|
/// </summary>
|
[Route("Updates@V1.0")]
|
[HttpPut]
|
public bool Updates(List<UpdateSimPaymentRecordInput> 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.SimPaymentRecord>();
|
modelList.ForEach(x => {
|
var input = inputList.Find(t => t.ID == x.ID);
|
if (input != null)
|
{
|
var rhs = new Model.SimPaymentRecord(x);
|
input.Adapt(rhs);
|
rhsList.Add(rhs);
|
}
|
});
|
if (rhsList.Count < 1)
|
return false;
|
var bol = _service.Updates(rhsList);
|
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
|
|
|
}
|
}
|