Перепиливание под чистый DDD

This commit is contained in:
Халимов Рустам
2026-03-22 23:59:33 +03:00
parent 5da1a2f45d
commit 6e532b021d
302 changed files with 3595 additions and 3679 deletions

View File

@@ -0,0 +1,52 @@
using Knot.Shared.Kernel;
using System;
namespace Knot.Modules.Profiles.Domain;
public sealed class Profile : AggregateRoot<Guid>
{
public string Username { get; private set; }
public string DisplayName { get; private set; }
public string? Bio { get; private set; }
public string? Avatar { get; private set; }
public DateTime? Birthday { get; private set; }
public bool HideStoryViews { get; private set; }
public string Profilename => Username;
public string Name => DisplayName;
public string AvatarUrl => Avatar;
public bool IsPrivate => false;
public DateTime CreatedAt { get; private set; } = DateTime.UtcNow;
public int FollowersCount => 0;
public int FollowingCount => 0;
public int FriendsCount => 0;
private Profile(Guid id, string username, string displayName, string? bio = null)
: base(id)
{
Username = username;
DisplayName = displayName;
Bio = bio;
}
public static Profile Create(Guid userId, string username, string displayName, string? bio = null)
{
return new Profile(userId, username, displayName, 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;
}
}

View File

@@ -0,0 +1,10 @@
namespace Knot.Modules.Profiles.Domain;
using Knot.Shared.Kernel;
public static class ProfilesErrors
{
public static readonly Error ProfileNotFound = new("Profile.NotFound", "Profile not found");
}
public static class IdentityErrors
{
public static readonly Error UserNotFound = new("Profile.NotFound", "Profile not found");
}