package domain import ( "errors" "time" ) type AgeGroup string const ( AgeUnder13 AgeGroup = "UNDER_13" Age13To17 AgeGroup = "13_17" Age18To24 AgeGroup = "18_24" Age25To34 AgeGroup = "25_34" Age35To44 AgeGroup = "35_44" Age45To54 AgeGroup = "45_54" Age55Plus AgeGroup = "55_PLUS" ) var ( ErrUserNotVerified = errors.New("user not verified") ErrUserAccountLocked = errors.New("user account is locked") ErrUserNotFound = errors.New("user not found") ErrEmailAlreadyRegistered = errors.New("email is already registered") ErrPhoneAlreadyRegistered = errors.New("phone number is already registered") ErrGoogleAccountAlreadyRegistered = errors.New("google account is already linked to another user") ErrAppleAccountAlreadyRegistered = errors.New("apple account is already linked to another user") ) /* 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" ) // ValidateUserCanAuthenticate reports whether a platform user may sign in or use auth tokens. // PENDING users must complete verification; SUSPENDED and DEACTIVATED accounts are locked. func ValidateUserCanAuthenticate(status UserStatus) error { switch status { case UserStatusPending: return ErrUserNotVerified case UserStatusSuspended, UserStatusDeactivated: return ErrUserAccountLocked default: return nil } } 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 AgeGroup string EducationLevel string Country string Region string // Profile fields KnowledgeLevel string NickName string Occupation string LearningGoal string LanguageGoal string LanguageChallange string FavouriteTopic string EmailVerified bool PhoneVerified bool Status UserStatus LastLogin *time.Time ProfileCompleted bool ProfileCompletionPercentage int 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 string `json:"birth_day,omitempty"` // formatted as YYYY-MM-DD // UserName string `json:"user_name,omitempty"` Email string `json:"email,omitempty"` PhoneNumber string `json:"phone_number,omitempty"` Role Role `json:"role"` AgeGroup string `json:"age_group,omitempty"` EducationLevel string `json:"education_level,omitempty"` Country string `json:"country,omitempty"` Region string `json:"region,omitempty"` // Profile fields 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"` ProfileCompletionPercentage int `json:"profile_completion_percentage"` ProfilePictureURL string `json:"profile_picture_url"` PreferredLanguage string `json:"preferred_language,omitempty"` CreatedAt time.Time `json:"created_at"` UpdatedAt *time.Time `json:"updated_at,omitempty"` SubscriptionStatus string `json:"subscription_status"` ActiveSubscriptions []UserProfileSubscription `json:"active_subscriptions"` } // UserProfileSubscription is an active subscription summary embedded in user profile responses. type UserProfileSubscription struct { ID int64 `json:"id"` PlanID int64 `json:"plan_id"` PlanName *string `json:"plan_name,omitempty"` Category *string `json:"category,omitempty"` IsLifetime *bool `json:"is_lifetime,omitempty"` StartsAt string `json:"starts_at"` ExpiresAt string `json:"expires_at"` Status string `json:"status"` AutoRenew bool `json:"auto_renew"` DurationValue *int32 `json:"duration_value,omitempty"` DurationUnit *string `json:"duration_unit,omitempty"` Price *float64 `json:"price,omitempty"` Currency *string `json:"currency,omitempty"` CreatedAt string `json:"created_at"` } type UserFilter struct { Role string Status string Country string Region string SubscriptionStatus string // display filter: ACTIVE, PENDING, Unsubscribed, EXPIRED // Profile EducationLevel string Occupation string AgeGroup string FavouriteTopic string LanguageGoal string LearningGoal string KnowledgeLevel string // Subscription targeting (current or derived subscription state) PlanID *int64 PlanCategory string AutoRenew *bool HasEverPaid *bool ExpiresWithinDays *int32 // Engagement / activity LastLoginBefore ValidTime LastLoginAfter ValidTime DaysSinceLastLoginMin *int32 DaysSinceLastLoginMax *int32 ProfileCompleted *bool MinLessonsCompleted *int32 MinModulesCompleted *int32 MinProfileCompletionPct *int32 // Technical / deliverability (device table only; push permission, timezone, app version not stored) DevicePlatform string HasActiveDevice *bool Page int64 PageSize int64 Query string CreatedBefore ValidTime CreatedAfter ValidTime } type AccountDeletionState string const ( AccountDeletionStatePending AccountDeletionState = "PENDING" AccountDeletionStateDue AccountDeletionState = "DUE" AccountDeletionStateCancelled AccountDeletionState = "CANCELLED" ) type AccountDeletionRequestFilter struct { Query string Role string Status string State string RequestedBefore ValidTime RequestedAfter ValidTime ScheduledBefore ValidTime ScheduledAfter ValidTime Page int64 PageSize int64 } type AccountDeletionRequest struct { UserID int64 FirstName string LastName string Email string PhoneNumber string Role Role Status UserStatus DeletionRequestedAt *time.Time DeletionScheduledAt *time.Time DeletionCancelledAt *time.Time DeletionState AccountDeletionState } 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 AgeGroup string 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 { Email string PhoneNumber string Password string OtpCode string } type UpdateUserStatusReq struct { Status string UserID int64 } type UserSummary struct { TotalUsers int64 `json:"total_users"` ActiveUsers int64 `json:"active_users"` JoinedThisMonth int64 `json:"joined_this_month"` } type UpdateUserReq struct { UserID int64 `json:"-"` FirstName string `json:"first_name"` LastName string `json:"last_name"` Gender string `json:"gender"` BirthDay *string `json:"birth_day"` // YYYY-MM-DD AgeGroup *AgeGroup `json:"age_group"` EducationLevel string `json:"education_level"` Country string `json:"country"` Region string `json:"region"` 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"` ProfilePictureURL string `json:"profile_picture_url"` PreferredLanguage string `json:"preferred_language"` }