| | |
| | | /// PumpMain |
| | | /// </summary> |
| | | [Route("Assets/PumpPart")] |
| | | [ApiDescriptionSettings("Assets", Name = "资产", Order = 70000)] |
| | | [ApiDescriptionSettings("Assets", Name = "PumpPart", Order = 600000)] |
| | | public class PumpPart_Controller : IDynamicApiController |
| | | { |
| | | private readonly HStation.Service.PumpPartMain _service = new(); |
| | |
| | | /// </summary> |
| | | [Route("GetByID@V1.0")] |
| | | [HttpGet] |
| | | public PumpPartMainDto GetByID(long ID) |
| | | public PumpPartMainDto GetByID([FromQuery][Required] IDInput input) |
| | | { |
| | | var model = _service.GetByID(ID); |
| | | var model = _service.GetByID(input.ID); |
| | | return model == null ? null : new PumpPartMainDto(model); |
| | | } |
| | | |
| | |
| | | /// </summary> |
| | | [Route("GetByIds@V1.0")] |
| | | [HttpGet] |
| | | public List<PumpPartMainDto> GetByIds(List<long> Ids) |
| | | public List<PumpPartMainDto> GetByIds([FromQuery][Required] IdsInput input) |
| | | { |
| | | var list = _service.GetByIds(Ids); |
| | | var ids = LongListHelper.ToList(input.Ids); |
| | | var list = _service.GetByIds(ids); |
| | | var vm_list = list?.Select(x => new PumpPartMainDto(x)).ToList(); |
| | | return vm_list; |
| | | } |
| | |
| | | /// </summary> |
| | | [Route("Insert@V1.0")] |
| | | [HttpPost] |
| | | public long Insert(AddPumpPartMainDto input) |
| | | public long Insert(AddPumpPartMainInput input) |
| | | { |
| | | var model = input.Adapt<AddPumpPartMainDto, Model.PumpPartMain>(); |
| | | var model = input.Adapt<AddPumpPartMainInput, Model.PumpPartMain>(); |
| | | model.SortCode = _service.GetMaxSortCode() + 1; |
| | | var id = _service.Insert(model); |
| | | return id; |
| | |
| | | /// </summary> |
| | | [Route("Inserts@V1.0")] |
| | | [HttpPost] |
| | | public bool Inserts(List<AddPumpPartMainDto> inputList) |
| | | public bool Inserts(List<AddPumpPartMainInput> inputList) |
| | | { |
| | | var list = inputList.Select(x => x.Adapt<AddPumpPartMainDto, Model.PumpPartMain>()).ToList(); |
| | | var list = inputList.Select(x => x.Adapt<AddPumpPartMainInput, Model.PumpPartMain>()).ToList(); |
| | | list.ForEach(x => |
| | | { |
| | | x.SortCode = _service.GetMaxSortCode() + 1 + list.IndexOf(x); |
| | |
| | | //插入拓展 |
| | | [Route("InsertEx@V1.0")] |
| | | [HttpPost] |
| | | public long InsertEx(AddPumpPartMainDto part, List<AddPumpPropContentDto> propcontents, AddPumpMainAndPartMapDto partmap) |
| | | public long InsertEx(AddPumpPartMainInput part, List<AddPumpPropContentInput> propcontents, AddPumpMainAndPartMapDto partmap) |
| | | { |
| | | var partmodel = part.Adapt<AddPumpPartMainDto, Model.PumpPartMain>(); |
| | | var partmodel = part.Adapt<AddPumpPartMainInput, Model.PumpPartMain>(); |
| | | partmodel.SortCode = _service.GetMaxSortCode() + 1; |
| | | var propcontentlistmodel = propcontents.Select(x => x.Adapt<AddPumpPropContentDto, Model.PumpPropContent>()).ToList(); |
| | | var propcontentlistmodel = propcontents.Select(x => x.Adapt<AddPumpPropContentInput, Model.PumpPropContent>()).ToList(); |
| | | var partmapmodel = partmap.Adapt<AddPumpMainAndPartMapDto, Model.PumpMainAndPartMap>(); |
| | | var id = _service.InsertEX(partmodel, propcontentlistmodel, partmapmodel); |
| | | return id; |
| | |
| | | /// </summary> |
| | | [Route("Update@V1.0")] |
| | | [HttpPut] |
| | | public bool Update(UpdatePumpPartMainDto input) |
| | | public bool Update([Required] UpdatePumpPartMainInput input) |
| | | { |
| | | var model = _service.GetByID(input.ID); |
| | | if (model == null) |
| | |
| | | /// </summary> |
| | | [Route("Updates@V1.0")] |
| | | [HttpPut] |
| | | public bool Updates(List<UpdatePumpPartMainDto> inputList) |
| | | public bool Updates([Required] List<UpdatePumpPartMainInput> inputList) |
| | | { |
| | | if (inputList == null || inputList.Count < 1) |
| | | { |
| | | return false; |
| | | } |
| | | var list = inputList.Select(x => x.Adapt<UpdatePumpPartMainDto, Model.PumpPartMain>()).ToList(); |
| | | var list = inputList.Select(x => x.Adapt<UpdatePumpPartMainInput, Model.PumpPartMain>()).ToList(); |
| | | var bol = _service.Updates(list); |
| | | return bol; |
| | | } |
| | |
| | | //编辑拓展 |
| | | [Route("UpdateEx@V1.0")] |
| | | [HttpPut] |
| | | public bool UpdateEx(UpdatePumpPartMainDto pumppart, List<UpdatePumpPropContentDto> updatePumpPropContentDtos) |
| | | public bool UpdateEx(UpdatePumpPartMainInput pumppart, List<UpdatePumpPropContentInput> updatePumpPropContentDtos) |
| | | { |
| | | var partmodel = pumppart.Adapt<UpdatePumpPartMainDto, Model.PumpPartMain>(); |
| | | var propcontentlistmodel = updatePumpPropContentDtos.Select(x => x.Adapt<UpdatePumpPropContentDto, Model.PumpPropContent>()).ToList(); |
| | | var partmodel = pumppart.Adapt<UpdatePumpPartMainInput, Model.PumpPartMain>(); |
| | | var propcontentlistmodel = updatePumpPropContentDtos.Select(x => x.Adapt<UpdatePumpPropContentInput, Model.PumpPropContent>()).ToList(); |
| | | return _service.UpdateEX(partmodel, propcontentlistmodel); |
| | | } |
| | | |
| | |
| | | /// </summary> |
| | | [Route("UpdateSortCode@V1.0")] |
| | | [HttpPut] |
| | | public bool UpdateSortCode(long ID, int SortCode) |
| | | public bool UpdateSortCode([Required] UpdateSortCodeInput input) |
| | | { |
| | | var bol = _service.UpdateSortCode(ID, SortCode); |
| | | var bol = _service.UpdateSortCode(input.ID, input.SortCode); |
| | | return bol; |
| | | } |
| | | |
| | |
| | | /// </summary> |
| | | [Route("UpdateSorter@V1.0")] |
| | | [HttpPut] |
| | | public bool UpdateSorter(List<UpdateSortCodeInput> inputList) |
| | | public bool UpdateSorter([Required] List<UpdateSortCodeInput> inputList) |
| | | { |
| | | if (inputList == null || inputList.Count < 1) |
| | | { |
| | | return false; |
| | | } |
| | | var list = inputList.Select(x => x.Adapt<Yw.Model.Sorter>()).ToList(); |
| | | var bol = _service.UpdateSorter(list); |
| | | return bol; |
| | |
| | | /// </summary> |
| | | [Route("DeleteByID@V1.0")] |
| | | [HttpDelete] |
| | | public bool DeleteByID(long ID) |
| | | public bool DeleteByID([FromQuery][Required] IDInput input) |
| | | { |
| | | var bol = _service.DeleteByID(ID, out string msg); |
| | | var bol = _service.DeleteByID(input.ID, out string msg); |
| | | if (!bol) |
| | | { |
| | | throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D999, msg); |