user create command and user repo
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using AipsCore.Domain.Abstract.Rule;
|
||||
using AipsCore.Domain.Abstract.ValueObject;
|
||||
using AipsCore.Domain.Common.Validation;
|
||||
using AipsCore.Domain.Common.Validation.Rules;
|
||||
|
||||
namespace AipsCore.Domain.Common.ValueObjects;
|
||||
|
||||
@@ -17,6 +18,8 @@ public record DomainId : AbstractValueObject
|
||||
|
||||
protected override ICollection<IRule> GetValidationRules()
|
||||
{
|
||||
return [];
|
||||
return [
|
||||
new MinLengthRule(IdValue, 5)
|
||||
];
|
||||
}
|
||||
}
|
||||
9
dotnet/AipsCore/Domain/Models/User/External/IUserRepository.cs
vendored
Normal file
9
dotnet/AipsCore/Domain/Models/User/External/IUserRepository.cs
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
using AipsCore.Domain.Models.User.ValueObjects;
|
||||
|
||||
namespace AipsCore.Domain.Models.User.External;
|
||||
|
||||
public interface IUserRepository
|
||||
{
|
||||
Task<User?> Get(UserId userId, CancellationToken cancellationToken = default);
|
||||
Task Save(User user, CancellationToken cancellationToken = default);
|
||||
}
|
||||
@@ -15,4 +15,19 @@ public class User
|
||||
Email = email;
|
||||
Username = username;
|
||||
}
|
||||
|
||||
public static User Create(string id, string email, string username)
|
||||
{
|
||||
var userIdVo = new UserId(id);
|
||||
var usernameVo = new Username(username);
|
||||
var emailVo = new Email(email);
|
||||
return new User( userIdVo, emailVo, usernameVo);
|
||||
}
|
||||
|
||||
public static User Create(string email, string username)
|
||||
{
|
||||
var usernameVo = new Username(username);
|
||||
var emailVo = new Email(email);
|
||||
return new User( UserId.Any(), emailVo, usernameVo);
|
||||
}
|
||||
}
|
||||
@@ -2,4 +2,7 @@
|
||||
|
||||
namespace AipsCore.Domain.Models.User.ValueObjects;
|
||||
|
||||
public record UserId(string IdValue) : DomainId(IdValue);
|
||||
public record UserId(string IdValue) : DomainId(IdValue)
|
||||
{
|
||||
public static UserId Any() => new(Guid.NewGuid().ToString());
|
||||
}
|
||||
Reference in New Issue
Block a user