namespace Yw.CAL.LocalClient
|
{
|
/// <summary>
|
/// 报警等级
|
/// </summary>
|
public class BimfaceFileRelationLabel : IBimfaceFileRelationLabel
|
{
|
private readonly Yw.Service.BimfaceFileRelationLabel _service = new();
|
|
|
#region Query
|
|
/// <summary>
|
/// 获取所有
|
/// </summary>
|
public async Task<List<BimfaceFileRelationLabelDto>> GetAll()
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var list = _service.GetAll();
|
var vm_list = list?.Select(x => new BimfaceFileRelationLabelDto(x)).ToList();
|
return vm_list;
|
});
|
}
|
|
/// <summary>
|
/// 通过 ID 获取
|
/// </summary>
|
public async Task<BimfaceFileRelationLabelDto> GetByID(long ID)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var model = _service.GetByID(ID);
|
return model == null ? null : new BimfaceFileRelationLabelDto(model);
|
});
|
}
|
|
/// <summary>
|
/// 通过 Ids 获取
|
/// </summary>
|
public async Task<List<BimfaceFileRelationLabelDto>> GetByIds(List<long> Ids)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var list = _service.GetByIds(Ids);
|
var vm_list = list?.Select(x => new BimfaceFileRelationLabelDto(x)).ToList();
|
return vm_list;
|
});
|
}
|
|
/// <summary>
|
/// 通过 RelationID 获取
|
/// </summary>
|
public async Task<List<BimfaceFileRelationLabelDto>> GetByRelationID(long RelationID)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var list = _service.GetByRelationID(RelationID);
|
var vm_list = list?.Select(x => new BimfaceFileRelationLabelDto(x)).ToList();
|
return vm_list;
|
});
|
}
|
|
|
#endregion
|
|
#region Insert
|
|
/// <summary>
|
/// 插入一条
|
/// </summary>
|
public async Task<long> Insert(AddBimfaceFileRelationLabelInput input)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var relation = new Service.BimfaceFileRelation().GetByID(input.RelationID);
|
if (relation == null)
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"RelationID:{input.RelationID} 数据不存在");
|
}
|
var model = input.Adapt<AddBimfaceFileRelationLabelInput, Model.BimfaceFileRelationLabel>();
|
var id = _service.Insert(model);
|
return id;
|
});
|
}
|
|
/// <summary>
|
/// 批量插入
|
/// </summary>
|
public async Task<bool> Inserts(List<AddBimfaceFileRelationLabelInput> inputList)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
return false;
|
});
|
}
|
|
/// <summary>
|
/// 大批量插入
|
/// </summary>
|
public async Task<bool> BulkInserts(List<AddBimfaceFileRelationLabelInput> list)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
return false;
|
});
|
}
|
|
#endregion
|
|
#region Update
|
|
/// <summary>
|
/// 更新一条
|
/// </summary>
|
public async Task<bool> Update(UpdateBimfaceFileRelationLabelInput 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.BimfaceFileRelationLabel(model);
|
input.Adapt(rhs);
|
var bol = _service.Update(rhs);
|
return bol;
|
});
|
}
|
|
/// <summary>
|
/// 批量更新
|
/// </summary>
|
public async Task<bool> Updates(List<UpdateBimfaceFileRelationLabelInput> inputList)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
if (inputList == null || inputList.Count < 1)
|
{
|
return false;
|
}
|
var list = inputList.Select(x => x.Adapt<UpdateBimfaceFileRelationLabelInput, Model.BimfaceFileRelationLabel>()).ToList();
|
var bol = _service.Updates(list);
|
return bol;
|
});
|
}
|
|
/// <summary>
|
/// 大批量更新
|
/// </summary>
|
public async Task<bool> BulkUpdates(List<UpdateBimfaceFileRelationLabelInput> list)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
return false;
|
});
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public async Task<bool> UpdateContent(long ID, string Content)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var bol = _service.UpdateContent(ID, Content);
|
return bol;
|
});
|
}
|
|
public async Task<bool> Save(SaveBimfaceFileRelationLabelInput input)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var relation = new Service.BimfaceFileRelation().GetByID(input.RelationID);
|
if (relation == null)
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"RelationID:{input.RelationID} 数据不存在");
|
}
|
var list = input.Labels?.Select(x => x.Adapt<SaveBimfaceFileRelationLabelItemInput, Model.BimfaceFileRelationLabel>()).ToList();
|
list?.ForEach(x => x.RelationID = input.RelationID);
|
var bol = _service.Save(input.RelationID, list, out string Msg);
|
if (!bol)
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.V001, Msg);
|
}
|
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;
|
});
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
}
|
}
|