This commit is contained in:
DEVICE8\12494
2023-05-19 09:13:35 +08:00
parent 1c31a4e496
commit 649105eb6e
4 changed files with 90 additions and 8 deletions

View File

@@ -46,9 +46,8 @@ namespace Tnb.EquipMgr
{
var pk = id;
TDest entity = new();
entity.id = SnowflakeIdHelper.NextId();
entity.PropertySetValue(mColumnName, input.item_group_id);
entity.PropertySetValue(name,pk);
entity.PropertySetValue(name, pk);
entities.Add(entity);
}
}
@@ -56,19 +55,27 @@ namespace Tnb.EquipMgr
if (row < 1) throw Oops.Oh(ErrorCode.COM1000);
}
protected async Task Delete<T>(Expression<Func<T, bool>> delFilter) where T : BaseEntity<string>, new()
{
var row = await _db.Deleteable<T>().Where(delFilter).ExecuteCommandAsync();
if (row < 1) throw Oops.Oh(ErrorCode.COM1002);
}
protected async Task<dynamic> GetListByMasterId<TRelaction, TDest, TOutput>(string masterId,
protected async Task<dynamic> GetListById<TRelaction, TDest, TOutput>(string masterId,
Expression<Func<TRelaction, bool>> masterFilterExp,
Expression<Func<TRelaction, string>> masterSelector,
Expression<Func<TDest, bool>> relactionFilterExp)
Expression<Func<TDest, object>> srcMap,
Expression<Func<TOutput, object>> destMap
) where TDest : BaseEntity<string>, new()
{
var config = new TypeAdapterConfig();
config.ForType<TDest, TOutput>();
config.ForType<TDest, TOutput>().Map(destMap, srcMap);
var list = new List<TOutput>();
var itemIds = await _db.Queryable<TRelaction>().Where(masterFilterExp).Select(masterSelector).ToListAsync();
if (itemIds?.Count > 0)
{
var items = await _db.Queryable<TDest>().Where(relactionFilterExp).ToListAsync();
var items = await _db.Queryable<TDest>().Where(it=>itemIds.Contains(it.id)).ToListAsync();
list = items.Adapt<List<TOutput>>();
}
return list;