초기커밋
This commit is contained in:
42
BrokerApiCore/Entity/Helpers/EntityHelper.cs
Normal file
42
BrokerApiCore/Entity/Helpers/EntityHelper.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
namespace BrokerCore.Entity;
|
||||
|
||||
|
||||
public static class EntityHelper
|
||||
{
|
||||
public static async Task<(Result, TDoc?)> findDocByPk<TDoc>(string pk, EntityBase owner, DynamoDbClient dynamoDbClient)
|
||||
where TDoc : DynamoDbDocBase, new()
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(owner, $"owner is null !!!");
|
||||
|
||||
var (result, user_primary_key) = await DynamoDBDocBaseHelper.makePrimaryKey<TDoc>(pk);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
ArgumentNullException.ThrowIfNull(user_primary_key, $"user_primary_key is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var query_config = dynamoDbClient.makeQueryConfigForReadByPKSK(user_primary_key.PK);
|
||||
(result, var found_doc) =
|
||||
await dynamoDbClient.simpleQueryDocTypeWithQueryOperationConfig<TDoc>(query_config, false);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, found_doc);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user