초기커밋
This commit is contained in:
28
BrokerApiCore/Entity/Helpers/EntityExtensions.cs
Normal file
28
BrokerApiCore/Entity/Helpers/EntityExtensions.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
namespace BrokerCore.Entity;
|
||||
|
||||
using ServerCommon;
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
public static class EntityExtensions
|
||||
{
|
||||
public static TEntityAttributeBase getEntityAttributeNotNull<TEntityAttributeBase>(this EntityBase entity)
|
||||
where TEntityAttributeBase : EntityAttributeBase
|
||||
{
|
||||
TEntityAttributeBase? attribute = entity.getEntityAttribute<TEntityAttributeBase>();
|
||||
// todo: 이렇게 널 처리를 하면 일관되게 처리할 수 있지만, null이 발생한 코드 위치가 항상 여기로 찍힌다.
|
||||
// getEntityAttributeNotNull를 호출한 위치에서 로그를 찍을 수 있는 지 고민해보자.
|
||||
NullReferenceCheckHelper.throwIfNull(attribute,
|
||||
() => $"entity attribute {nameof(TEntityAttributeBase)} not found - {entity.toBasicString()}");
|
||||
return attribute;
|
||||
}
|
||||
|
||||
public static TEntityActionBase getEntityActionNotNull<TEntityActionBase>(this EntityBase entity)
|
||||
where TEntityActionBase : EntityActionBase
|
||||
{
|
||||
TEntityActionBase? action = entity.getEntityAction<TEntityActionBase>();
|
||||
NullReferenceCheckHelper.throwIfNull(action,
|
||||
() => $"entity action {nameof(TEntityActionBase)} not found - {entity.toBasicString()}");
|
||||
return action;
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
65
BrokerApiCore/Entity/Helpers/MailSendOption.cs
Normal file
65
BrokerApiCore/Entity/Helpers/MailSendOption.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
namespace BrokerCore.Entity.Actions;
|
||||
|
||||
using ServerCommon;
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
public record class MailSendOption
|
||||
{
|
||||
//==================
|
||||
// 기본 속성들
|
||||
//==================
|
||||
public string ReceiverUserGuid { get; set; } = string.Empty;
|
||||
public string ReceiverNickName { get; set; } = string.Empty;
|
||||
public string SenderNickName { get; set; } = string.Empty;
|
||||
public string SenderGuid { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public string Text { get; set; } = string.Empty;
|
||||
public List<string> ContentsArguments { get; set; } = new List<string>();
|
||||
public bool IsTextByMetaData { get; set; } = true;
|
||||
public List<ServerCommon.MailItem> ItemList { get; set; } = new List<ServerCommon.MailItem>();
|
||||
public DateTime ExpireDate { get; set; } = DateTimeHelper.MaxTime;
|
||||
public string PackageOrderId { get; set; } = string.Empty;
|
||||
|
||||
//==================
|
||||
// 추가 옵션들
|
||||
//==================
|
||||
public bool IsSystemMail { get; set; } = true;
|
||||
public string PlanetId { get; set; } = string.Empty;
|
||||
public string AccountId { get; set; } = string.Empty;
|
||||
|
||||
//==================
|
||||
// 기본 생성자
|
||||
//==================
|
||||
public MailSendOption() { }
|
||||
|
||||
//==================
|
||||
// 필수 항목을 포함한 생성자
|
||||
//==================
|
||||
public MailSendOption(string receiverUserGuid, string receiverNickName, string title, string text)
|
||||
{
|
||||
ReceiverUserGuid = receiverUserGuid;
|
||||
ReceiverNickName = receiverNickName;
|
||||
Title = title;
|
||||
Text = text;
|
||||
}
|
||||
|
||||
//==================
|
||||
// 아이템 목록 추가 메서드
|
||||
//==================
|
||||
public void addItems(List<MailItem>? mailItems)
|
||||
{
|
||||
if (mailItems != null)
|
||||
{
|
||||
ItemList.AddRange(mailItems);
|
||||
}
|
||||
}
|
||||
|
||||
//==================
|
||||
// 기본값 검증 메서드
|
||||
//==================
|
||||
public bool validate()
|
||||
{
|
||||
return !string.IsNullOrEmpty(ReceiverUserGuid) && !string.IsNullOrEmpty(Title);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user