Documentation
¶
Index ¶
- type DomainService
- type Email
- type Name
- type Repository
- type User
- func (u *User) CreatedAt() time.Time
- func (u *User) Email() Email
- func (u *User) Equals(other *User) bool
- func (u *User) ID() UserID
- func (u *User) Name() Name
- func (u *User) UpdateEmail(email string) error
- func (u *User) UpdateName(name string) error
- func (u *User) UpdatedAt() time.Time
- func (u *User) Validate() error
- type UserID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DomainService ¶
type DomainService interface {
// ValidateUniqueEmail ensures email uniqueness across the domain
ValidateUniqueEmail(ctx context.Context, email Email, excludeUserID *UserID) error
// CanDeleteUser checks if a user can be safely deleted
CanDeleteUser(ctx context.Context, userID UserID) error
}
DomainService defines domain-specific business logic that doesn't belong to a single entity
func NewDomainService ¶
func NewDomainService(userRepo Repository) DomainService
NewDomainService creates a new domain service instance
type Email ¶
type Email struct {
// contains filtered or unexported fields
}
Email represents a validated email address
type Name ¶
type Name struct {
// contains filtered or unexported fields
}
Name represents a validated user name
type Repository ¶
type Repository interface {
// FindByID retrieves a user by their ID
FindByID(ctx context.Context, id UserID) (*User, error)
// FindByEmail retrieves a user by their email address
FindByEmail(ctx context.Context, email Email) (*User, error)
// FindAll retrieves users with pagination support
// limit: maximum number of users to return
// cursor: pagination cursor (empty string for first page)
// Returns users and next cursor (empty if no more pages)
FindAll(ctx context.Context, limit int, cursor string) ([]*User, string, error)
// Create persists a new user
Create(ctx context.Context, user *User) error
// Update modifies an existing user
Update(ctx context.Context, user *User) error
// Delete removes a user by their ID
Delete(ctx context.Context, id UserID) error
// ExistsByEmail checks if a user with the given email exists
ExistsByEmail(ctx context.Context, email Email) (bool, error)
// Count returns the total number of users
Count(ctx context.Context) (int64, error)
}
Repository defines the interface for user persistence operations
type User ¶
type User struct {
// contains filtered or unexported fields
}
User represents the user domain entity
func NewUserWithID ¶
NewUserWithID creates a User entity with a specific ID (for reconstruction from persistence)
func (*User) UpdateEmail ¶
UpdateEmail updates the user's email with validation
func (*User) UpdateName ¶
UpdateName updates the user's name with validation
Click to show internal directories.
Click to hide internal directories.