This commit is contained in:
2026-04-18 22:36:21 +04:30
parent 49591985ac
commit c64c3dd9be
20 changed files with 157 additions and 24 deletions
@@ -2,6 +2,7 @@
using Vizhvizh.Shop.Domain.Members.TypeIds;
using Vizhvizh.Shop.Domain.Members.ValuesObjects;
using Vizhvizh.BuildingBlocks.Domain;
using Vizhvizh.Shop.Domain.Members.Events;
namespace Vizhvizh.Shop.Domain.Members.Entities;
@@ -10,10 +11,11 @@ public class Member : Entity<MemberId>, IAggregateRoot
private PhoneNumberVO _phoneNumber;
private MemberFullName _fullName;
private MemberAvatar? _avatar;
private MemberNationalCode? _nationalCode;
private Member()
{
}
private Member(PhoneNumberVO phoneNumber, MemberFullName fullName, MemberAvatar? avatar)
{
@@ -28,4 +30,12 @@ public class Member : Entity<MemberId>, IAggregateRoot
public MemberFullName? FullName => _fullName;
public PhoneNumberVO PhoneNumber => _phoneNumber;
public MemberAvatar? Avatar => _avatar;
public MemberNationalCode? NationalCode => _nationalCode;
public void SetNationalCode(MemberNationalCode nationalCode)
{
_nationalCode = nationalCode;
this.AddDomainEvent(new SetNationalCodeEvent(this));
}
}
@@ -0,0 +1,9 @@
using Vizhvizh.BuildingBlocks.Domain;
using Vizhvizh.Shop.Domain.Members.Entities;
namespace Vizhvizh.Shop.Domain.Members.Events;
public class SetNationalCodeEvent(Member member) : DomainEventBase
{
public Member Member => member;
}
@@ -0,0 +1,17 @@
using Vizhvizh.BuildingBlocks.Domain;
using Vizhvizh.Shared.Domain.Exceptions;
namespace Vizhvizh.Shop.Domain.Members.ValuesObjects;
public class MemberNationalCode : ValueObject
{
public const short Limit = 10;
public MemberNationalCode(string value)
{
if (value.Length > Limit)
throw new CharacterLimitException(nameof(MemberNationalCode), Limit);
Value = value;
}
public string Value { get; private set; }
}
@@ -27,7 +27,7 @@ public class Specifications : Entity<SpecificationsId>
_product = product;
}
public static Specifications CreateNew(TitleVO title, Product product, List<string> values)
internal static Specifications CreateNew(TitleVO title, Product product, List<string> values)
=> new Specifications(title, product, values);
public TitleVO Title => _title;
+10 -1
View File
@@ -22,6 +22,8 @@ public class Shop : Entity<ShopId>, IAggregateRoot
private TelephoneVO _telephoneVO;
private ShopLogo _logo;
private MemberId _ownerId;
private ShopStatus _shopStatus;
private ShopBusinessLicense _businessLicense;
private Shop()
{
@@ -32,6 +34,7 @@ public class Shop : Entity<ShopId>, IAggregateRoot
TitleVO title,
ShopLocation location,
TelephoneVO telephone,
ShopBusinessLicense businessLicense,
DescriptionVO? description = null,
EmailVO? email = null
)
@@ -40,18 +43,22 @@ public class Shop : Entity<ShopId>, IAggregateRoot
_title = title;
_location = location;
_description = description;
_businessLicense = businessLicense;
_email = email;
_telephoneVO = telephone;
_shopStatus = ShopStatus.CreateNew(ShopStatusEnum.PendingApproval);
}
public static Shop CreateNew(MemberId ownerId,
TitleVO title,
ShopLocation location,
TelephoneVO telephone,
ShopBusinessLicense businessLicense,
DescriptionVO? description = null,
EmailVO? email = null)
{
return new Shop(ownerId, title, location, telephone, description, email);
return new Shop(ownerId, title, location, telephone, businessLicense, description, email);
}
public MemberId OwnerId => _ownerId;
public Management Management => _management;
@@ -61,6 +68,8 @@ public class Shop : Entity<ShopId>, IAggregateRoot
public EmailVO? Email => _email;
public TelephoneVO Telephone => _telephoneVO;
public ShopLogo Logo => _logo;
public ShopStatus Status => _shopStatus;
public ShopBusinessLicense BusinessLicense => _businessLicense;
public IReadOnlyList<Product> Products => _products;
public IReadOnlyList<ShippingMethod> ShippingMethods => _shippingMethods;
public IReadOnlyList<Member> Members => _members;
@@ -0,0 +1,31 @@
using Vizhvizh.BuildingBlocks.Domain;
using Vizhvizh.Shared.Domain.Exceptions;
namespace Vizhvizh.Shop.Domain.Shops.ValuesObjects;
/// <summary>
/// پروانه کسب
/// </summary>
public class ShopBusinessLicense : ValueObject
{
public const short ImageLimit = 150;
public const short CodeLimit = 50;
private ShopBusinessLicense(string image, string code)
{
if (image.Length > ImageLimit)
throw new CharacterLimitException("ShopBusinessLicenseImage", ImageLimit);
if (code.Length > CodeLimit)
throw new CharacterLimitException("ShopBusinessLicenseCode", CodeLimit);
Image = image;
Code = code;
}
public string Image { get; private set; }
public string Code { get; private set; }
public static ShopBusinessLicense CreateNew(string image, string code)
=> new ShopBusinessLicense(image, code);
}
@@ -0,0 +1,22 @@
using Vizhvizh.BuildingBlocks.Domain;
namespace Vizhvizh.Shop.Domain.Shops.ValuesObjects;
public class ShopStatus : ValueObject
{
public ShopStatus(ShopStatusEnum value)
{
Value = value;
}
public ShopStatusEnum Value { get; private set; }
public static ShopStatus CreateNew(ShopStatusEnum value)
=> new(value);
}
public enum ShopStatusEnum
{
Creating = 1,
PendingApproval,
Available,
}
@@ -12,7 +12,6 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Members\Events\" />
<Folder Include="Members\Rules\" />
<Folder Include="Members\Repositories\" />
<Folder Include="Products\Events\" />