201 lines
5.3 KiB
Go
201 lines
5.3 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 UpdateKnowledgeLevelReq struct {
|
|
UserID int64 `json:"user_id"`
|
|
KnowledgeLevel string `json:"knowledge_level"` // BEGINNER, INTERMEDIATE, ADVANCED
|
|
}
|
|
|
|
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
|
|
|
|
// Profile fields
|
|
KnowledgeLevel string
|
|
initial_assessment_completed bool
|
|
NickName string
|
|
Occupation string
|
|
LearningGoal string
|
|
LanguageGoal string
|
|
LanguageChallange string
|
|
FavoutiteTopic 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"`
|
|
|
|
// Profile fields
|
|
InitialAssessmentCompleted bool `json:"initial_assessment_completed,omitempty"`
|
|
NickName string `json:"nick_name,omitempty"`
|
|
Occupation string `json:"occupation,omitempty"`
|
|
LearningGoal string `json:"learning_goal,omitempty"`
|
|
LanguageGoal string `json:"language_goal,omitempty"`
|
|
LanguageChallange string `json:"language_challange,omitempty"`
|
|
FavoutiteTopic string `json:"favoutite_topic,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 `json:"first_name"`
|
|
LastName string `json:"last_name"`
|
|
UserName string `json:"user_name"`
|
|
Email string `json:"email"`
|
|
PhoneNumber string `json:"phone_number"`
|
|
Password string `json:"password"`
|
|
Role string `json:"role"`
|
|
|
|
OtpMedium OtpMedium `json:"otp_medium"`
|
|
|
|
// NickName string `json:"nick_name,omitempty"`
|
|
// Occupation string `json:"occupation,omitempty"`
|
|
// LearningGoal string `json:"learning_goal,omitempty"`
|
|
// LanguageGoal string `json:"language_goal,omitempty"`
|
|
// LanguageChallange string `json:"language_challange,omitempty"`
|
|
// FavoutiteTopic string `json:"favoutite_topic,omitempty"`
|
|
|
|
// Age int `json:"age,omitempty"`
|
|
// EducationLevel string `json:"education_level,omitempty"`
|
|
// Country string `json:"country,omitempty"`
|
|
// Region string `json:"region,omitempty"`
|
|
// PreferredLanguage string `json:"preferred_language,omitempty"`
|
|
}
|
|
|
|
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
|
|
|
|
// Profile fields
|
|
NickName string
|
|
Occupation string
|
|
LearningGoal string
|
|
LanguageGoal string
|
|
LanguageChallange string
|
|
FavoutiteTopic 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
|
|
|
|
// Profile fields
|
|
KnowledgeLevel ValidString
|
|
NickName ValidString
|
|
Occupation ValidString
|
|
LearningGoal ValidString
|
|
LanguageGoal ValidString
|
|
LanguageChallange ValidString
|
|
FavoutiteTopic ValidString
|
|
|
|
ProfileCompleted ValidBool
|
|
ProfilePictureURL ValidString
|
|
PreferredLanguage ValidString
|
|
}
|