Reorganize root folder structure: Remove apps layer layer
This commit is contained in:
60
backend/src/Modules/Identity/Domain/User.cs
Normal file
60
backend/src/Modules/Identity/Domain/User.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using Knot.Shared.Kernel;
|
||||
|
||||
namespace Knot.Modules.Identity.Domain;
|
||||
|
||||
/// <summary>
|
||||
/// Сущность пользователя в контексте идентификации (Identity).
|
||||
/// </summary>
|
||||
public sealed class User : AggregateRoot<Guid>
|
||||
{
|
||||
public string Username { get; private set; }
|
||||
public string PasswordHash { get; private set; }
|
||||
public string DisplayName { get; private set; }
|
||||
public string? Email { get; private set; }
|
||||
public string? Bio { get; private set; }
|
||||
public string? Avatar { get; private set; }
|
||||
public DateTime? Birthday { get; private set; }
|
||||
public DateTime CreatedAt { get; private set; }
|
||||
public bool HideStoryViews { get; private set; }
|
||||
|
||||
private User(Guid id, string username, string passwordHash, string displayName, string? email, string? bio = null)
|
||||
: base(id)
|
||||
{
|
||||
Username = username;
|
||||
PasswordHash = passwordHash;
|
||||
DisplayName = displayName;
|
||||
Email = email;
|
||||
Bio = bio;
|
||||
CreatedAt = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Фабричный метод для создания нового пользователя.
|
||||
/// </summary>
|
||||
public static User Create(string username, string passwordHash, string displayName, string? email = null, string? bio = null)
|
||||
{
|
||||
return new User(Guid.NewGuid(), username, passwordHash, displayName, email, bio);
|
||||
}
|
||||
|
||||
public void UpdateProfile(string displayName, string? bio, DateTime? birthday)
|
||||
{
|
||||
DisplayName = displayName;
|
||||
Bio = bio;
|
||||
Birthday = birthday;
|
||||
}
|
||||
|
||||
public void UpdateAvatar(string? avatarUrl)
|
||||
{
|
||||
Avatar = avatarUrl;
|
||||
}
|
||||
|
||||
public void UpdateSettings(bool hideStoryViews)
|
||||
{
|
||||
HideStoryViews = hideStoryViews;
|
||||
}
|
||||
|
||||
public void ChangePassword(string newPasswordHash)
|
||||
{
|
||||
PasswordHash = newPasswordHash;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user