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