Documentation
¶
Overview ¶
Package entities provides domain entities that represent the core business objects in the application, including users, forms, and other domain models.
Index ¶
- Constants
- Variables
- type User
- func (u *User) Activate()
- func (u *User) AfterFind(_ *gorm.DB) error
- func (u *User) BeforeCreate(_ *gorm.DB) error
- func (u *User) BeforeUpdate(_ *gorm.DB) error
- func (u *User) CheckPassword(password string) bool
- func (u *User) Deactivate()
- func (u *User) GetFullName() string
- func (u *User) GetID() string
- func (u *User) SetID(id string)
- func (u *User) SetPassword(password string) error
- func (u *User) TableName() string
- func (u *User) UpdateProfile(firstName, lastName string)
- func (u *User) Validate() error
- func (u *User) ValidatePassword(password string) error
Constants ¶
View Source
const (
// MinPasswordLength is the minimum length required for passwords
MinPasswordLength = 8
)
Variables ¶
View Source
var ( // ErrInvalidEmail represents an invalid email format error ErrInvalidEmail = errors.New("invalid email format") // ErrInvalidPassword represents an invalid password error ErrInvalidPassword = errors.New("password must be at least 8 characters") )
Functions ¶
This section is empty.
Types ¶
type User ¶
type User struct {
ID string `json:"id" gorm:"column:uuid;primaryKey;type:uuid;default:gen_random_uuid()"`
Email string `json:"email" gorm:"uniqueIndex;not null;size:255"`
HashedPassword string `json:"-" gorm:"column:hashed_password;not null;size:255"`
FirstName string `json:"first_name" gorm:"not null;size:100"`
LastName string `json:"last_name" gorm:"not null;size:100"`
Role string `json:"role" gorm:"not null;size:50;default:user"`
Active bool `json:"active" gorm:"not null;default:true"`
CreatedAt time.Time `json:"created_at" gorm:"not null;autoCreateTime"`
UpdatedAt time.Time `json:"updated_at" gorm:"not null;autoUpdateTime"`
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
}
User represents a user entity
func (*User) BeforeCreate ¶ added in v0.1.5
BeforeCreate is a GORM hook that runs before creating a user
func (*User) BeforeUpdate ¶ added in v0.1.5
BeforeUpdate is a GORM hook that runs before updating a user
func (*User) CheckPassword ¶ added in v0.1.5
CheckPassword verifies if the provided password matches the user's hashed password
func (*User) Deactivate ¶ added in v0.1.5
func (u *User) Deactivate()
Deactivate marks the user as inactive
func (*User) GetFullName ¶ added in v0.1.5
GetFullName returns the user's full name
func (*User) SetPassword ¶ added in v0.1.5
SetPassword hashes and sets the user's password
func (*User) UpdateProfile ¶ added in v0.1.5
UpdateProfile updates the user's profile information
func (*User) ValidatePassword ¶ added in v0.1.5
ValidatePassword validates a password
Click to show internal directories.
Click to hide internal directories.