Files
caliverse_server/BrokerApiCore/Entity/PlanetUserEntity.cs
2025-05-01 07:23:28 +09:00

71 lines
1.9 KiB
C#

using ServerBase;
using ServerCommon;
using ServerCore;
namespace BrokerApiCore;
public sealed class PlanetUserEntity : EntityBase, IWithLogActor
{
private readonly DynamoDbClient m_dynamo_db_client;
private readonly IServerLogic m_server_logic;
private string m_planet_id = string.Empty;
// private BrokerMail m_broker_mail = null!;
public string AccountId
=> this.getEntityAttributeNotNull<AccountAttribute>().AccountId;
public string UserGuid
=> this.getEntityAttributeNotNull<UserAttribute>().UserGuid;
public string Nickname
=> this.getEntityAttributeNotNull<NicknameAttribute>().Nickname;
public PlanetUserEntity(IServerLogic serverLogic) : base(EntityType.PlanetUser)
{
m_server_logic = serverLogic;
m_dynamo_db_client = serverLogic.getDynamoDbClient();
}
public override OwnerEntityType onGetOwnerEntityType()
{
return OwnerEntityType.User;
}
public override async Task<Result> onInit()
{
try
{
addEntityAttribute(new UserAttribute(this));
addEntityAttribute(new NicknameAttribute(this));
addEntityAction(new UserAuthAction(this, m_dynamo_db_client));
addEntityAttribute(new AccountAttribute(this));
}
catch (Exception ex)
{
Log.getLogger().Error(ex, $"{nameof(PlanetUserEntity)}.onInit() Exception => {ex.Message}");
}
return await base.onInit();
}
public void setPlanetId(string planetId)
{
m_planet_id = planetId;
}
// IWithLogActor 구현
public ILogActor toLogActor()
{
var account = this.getEntityAttributeNotNull<AccountAttribute>();
var nickname = this.getEntityAttributeNotNull<NicknameAttribute>();
var log_actor = new PlanetUserLogActor
{
ServerType = m_server_logic.getServerType().toServerType(),
PlanetId = m_planet_id,
AccountType = account.AccountType,
AccountId = account.AccountId,
AccountIdString = account.AccountIdString,
UserNickname = nickname.Nickname,
UserGuid = account.UserGuid,
};
return log_actor;
}
}