package models

import (
	"time"

	"gorm.io/gorm"
)

type Ticket struct {
	ID         uint           `gorm:"primaryKey" json:"id"`
	UserID     uint           `gorm:"index;not null" json:"user_id"`
	Title      string         `gorm:"size:200;not null" json:"title"`
	Content    string         `gorm:"type:text;not null" json:"content"`
	Category   string         `gorm:"size:50" json:"category"`
	Status     string         `gorm:"size:20;not null;default:'pending'" json:"status"`
	AssignedTo *uint          `json:"assigned_to"`
	Reply      string         `gorm:"type:text" json:"reply"`
	CreatedAt  time.Time      `json:"created_at"`
	UpdatedAt  time.Time      `json:"updated_at"`
	DeletedAt  gorm.DeletedAt `gorm:"index" json:"-"`
	User       User           `gorm:"foreignKey:UserID" json:"user,omitempty"`
	Assignee   *User          `gorm:"foreignKey:AssignedTo" json:"assignee,omitempty"`
}

func (Ticket) TableName() string {
	return "tickets"
}

const (
	TicketStatusPending    = "pending"
	TicketStatusProcessing = "processing"
	TicketStatusResolved   = "resolved"
	TicketStatusClosed     = "closed"

	TicketCategoryOrder    = "order"
	TicketCategoryAccount  = "account"
	TicketCategoryProduct  = "product"
	TicketCategoryOther    = "other"
)
