| | |
| | | namespace HStation.Application |
| | | { |
| | | /// <summary> |
| | | /// PumpMain |
| | | /// AssetsPumpMain |
| | | /// </summary> |
| | | [Route("Assets/PumpPart")] |
| | | [ApiDescriptionSettings("Assets", Name = "PumpPart", Order = 600000)] |
| | | public class PumpPart_Controller : IDynamicApiController |
| | | { |
| | | private readonly HStation.Service.PumpPartMain _service = new(); |
| | | private readonly HStation.Service.AssetsPumpPartMain _service = new(); |
| | | |
| | | #region Query |
| | | |
| | |
| | | /// </summary> |
| | | [Route("GetAll@V1.0")] |
| | | [HttpGet] |
| | | public List<PumpPartMainDto> GetAll() |
| | | public List<AssetsPumpPartMainDto> GetAll() |
| | | { |
| | | var list = _service.GetAll(); |
| | | var vm_list = list?.Select(x => new PumpPartMainDto(x)).ToList(); |
| | | var vm_list = list?.Select(x => new AssetsPumpPartMainDto(x)).ToList(); |
| | | return vm_list; |
| | | } |
| | | |
| | |
| | | /// </summary> |
| | | [Route("GetByID@V1.0")] |
| | | [HttpGet] |
| | | public PumpPartMainDto GetByID([FromQuery][Required] IDInput input) |
| | | public AssetsPumpPartMainDto GetByID([FromQuery][Required] IDInput input) |
| | | { |
| | | var model = _service.GetByID(input.ID); |
| | | return model == null ? null : new PumpPartMainDto(model); |
| | | return model == null ? null : new AssetsPumpPartMainDto(model); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | [Route("GetByIds@V1.0")] |
| | | [HttpGet] |
| | | public List<PumpPartMainDto> GetByIds([FromQuery][Required] IdsInput input) |
| | | public List<AssetsPumpPartMainDto> GetByIds([FromQuery][Required] IdsInput input) |
| | | { |
| | | var ids = LongListHelper.ToList(input.Ids); |
| | | var list = _service.GetByIds(ids); |
| | | var vm_list = list?.Select(x => new PumpPartMainDto(x)).ToList(); |
| | | var vm_list = list?.Select(x => new AssetsPumpPartMainDto(x)).ToList(); |
| | | return vm_list; |
| | | } |
| | | |
| | |
| | | /// </summary> |
| | | [Route("GetByPumpMainID@V1.0")] |
| | | [HttpGet] |
| | | public List<PumpPartMainDto> GetByPumpMainID(long ID) |
| | | public List<AssetsPumpPartMainDto> GetByPumpMainID(long ID) |
| | | { |
| | | var list = _service.GetByMainID(ID); |
| | | var vm_list = list?.Select(x => new PumpPartMainDto(x)).ToList(); |
| | | var vm_list = list?.Select(x => new AssetsPumpPartMainDto(x)).ToList(); |
| | | return vm_list; |
| | | } |
| | | |
| | |
| | | /// </summary> |
| | | [Route("Insert@V1.0")] |
| | | [HttpPost] |
| | | public long Insert(AddPumpPartMainInput input) |
| | | public long Insert(AddAssetsPumpPartMainInput input) |
| | | { |
| | | var model = input.Adapt<AddPumpPartMainInput, Model.PumpPartMain>(); |
| | | var model = input.Adapt<AddAssetsPumpPartMainInput, Model.AssetsPumpPartMain>(); |
| | | model.SortCode = _service.GetMaxSortCode() + 1; |
| | | var id = _service.Insert(model); |
| | | return id; |
| | |
| | | /// </summary> |
| | | [Route("Inserts@V1.0")] |
| | | [HttpPost] |
| | | public bool Inserts(List<AddPumpPartMainInput> inputList) |
| | | public bool Inserts(List<AddAssetsPumpPartMainInput> inputList) |
| | | { |
| | | var list = inputList.Select(x => x.Adapt<AddPumpPartMainInput, Model.PumpPartMain>()).ToList(); |
| | | var list = inputList.Select(x => x.Adapt<AddAssetsPumpPartMainInput, Model.AssetsPumpPartMain>()).ToList(); |
| | | list.ForEach(x => |
| | | { |
| | | x.SortCode = _service.GetMaxSortCode() + 1 + list.IndexOf(x); |
| | |
| | | //插入拓展 |
| | | [Route("InsertEx@V1.0")] |
| | | [HttpPost] |
| | | public long InsertEx(AddPumpPartMainInput part, List<AddPumpPropContentInput> propcontents, AddPumpMainAndPartMapDto partmap) |
| | | public long InsertEx(AddAssetsPumpPartMainInput part, List<AddAssetsPumpPropContentInput> propcontents, AddAssetsPumpMainAndPartMapInput partmap) |
| | | { |
| | | var partmodel = part.Adapt<AddPumpPartMainInput, Model.PumpPartMain>(); |
| | | var partmodel = part.Adapt<AddAssetsPumpPartMainInput, Model.AssetsPumpPartMain>(); |
| | | partmodel.SortCode = _service.GetMaxSortCode() + 1; |
| | | var propcontentlistmodel = propcontents.Select(x => x.Adapt<AddPumpPropContentInput, Model.PumpPropContent>()).ToList(); |
| | | var partmapmodel = partmap.Adapt<AddPumpMainAndPartMapDto, Model.PumpMainAndPartMap>(); |
| | | var propcontentlistmodel = propcontents.Select(x => x.Adapt<AddAssetsPumpPropContentInput, Model.AssetsPumpPropContent>()).ToList(); |
| | | var partmapmodel = partmap.Adapt<AddAssetsPumpMainAndPartMapInput, Model.AssetsPumpMainAndPartMap>(); |
| | | var id = _service.InsertEX(partmodel, propcontentlistmodel, partmapmodel); |
| | | return id; |
| | | } |
| | |
| | | /// </summary> |
| | | [Route("Update@V1.0")] |
| | | [HttpPut] |
| | | public bool Update([Required] UpdatePumpPartMainInput input) |
| | | public bool Update([Required] UpdateAssetsPumpPartMainInput input) |
| | | { |
| | | var model = _service.GetByID(input.ID); |
| | | if (model == null) |
| | |
| | | throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"ID:{input.ID} 数据不存在"); |
| | | } |
| | | |
| | | var rhs = new Model.PumpPartMain(model); |
| | | var rhs = new Model.AssetsPumpPartMain(model); |
| | | input.Adapt(rhs); |
| | | var bol = _service.Update(rhs); |
| | | return bol; |
| | |
| | | /// </summary> |
| | | [Route("Updates@V1.0")] |
| | | [HttpPut] |
| | | public bool Updates([Required] List<UpdatePumpPartMainInput> inputList) |
| | | public bool Updates([Required] List<UpdateAssetsPumpPartMainInput> inputList) |
| | | { |
| | | if (inputList == null || inputList.Count < 1) |
| | | { |
| | | return false; |
| | | } |
| | | var list = inputList.Select(x => x.Adapt<UpdatePumpPartMainInput, Model.PumpPartMain>()).ToList(); |
| | | var list = inputList.Select(x => x.Adapt<UpdateAssetsPumpPartMainInput, Model.AssetsPumpPartMain>()).ToList(); |
| | | var bol = _service.Updates(list); |
| | | return bol; |
| | | } |
| | |
| | | //编辑拓展 |
| | | [Route("UpdateEx@V1.0")] |
| | | [HttpPut] |
| | | public bool UpdateEx(UpdatePumpPartMainInput pumppart, List<UpdatePumpPropContentInput> updatePumpPropContentDtos) |
| | | public bool UpdateEx(UpdateAssetsPumpPartMainInput pumppart, List<UpdateAssetsPumpPropContentInput> updateAssetsPumpPropContentDtos) |
| | | { |
| | | var partmodel = pumppart.Adapt<UpdatePumpPartMainInput, Model.PumpPartMain>(); |
| | | var propcontentlistmodel = updatePumpPropContentDtos.Select(x => x.Adapt<UpdatePumpPropContentInput, Model.PumpPropContent>()).ToList(); |
| | | var partmodel = pumppart.Adapt<UpdateAssetsPumpPartMainInput, Model.AssetsPumpPartMain>(); |
| | | var propcontentlistmodel = updateAssetsPumpPropContentDtos.Select(x => x.Adapt<UpdateAssetsPumpPropContentInput, Model.AssetsPumpPropContent>()).ToList(); |
| | | return _service.UpdateEX(partmodel, propcontentlistmodel); |
| | | } |
| | | |
| | |
| | | return true; |
| | | } |
| | | |
| | | [Route("DeleteEx@V1.0")] |
| | | [HttpDelete] |
| | | public bool DeleteEx(long ID) |
| | | { |
| | | var bol = _service.DeleteExByID(ID); |
| | | if (!bol) |
| | | { |
| | | throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D999, "删除失败"); |
| | | } |
| | | return true; |
| | | } |
| | | /* [Route("DeleteEx@V1.0")] |
| | | [HttpDelete] |
| | | public bool DeleteEx(long ID) |
| | | { |
| | | var bol = _service.DeleteExByID(ID); |
| | | if (!bol) |
| | | { |
| | | throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D999, "删除失败"); |
| | | } |
| | | return true; |
| | | }*/ |
| | | |
| | | #endregion Delete |
| | | } |