149 lines
3.4 KiB
Go
149 lines
3.4 KiB
Go
package domain
|
|
|
|
import (
|
|
"errors"
|
|
"time"
|
|
)
|
|
|
|
var (
|
|
ErrUserNotVerified = errors.New("user not verified")
|
|
ErrUserNotFound = errors.New("user not found")
|
|
ErrEmailAlreadyRegistered = errors.New("email is already registered")
|
|
ErrPhoneAlreadyRegistered = errors.New("phone number is already registered")
|
|
)
|
|
|
|
/*
|
|
UserStatus reflects the lifecycle state of a user account.
|
|
Matches DB column: users.status
|
|
*/
|
|
type UserStatus string
|
|
|
|
const (
|
|
UserStatusPending UserStatus = "PENDING"
|
|
UserStatusActive UserStatus = "ACTIVE"
|
|
UserStatusSuspended UserStatus = "SUSPENDED"
|
|
UserStatusDeactivated UserStatus = "DEACTIVATED"
|
|
)
|
|
|
|
type User struct {
|
|
ID int64
|
|
FirstName string
|
|
LastName string
|
|
UserName string
|
|
Email string
|
|
PhoneNumber string
|
|
Password []byte
|
|
Role Role
|
|
|
|
Age int
|
|
EducationLevel string
|
|
Country string
|
|
Region string
|
|
|
|
EmailVerified bool
|
|
PhoneVerified bool
|
|
Status UserStatus
|
|
|
|
LastLogin *time.Time
|
|
ProfileCompleted bool
|
|
ProfilePictureURL string
|
|
PreferredLanguage string
|
|
|
|
CreatedAt time.Time
|
|
UpdatedAt *time.Time
|
|
}
|
|
|
|
type UserProfileResponse struct {
|
|
ID int64 `json:"id"`
|
|
FirstName string `json:"first_name"`
|
|
LastName string `json:"last_name"`
|
|
UserName string `json:"user_name,omitempty"`
|
|
Email string `json:"email,omitempty"`
|
|
PhoneNumber string `json:"phone_number,omitempty"`
|
|
Role Role `json:"role"`
|
|
Age int `json:"age,omitempty"`
|
|
EducationLevel string `json:"education_level,omitempty"`
|
|
Country string `json:"country,omitempty"`
|
|
Region string `json:"region,omitempty"`
|
|
EmailVerified bool `json:"email_verified"`
|
|
PhoneVerified bool `json:"phone_verified"`
|
|
Status UserStatus `json:"status"`
|
|
LastLogin *time.Time `json:"last_login,omitempty"`
|
|
ProfileCompleted bool `json:"profile_completed"`
|
|
ProfilePictureURL string `json:"profile_picture_url,omitempty"`
|
|
PreferredLanguage string `json:"preferred_language,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt *time.Time `json:"updated_at,omitempty"`
|
|
}
|
|
|
|
type UserFilter struct {
|
|
Role string
|
|
|
|
Page ValidInt
|
|
PageSize ValidInt
|
|
Query ValidString
|
|
CreatedBefore ValidTime
|
|
CreatedAfter ValidTime
|
|
}
|
|
|
|
type RegisterUserReq struct {
|
|
FirstName string
|
|
LastName string
|
|
UserName string
|
|
Email string
|
|
PhoneNumber string
|
|
Password string
|
|
Role string
|
|
|
|
OtpMedium OtpMedium
|
|
|
|
Age int
|
|
EducationLevel string
|
|
Country string
|
|
Region string
|
|
PreferredLanguage string
|
|
}
|
|
|
|
type CreateUserReq struct {
|
|
FirstName string
|
|
LastName string
|
|
UserName string
|
|
Email string
|
|
PhoneNumber string
|
|
Password string
|
|
Role string
|
|
|
|
Status UserStatus
|
|
|
|
Age int
|
|
EducationLevel string
|
|
Country string
|
|
Region string
|
|
PreferredLanguage string
|
|
}
|
|
|
|
type ResetPasswordReq struct {
|
|
UserName string
|
|
Password string
|
|
OtpCode string
|
|
}
|
|
|
|
type UpdateUserReq struct {
|
|
UserID int64
|
|
|
|
FirstName ValidString
|
|
LastName ValidString
|
|
UserName ValidString
|
|
|
|
Status ValidString
|
|
|
|
Age ValidInt
|
|
EducationLevel ValidString
|
|
Country ValidString
|
|
Region ValidString
|
|
|
|
ProfileCompleted ValidBool
|
|
ProfilePictureURL ValidString
|
|
PreferredLanguage ValidString
|
|
}
|