package models

import "time"

type Astrologer struct {
	ID                   uint       `gorm:"column:id;primaryKey"`
	UserID               uint       `gorm:"column:userId" json:"userId"`
	Name                 string     `gorm:"column:name"`
	// displayName is the public-facing name step 1 asks for. The request has
	// carried display_name (and required it) all along with no column to land
	// in, so it was validated and dropped; added by
	// migrations/2026_09_09_astrologer_display_name.sql.
	DisplayName          string     `gorm:"column:displayName" json:"displayName"`
	Email                string     `gorm:"column:email"`
	ContactNo            string     `gorm:"column:contactNo"`
	Gender               string     `gorm:"column:gender"`
	MaritalStatus        string     `gorm:"column:maritalStatus" json:"marital_status"`
	BirthDate            *time.Time `gorm:"column:birthDate" json:"birth_date"`
	City                 string     `gorm:"column:city" json:"city"`
	// currentCity is its own column. This mapped onto `city` as well, so the
	// response echoed the city twice and the real column was never written.
	CurrentCity          string     `gorm:"column:currentCity" json:"currentCity"`
	State                string     `gorm:"column:state" json:"state"`
	// One field, one param. There used to be two — Country as "countary" and
	// Countary as "country" — both mapped onto the same column, so the
	// response carried the value twice under two spellings and GORM filled
	// only the first of them.
	//
	// The column keeps the schema's misspelling: astrologers also has a
	// correctly spelled `country` column, but it is NULL on every row and no
	// query in this project reads it, while `countary` holds the data.
	Country              string     `gorm:"column:countary" json:"country"`
	Bio                  string     `gorm:"column:loginBio" json:"loginBio"`
	ProfileImage         string     `gorm:"column:profileImage"`
	// Decimal years — 8.5 is eight and a half. The column is a DECIMAL(4,1) as
	// of migrations/2026_09_07_astrologer_basic_profile.sql; it was an INT.
	ExperienceYears      float64    `gorm:"column:experience;type:decimal(4,1)"`
	LearnAstrology       string     `gorm:"column:learnAstrology" json:"learnAstrology"`
	DailyHours           int        `gorm:"column:dailyContribution" json:"dailyContribution"`
	WorkingPlatform      bool       `gorm:"column:isWorkingOnAnotherPlatform" json:"isWorkingOnAnotherPlatform"`
	WorkingPlatformName  string     `gorm:"column:nameofplateform" json:"nameofplateform"`
	CompletionPercentage int        `gorm:"column:completion_percentage"`
	CurrentStep          int        `gorm:"column:current_step"`
	ProfileStatus        string     `gorm:"column:profile_status"`
	IsProfileCompleted   bool       `gorm:"column:is_profile_completed"`
	PrimarySkill         string     `gorm:"column:primarySkill"`
	AllSkill             string     `gorm:"column:allSkill"`
	LanguageKnown        string     `gorm:"column:languageKnown"`
	HighestQualification string     `gorm:"column:highestQualification"`
	// The columns are `degree` and `college`. These tags said `Degree` and
	// `College`: MySQL matches an identifier case-insensitively, so writing
	// worked, but GORM maps a result-set column to a field through a
	// case-sensitive lookup on the tag — so reading did not. Both fields came
	// back empty on every load, and the next step's Save then wrote those
	// empty strings over what the education step had stored.
	Degree               string     `gorm:"column:degree"`
	College              string     `gorm:"column:college"`
	AstrologerCategoryID string     `gorm:"column:astrologerCategoryId"`
	Charge               int        `gorm:"column:charge"`
	DeviceType           string     `gorm:"column:deviceType"`
	DailyContribution    int        `gorm:"column:dailyContribution"`
	ChatRate             int        `gorm:"column:chatRate"`
	AudioCallRate        int        `gorm:"column:audioCallRate"`
	VideoCallRate        int        `gorm:"column:videoCallRate"`
	FreeChat             bool       `gorm:"column:freeChat"`
	FreeCall             bool       `gorm:"column:freeCall"`
	ChatStatus           string     `gorm:"column:chatStatus"`
	ChatWaitTime         string     `gorm:"column:chatWaitTime"`
	CallStatus           string     `gorm:"column:callStatus"`
	CallWaitTime         string     `gorm:"column:callWaitTime"`
	ReportRate           int        `gorm:"column:reportRate"`
	IsActive             bool       `gorm:"column:isActive"`
	IsDelete             bool       `gorm:"column:isDelete"`
	IsAvailable          int        `gorm:"column:is_available"` // 0 offline, 1 online, 2 busy in a session
	SubmittedAt          time.Time  `gorm:"column:submitted_at"`
	VerificationStatus   string     `gorm:"column:verification_status"`
	AdminStatus          string     `gorm:"column:admin_status"`
	Status               string     `gorm:"column:status"`
	IsVerified           bool       `gorm:"column:isVerified"`
	InstaProfileLink     string     `gorm:"column:instaProfileLink"`
	FacebookProfileLink  string     `gorm:"column:facebookProfileLink"`
	YoutubeProfileLink   string     `gorm:"column:youtubeChannelLink"`
	TelegramProfileLink  string     `gorm:"column:telegramProfileLink"`
	LinkedinProfileLink  string     `gorm:"column:linkedInProfileLink"`
	WebsiteProfileLink   string     `gorm:"column:websiteProfileLink"`
	IsAnyBodyReferred    bool       `gorm:"column:isAnyBodyRefer"`
	Nameofplateform      string     `gorm:"column:nameofplateform"`
	CreatedAt            *time.Time `gorm:"column:created_at"`
	UpdatedAt            *time.Time `gorm:"column:updated_at"`

	Languages []AstrologerLanguage `gorm:"foreignKey:AstrologerID" json:"languages"`

	Skills []AstrologerSkill `gorm:"foreignKey:AstrologerID" json:"skills"`

	Educations []AstrologerEducation `gorm:"foreignKey:AstrologerID" json:"educations"`

	Professionals []AstrologerProfessional `gorm:"foreignKey:AstrologerID" json:"professionals"`

	Experiences []AstrologerExperience `gorm:"foreignKey:AstrologerID" json:"experiences"`

	BankAccount []AstrologerBankAccount `gorm:"foreignKey:AstrologerID"`

	Documents []AstrologerDocument `gorm:"foreignKey:AstrologerID" json:"documents"`

	// astrologer_availabilities holds one row per day, so this is a slice. It
	// was a single struct, which GORM filled with at most one row and
	// otherwise left as a zero value — the response showed an availability
	// block of empty strings and zeroes whatever the astrologer had saved.
	Availability []AstrologerAvailability `gorm:"foreignKey:AstrologerID" json:"Availability"`

	SocialLinks []AstrologerSocialLink `gorm:"foreignKey:AstrologerID" json:"social_links"`

	WaitingQueue []AstrologerWaitingQueue `gorm:"foreignKey:AstrologerID" json:"waitingQueue"`

	Progress []AstrologerProfileProgress `gorm:"foreignKey:AstrologerID" json:"progress"`

	ProfileCompletion []AstrologerProfileCompletion `gorm:"foreignKey:AstrologerID;references:ID"`

	VerificationLogs []AstrologerVerificationLog `gorm:"foreignKey:AstrologerID"`
}

func (Astrologer) TableName() string {
	return "astrologers"
}
