| | |
| | | /// <summary> |
| | | /// 报警等级 |
| | | /// </summary> |
| | | public class ElbowSeries : IElbowSeries |
| | | public class AssetsElbowSeries : IAssetsElbowSeries |
| | | { |
| | | private readonly HStation.Service.ElbowSeries _service = new(); |
| | | private readonly HStation.Service.AssetsElbowSeries _service = new(); |
| | | |
| | | #region Query |
| | | |
| | | /// <summary> |
| | | /// 获取所有 |
| | | /// </summary> |
| | | public async Task<List<ElbowSeriesDto>> GetAll() |
| | | public async Task<List<AssetsElbowSeriesDto>> GetAll() |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | | var list = _service.GetAll(); |
| | | var vm_list = list?.Select(x => new ElbowSeriesDto(x)).ToList(); |
| | | var vm_list = list?.Select(x => new AssetsElbowSeriesDto(x)).ToList(); |
| | | return vm_list; |
| | | }); |
| | | } |
| | |
| | | /// <summary> |
| | | /// 通过 ID 获取 |
| | | /// </summary> |
| | | public async Task<ElbowSeriesDto> GetByID(long ID) |
| | | public async Task<AssetsElbowSeriesDto> GetByID(long ID) |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | | var model = _service.GetByID(ID); |
| | | return model == null ? null : new ElbowSeriesDto(model); |
| | | return model == null ? null : new AssetsElbowSeriesDto(model); |
| | | }); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 通过 Ids 获取 |
| | | /// </summary> |
| | | public async Task<List<ElbowSeriesDto>> GetByIds(List<long> Ids) |
| | | public async Task<List<AssetsElbowSeriesDto>> GetByIds(List<long> Ids) |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | | var list = _service.GetByIds(Ids); |
| | | var vm_list = list?.Select(x => new ElbowSeriesDto(x)).ToList(); |
| | | var vm_list = list?.Select(x => new AssetsElbowSeriesDto(x)).ToList(); |
| | | return vm_list; |
| | | }); |
| | | } |
| | |
| | | /// <summary> |
| | | /// 插入一条 |
| | | /// </summary> |
| | | public async Task<long> Insert(AddElbowSeriesInput input) |
| | | public async Task<long> Insert(AddAssetsElbowSeriesInput input) |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | | var model = input.Adapt<AddElbowSeriesInput, Model.ElbowSeries>(); |
| | | var model = input.Adapt<AddAssetsElbowSeriesInput, Model.AssetsElbowSeries>(); |
| | | model.SortCode = _service.GetMaxSortCode() + 1; |
| | | var id = _service.Insert(model); |
| | | return id; |
| | |
| | | /// <summary> |
| | | /// 批量插入 |
| | | /// </summary> |
| | | public async Task<bool> Inserts(List<AddElbowSeriesInput> inputList) |
| | | public async Task<bool> Inserts(List<AddAssetsElbowSeriesInput> inputList) |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | | var list = inputList.Select(x => x.Adapt<AddElbowSeriesInput, Model.ElbowSeries>()).ToList(); |
| | | var list = inputList.Select(x => x.Adapt<AddAssetsElbowSeriesInput, Model.AssetsElbowSeries>()).ToList(); |
| | | list.ForEach(x => |
| | | { |
| | | x.SortCode = _service.GetMaxSortCode() + 1 + list.IndexOf(x); |
| | |
| | | /// <summary> |
| | | /// 大批量插入 |
| | | /// </summary> |
| | | public async Task<bool> BulkInserts(List<AddElbowSeriesInput> list) |
| | | public async Task<bool> BulkInserts(List<AddAssetsElbowSeriesInput> list) |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | |
| | | /// <summary> |
| | | /// 更新一条 |
| | | /// </summary> |
| | | public async Task<bool> Update(UpdateElbowSeriesInput input) |
| | | public async Task<bool> Update(UpdateAssetsElbowSeriesInput input) |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | |
| | | throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"ID:{input.ID} 数据不存在"); |
| | | } |
| | | |
| | | var rhs = new Model.ElbowSeries(model); |
| | | var rhs = new Model.AssetsElbowSeries(model); |
| | | input.Adapt(rhs); |
| | | var bol = _service.Update(rhs); |
| | | return bol; |
| | |
| | | /// <summary> |
| | | /// 批量更新 |
| | | /// </summary> |
| | | public async Task<bool> Updates(List<UpdateElbowSeriesInput> inputList) |
| | | public async Task<bool> Updates(List<UpdateAssetsElbowSeriesInput> inputList) |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | |
| | | { |
| | | return false; |
| | | } |
| | | var list = inputList.Select(x => x.Adapt<UpdateElbowSeriesInput, Model.ElbowSeries>()).ToList(); |
| | | var list = inputList.Select(x => x.Adapt<UpdateAssetsElbowSeriesInput, Model.AssetsElbowSeries>()).ToList(); |
| | | var bol = _service.Updates(list); |
| | | return bol; |
| | | }); |
| | |
| | | /// <summary> |
| | | /// 大批量更新 |
| | | /// </summary> |
| | | public async Task<bool> BulkUpdates(List<UpdateElbowSeriesInput> list) |
| | | public async Task<bool> BulkUpdates(List<UpdateAssetsElbowSeriesInput> list) |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |