package model

import (
	"time"

	"gorm.io/datatypes"
)

type GameAccount struct {
	ID             uint64         `gorm:"primaryKey" json:"id"`
	OwnerID        uint64         `gorm:"not null;index" json:"owner_id"`
	GameName       string         `gorm:"size:64;not null;default:'delta_force'" json:"game_name"`
	ServerRegion   string         `gorm:"size:64;not null" json:"server_region"`
	LoginPlatform  string         `gorm:"size:64;not null" json:"login_platform"`
	Title          string         `gorm:"size:128;not null" json:"title"`
	Description    string         `json:"description"`
	RankLevel      string         `gorm:"size:64;not null;default:''" json:"rank_level"`
	HafCoinAmount  int64          `gorm:"not null;default:0" json:"haf_coin_amount"`
	AssetSummary   datatypes.JSON `json:"asset_summary"`
	SeasonTags     datatypes.JSON `json:"season_tags"`
	ScreenshotURLS datatypes.JSON `gorm:"column:screenshot_urls" json:"screenshot_urls"`
	Status         string         `gorm:"size:32;not null;default:'draft'" json:"status"`
	CreatedAt      time.Time      `json:"created_at"`
	UpdatedAt      time.Time      `json:"updated_at"`
}

func (GameAccount) TableName() string {
	return "game_accounts"
}

type RentalListing struct {
	ID            uint64     `gorm:"primaryKey" json:"id"`
	AccountID     uint64     `gorm:"not null;index" json:"account_id"`
	OwnerID       uint64     `gorm:"not null;index" json:"owner_id"`
	Price         float64    `gorm:"type:decimal(12,2);not null;default:0" json:"price"`
	DepositAmount float64    `gorm:"type:decimal(12,2);not null;default:0" json:"deposit_amount"`
	InTransaction bool       `gorm:"not null;default:false" json:"in_transaction"`
	Status        string     `gorm:"size:32;not null;default:'draft'" json:"status"`
	ReviewStatus  string     `gorm:"size:32;not null;default:'none'" json:"review_status"`
	ReviewReason  string     `gorm:"size:255;not null;default:''" json:"review_reason"`
	PublishedAt   *time.Time `json:"published_at"`
	CreatedAt     time.Time  `json:"created_at"`
	UpdatedAt     time.Time  `json:"updated_at"`
}

func (RentalListing) TableName() string {
	return "rental_listings"
}

type ListingUpload struct {
	ID               uint64         `gorm:"primaryKey" json:"id"`
	UploaderName     string         `gorm:"size:64;not null;index" json:"uploader_name"`
	MatchedAdminID   *uint64        `gorm:"index" json:"matched_admin_id"`
	OwnerID          *uint64        `gorm:"index" json:"owner_id"`
	ClientUploadTime *time.Time     `json:"client_upload_time"`
	ClientIP         string         `gorm:"size:64;not null;default:''" json:"client_ip"`
	RawPayload       datatypes.JSON `json:"raw_payload"`
	ParsedPayload    datatypes.JSON `json:"parsed_payload"`
	ListingID        *uint64        `gorm:"index" json:"listing_id"`
	Status           string         `gorm:"size:32;not null;default:'draft_created'" json:"status"`
	ErrorMessage     string         `gorm:"size:255;not null;default:''" json:"error_message"`
	CreatedAt        time.Time      `json:"created_at"`
	UpdatedAt        time.Time      `json:"updated_at"`
}

func (ListingUpload) TableName() string {
	return "listing_uploads"
}
