domain

package
v0.0.0-...-fe66388 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserNotFound      = errors.New("user not found")
	ErrUserAlreadyExists = errors.New("user already exists")
)

Functions

This section is empty.

Types

type Address

type Address struct {
	Street string
	State  string
	City   string
}

type Date

type Date struct {
	Year  int
	Month time.Month
	Day   int
}

func NewDate

func NewDate(year int, month time.Month, day int) Date

type Mailer

type Mailer interface {
	SendPasswordResetEmail(to string) error
}

type TokenGenerator

type TokenGenerator interface {
	GenerateToken(userID int, expirationTime time.Time) (string, error)
}

type User

type User struct {
	ID                  int    `json:"id"`
	Name                string `json:"name"`
	BirthDate           Date
	Password            string
	Email               string
	DocumentNo          string
	Address             Address
	IsActive            bool `json:"is_active"`
	IsStaff             bool `json:"is_staff"`
	CreatedAt           time.Time
	UpdatedAt           time.Time
	DeletedAt           *time.Time
	ResetToken          string
	ResetTokenExpiresAt time.Time
}

func NewUser

func NewUser(userID int, name string, password string, email string, documentNo string, address Address, birthDate Date) (*User, error)

func (*User) ComparePassword

func (u *User) ComparePassword(password string) error

func (*User) EncryptPassword

func (u *User) EncryptPassword() error

func (*User) IsDeleted

func (u *User) IsDeleted() bool

type UserOutput

type UserOutput struct {
	ID       int    `json:"id"`
	Name     string `json:"name"`
	IsActive bool   `json:"is_active"`
	IsStaff  bool   `json:"is_staff"`
}

func NewUserOutput

func NewUserOutput(userID int, name string, IsActive bool, IsStaff bool) (*UserOutput, error)

type UserRepository

type UserRepository interface {
	Save(user *User) error
	FindByDocumentNo(documentNo string) (*User, error)
	FindByEmail(email string) (*User, error)
	FindByID(id int) (*User, error)
	Update(user *User) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL