using Yw.Dto;
|
|
namespace Yw.CAL.LocalClient
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public class BimfaceFileRelation : IBimfaceFileRelation
|
{
|
private readonly Yw.Service.BimfaceFileRelation _service = new();
|
|
#region Query
|
|
/// <summary>
|
/// 获取所有
|
/// </summary>
|
public async Task<List<BimfaceFileRelationDto>> GetAll()
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var list = _service.GetAll();
|
var vm_list = list?.Select(x => new BimfaceFileRelationDto(x)).ToList();
|
return vm_list;
|
});
|
}
|
|
/// <summary>
|
/// 通过 ID 获取
|
/// </summary>
|
public async Task<BimfaceFileRelationDto> GetByID(long ID)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var model = _service.GetByID(ID);
|
return model == null ? null : new BimfaceFileRelationDto(model);
|
});
|
}
|
|
/// <summary>
|
/// 通过 Ids 获取
|
/// </summary>
|
public async Task<List<BimfaceFileRelationDto>> GetByIds(List<long> Ids)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var list = _service.GetByIds(Ids);
|
var vm_list = list?.Select(x => new BimfaceFileRelationDto(x)).ToList();
|
return vm_list;
|
});
|
}
|
|
|
/// <summary>
|
/// 通过 ObjectType 和 ObjectID 获取
|
/// </summary>
|
public async Task<List<BimfaceFileRelationDto>> GetByObjectTypeAndObjectID(string ObjectType, long ObjectID)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var list = _service.GetByObjectTypeAndObjectID(ObjectType, ObjectID);
|
var vm_list = list?.Select(x => new BimfaceFileRelationDto(x)).ToList();
|
return vm_list;
|
});
|
}
|
|
/// <summary>
|
/// 通过 ObjectType 和 ObjectID 获取 Purpose 下
|
/// </summary>
|
public async Task<List<BimfaceFileRelationDto>> GetByObjectTypeAndObjectIDOfPurpose(string ObjectType, long ObjectID, string Purpose)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var list = _service.GetByObjectTypeAndObjectIDOfPurpose(ObjectType, ObjectID, Purpose);
|
var vm_list = list?.Select(x => new BimfaceFileRelationDto(x)).ToList();
|
return vm_list;
|
});
|
}
|
|
/// <summary>
|
/// 通过 ObjectType 和 ObjectID 获取 Purpose 下
|
/// </summary>
|
public async Task<BimfaceFileRelationDto> GetDefaultByObjectTypeAndObjectIDOfPurpose(string ObjectType, long ObjectID, string Purpose)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var model = _service.GetDefaultByObjectTypeAndObjectIDOfPurpose(ObjectType, ObjectID, Purpose);
|
return model == null ? null : new BimfaceFileRelationDto(model);
|
});
|
}
|
|
|
#endregion
|
|
#region Insert
|
|
/// <summary>
|
/// 插入一条
|
/// </summary>
|
public async Task<long> Insert(AddBimfaceFileRelationInput input)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var bimfaceFile = new Yw.Service.BimfaceFile().GetByID(input.BimfaceFileID);
|
if (bimfaceFile == null)
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"BimfaceFileID:{input.BimfaceFileID} 数据不存在");
|
}
|
var model = input.Adapt<AddBimfaceFileRelationInput, Model.BimfaceFileRelation>();
|
model.SortCode = _service.GetMaxSortCode() + 1;
|
var id = _service.Insert(model);
|
return id;
|
});
|
}
|
|
/// <summary>
|
/// 批量插入
|
/// </summary>
|
public async Task<bool> Inserts(List<AddBimfaceFileRelationInput> inputList)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
return false;
|
});
|
}
|
|
/// <summary>
|
/// 大批量插入
|
/// </summary>
|
public async Task<bool> BulkInserts(List<AddBimfaceFileRelationInput> list)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
return false;
|
});
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public async Task<long> InsertObject(AddBimfaceFileRelationInput input)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var bimfaceFile = new Yw.Service.BimfaceFile().GetByID(input.BimfaceFileID);
|
if (bimfaceFile == null)
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"BimfaceFileID:{input.BimfaceFileID} 数据不存在");
|
}
|
var model = input.Adapt<AddBimfaceFileRelationInput, Model.BimfaceFileRelation>();
|
model.SortCode = _service.GetMaxSortCode(input.ObjectType, input.ObjectID) + 1;
|
var id = _service.Insert(model);
|
return id;
|
});
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public async Task<long> InsertPage(AddBimfaceFileRelationInput input)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var bimfaceFile = new Yw.Service.BimfaceFile().GetByID(input.BimfaceFileID);
|
if (bimfaceFile == null)
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"BimfaceFileID:{input.BimfaceFileID} 数据不存在");
|
}
|
var model = input.Adapt<AddBimfaceFileRelationInput, Model.BimfaceFileRelation>();
|
model.SortCode = _service.GetMaxSortCode(input.BimfaceFileID) + 1;
|
var id = _service.Insert(model);
|
return id;
|
});
|
}
|
|
#endregion
|
|
#region Update
|
|
/// <summary>
|
/// 更新一条
|
/// </summary>
|
public async Task<bool> Update(UpdateBimfaceFileRelationInput 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.BimfaceFileRelation(model);
|
input.Adapt(rhs);
|
var bol = _service.Update(rhs);
|
return bol;
|
});
|
}
|
|
/// <summary>
|
/// 批量更新
|
/// </summary>
|
public async Task<bool> Updates(List<UpdateBimfaceFileRelationInput> inputList)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
return false;
|
});
|
}
|
|
/// <summary>
|
/// 大批量更新
|
/// </summary>
|
public async Task<bool> BulkUpdates(List<UpdateBimfaceFileRelationInput> 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<Model.Sorter>()).ToList();
|
var bol = _service.UpdateSorter(list);
|
return bol;
|
});
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public async Task<bool> UpdatePurpose(long ID, string Purpose)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var bol = _service.UpdatePurpose(ID, Purpose);
|
return bol;
|
});
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public async Task<bool> UpdateContent(long ID, string Content)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var bol = _service.UpdateContent(ID, Content);
|
return bol;
|
});
|
}
|
|
#endregion
|
|
#region Exist
|
|
/// <summary>
|
///
|
/// </summary>
|
public async Task<bool> IsExistByBimfaceFileID(long BimfaceFileID)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var bol = _service.IsExistByBimfaceFileID(BimfaceFileID);
|
return bol;
|
});
|
}
|
|
#endregion
|
|
#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>
|
/// <returns></returns>
|
public async Task<bool> DeleteAll()
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
return false;
|
});
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public async Task<bool> DeleteExByID(long ID)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var bol = _service.DeleteExByID(ID, out string msg);
|
if (!bol)
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D999, msg);
|
}
|
return true;
|
});
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public async Task<bool> DeleteAllByID(long ID)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var bol = _service.DeleteAllByID(ID, out string msg);
|
if (!bol)
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D999, msg);
|
}
|
return true;
|
});
|
}
|
|
|
#endregion
|
}
|
|
}
|