using HStation.Dto;
|
using Yw.Dto;
|
|
namespace HStation.CAL.LocalClient
|
{
|
/// <summary>
|
///
|
///</summary>
|
public class AssetsPackagePartMain : IAssetsPackagePartMain
|
{
|
private readonly Service.AssetsPackagePartMain _service = new();
|
|
#region Query
|
|
/// <summary>
|
/// 获取所有
|
/// </summary>
|
public async Task<List<AssetsPackagePartMainDto>> GetAll()
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var list = _service.GetAll();
|
var vm_list = list?.Select(x => new AssetsPackagePartMainDto(x)).ToList();
|
return vm_list;
|
});
|
}
|
|
/// <summary>
|
/// 通过 ID 获取
|
/// </summary>
|
public async Task<AssetsPackagePartMainDto> GetByID(long ID)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var model = _service.GetByID(ID);
|
return model == null ? null : new AssetsPackagePartMainDto(model);
|
});
|
}
|
|
/// <summary>
|
/// 通过型号ID 获取
|
/// </summary>
|
public async Task<List<AssetsPackagePartMainDto>> GetByPackageMainID(long ID)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var list = _service.GetByMainID(ID);
|
var vm_list = list?.Select(x => new AssetsPackagePartMainDto(x)).ToList();
|
return vm_list;
|
});
|
}
|
|
/// <summary>
|
/// 通过 Ids 获取
|
/// </summary>
|
public async Task<List<AssetsPackagePartMainDto>> GetByIds(List<long> Ids)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var list = _service.GetByIds(Ids);
|
var vm_list = list?.Select(x => new AssetsPackagePartMainDto(x)).ToList();
|
return vm_list;
|
});
|
}
|
|
/// <summary>
|
/// 获取最大排序码
|
/// </summary>
|
public async Task<int> GetMaxSortCode()
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var sort_code = _service.GetMaxSortCode();
|
return sort_code;
|
});
|
}
|
|
/// <summary>
|
/// 创建编号
|
/// </summary>
|
public async Task<string> CreateNO()
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var no = _service.CreateNO();
|
return no;
|
});
|
}
|
|
#endregion Query
|
|
#region Insert
|
|
/// <summary>
|
/// 插入一条
|
/// </summary>
|
public async Task<long> Insert(AddAssetsPackagePartMainInput input)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var model = input.Adapt<AddAssetsPackagePartMainInput, Model.AssetsPackagePartMain>();
|
model.SortCode = _service.GetMaxSortCode() + 1;
|
var id = _service.Insert(model);
|
return id;
|
});
|
}
|
|
//插入拓展
|
public async Task<long> InsertEx(AddAssetsPackagePartMainInput part, List<AddAssetsPackagePropContentInput> propcontents, AddAssetsPackageMainAndPartMappingInput partmap)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var partmodel = part.Adapt<AddAssetsPackagePartMainInput, Model.AssetsPackagePartMain>();
|
partmodel.SortCode = _service.GetMaxSortCode() + 1;
|
var propcontentlistmodel = propcontents.Select(x => x.Adapt<AddAssetsPackagePropContentInput, Model.AssetsPackagePropContent>()).ToList();
|
var partmapmodel = partmap.Adapt<AddAssetsPackageMainAndPartMappingInput, Model.AssetsPackageMainAndPartMapping>();
|
var id = _service.InsertEX(partmodel, propcontentlistmodel, partmapmodel);
|
return id;
|
});
|
}
|
|
/// <summary>
|
/// 批量插入
|
/// </summary>
|
public async Task<bool> Inserts(List<AddAssetsPackagePartMainInput> inputList)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
return false;
|
});
|
}
|
|
/// <summary>
|
/// 大批量插入
|
/// </summary>
|
public async Task<bool> BulkInserts(List<AddAssetsPackagePartMainInput> list)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
return false;
|
});
|
}
|
|
#endregion Insert
|
|
#region Update
|
|
/// <summary>
|
/// 更新一条
|
/// </summary>
|
public async Task<bool> Update(UpdateAssetsPackagePartMainInput input)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var model = _service.GetByID(input.ID);
|
if (model == null)
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"ID:{input.ID} 数据不存在");
|
}
|
var rhs = new Model.AssetsPackagePartMain(model);
|
input.Adapt(rhs);
|
var bol = _service.Update(rhs);
|
return bol;
|
});
|
}
|
|
//编辑拓展
|
public async Task<bool> UpdateEx(UpdateAssetsPackagePartMainInput Packagepart, List<UpdateAssetsPackagePropContentInput> updateAssetsPackagePropContentDtos)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var partmodel = Packagepart.Adapt<UpdateAssetsPackagePartMainInput, Model.AssetsPackagePartMain>();
|
var propcontentlistmodel = updateAssetsPackagePropContentDtos.Select(x => x.Adapt<UpdateAssetsPackagePropContentInput, Model.AssetsPackagePropContent>()).ToList();
|
return _service.UpdateEX(partmodel, propcontentlistmodel);
|
});
|
}
|
|
/// <summary>
|
/// 批量更新
|
/// </summary>
|
public async Task<bool> Updates(List<UpdateAssetsPackagePartMainInput> inputList)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
return false;
|
});
|
}
|
|
/// <summary>
|
/// 大批量更新
|
/// </summary>
|
public async Task<bool> BulkUpdates(List<UpdateAssetsPackagePartMainInput> list)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
return false;
|
});
|
}
|
|
/// <summary>
|
/// 更新排序码
|
/// </summary>
|
public async Task<bool> UpdateSortCode(long ID, int SortCode)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var bol = _service.UpdateSortCode(ID, SortCode);
|
return bol;
|
});
|
}
|
|
/// <summary>
|
/// 更新排序
|
/// </summary>
|
public async Task<bool> UpdateSorter(List<UpdateSortCodeInput> inputList)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var list = inputList.Select(x => x.Adapt<Yw.Model.Sorter>()).ToList();
|
var bol = _service.UpdateSorter(list);
|
return bol;
|
});
|
}
|
|
/// <summary>
|
/// 更新编码
|
/// </summary>
|
public async Task<bool> UpdateCode(long ID, string Code)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
if (!string.IsNullOrEmpty(Code))
|
{
|
if (_service.IsExistCodeExceptID(Code, ID))
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.V001, $"Code:{Code}", "编码已存在");
|
}
|
}
|
var bol = _service.UpdateCode(ID, Code);
|
return bol;
|
});
|
}
|
|
#endregion Update
|
|
#region Exist
|
|
/// <summary>
|
/// 判断Code是否存在
|
/// </summary>
|
public async Task<bool> IsExistCode(string Code)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var bol = _service.IsExistCode(Code);
|
return bol;
|
});
|
}
|
|
/// <summary>
|
/// 判断Code是否存在 ExceptID
|
/// </summary>
|
public async Task<bool> IsExistCodeExceptID(string Code, long ExceptID)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var bol = _service.IsExistCodeExceptID(Code, ExceptID);
|
return bol;
|
});
|
}
|
|
#endregion Exist
|
|
#region Delete
|
|
/// <summary>
|
/// 通过 ID 删除
|
/// </summary>
|
public async Task<bool> DeleteByID(long ID)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var bol = _service.DeleteByID(ID, out string msg);
|
if (!bol)
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D999, msg);
|
}
|
return true;
|
});
|
}
|
|
/// <summary>
|
/// 通过 Ids 删除
|
/// </summary>
|
public async Task<bool> DeleteByIds(List<long> Ids)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
return false;
|
});
|
}
|
|
/// <summary>
|
/// 全部删除
|
/// </summary>
|
public async Task<bool> DeleteAll()
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
return false;
|
});
|
}
|
|
public async Task<bool> DeleteEx(long ID)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var bol = _service.DeleteExByID(ID);
|
if (!bol)
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D999, "删除失败");
|
}
|
return true;
|
});
|
}
|
|
#endregion Delete
|
}
|
}
|