Yimaru-BackEnd/internal/domain/user.go

207 lines
5.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
Gender string
BirthDay time.Time `json:"birth_day"`
// UserName string
Email string
PhoneNumber string
Password []byte
Role Role
Age int
EducationLevel string
Country string
Region string
// Profile fields
KnowledgeLevel string
InitialAssessmentCompleted bool
NickName string
Occupation string
LearningGoal string
LanguageGoal string
LanguageChallange string
FavouriteTopic 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"`
Gender string `json:"gender"`
BirthDay time.Time `json:"birth_day"`
// 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"`
FavouriteTopic 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 int64
PageSize int64
Query string
CreatedBefore ValidTime
CreatedAfter ValidTime
}
type RegisterUserReq struct {
Email string `json:"email"`
PhoneNumber string `json:"phone_number"`
Password string `json:"password"`
Role string `json:"role"`
OtpMedium OtpMedium `json:"otp_medium"`
}
type CreateUserReq struct {
FirstName string
LastName string
Gender string `json:"gender"`
BirthDay time.Time `json:"birth_day"`
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
FavouriteTopic string
PreferredLanguage string
}
type ResetPasswordReq struct {
UserID int64
Password string
OtpCode string
}
type UpdateUserStatusReq struct {
Status string
UserID int64
}
type UpdateUserReq struct {
// Identity (enforced from auth context, not request body)
UserID int64 `json:"-"`
// Basic profile
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Gender string `json:"gender"`
BirthDay time.Time `json:"birth_day"`
// Contact (optional at least one must exist at DB level)
// Email string `json:"email"`
// PhoneNumber string `json:"phone_number"`
// Personal details
Age int64 `json:"age"`
EducationLevel string `json:"education_level"`
Country string `json:"country"`
Region string `json:"region"`
// Learning / profile
KnowledgeLevel string `json:"knowledge_level"`
NickName string `json:"nick_name"`
Occupation string `json:"occupation"`
LearningGoal string `json:"learning_goal"`
LanguageGoal string `json:"language_goal"`
LanguageChallange string `json:"language_challange"`
FavouriteTopic string `json:"favourite_topic"`
InitialAssessmentCompleted bool `json:"initial_assessment_completed"`
// EmailVerified bool `json:"email_verified"`
// PhoneVerified bool `json:"phone_verified"`
ProfileCompleted bool `json:"profile_completed"`
// Media & preferences
ProfilePictureURL string `json:"profile_picture_url"`
PreferredLanguage string `json:"preferred_language"`
}