package entity import "time" type UndianEventDB struct { ID int64 `gorm:"primaryKey;autoIncrement" json:"id"` Title string `gorm:"size:255;not null" json:"title"` Description *string `gorm:"type:text" json:"description"` ImageURL *string `gorm:"size:500" json:"image_url"` Status string `gorm:"size:20;not null;default:upcoming" json:"status"` StartDate time.Time `gorm:"not null" json:"start_date"` EndDate time.Time `gorm:"not null" json:"end_date"` DrawDate time.Time `gorm:"not null" json:"draw_date"` MinimumPurchase float64 `gorm:"type:numeric(10,2);default:50000" json:"minimum_purchase"` DrawCompleted bool `gorm:"default:false" json:"draw_completed"` DrawCompletedAt *time.Time `json:"draw_completed_at"` TermsAndConditions *string `gorm:"column:terms_and_conditions;type:text" json:"terms_and_conditions"` CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"` UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"` Prefix *string `json:"prefix"` Prizes []UndianPrizeDB `gorm:"foreignKey:UndianEventID" json:"prizes,omitempty"` Vouchers []UndianVoucherDB `gorm:"foreignKey:UndianEventID" json:"vouchers,omitempty"` } func (UndianEventDB) TableName() string { return "undian_events" } // UndianPrizeDB represents the undian_prizes table type UndianPrizeDB struct { ID int64 `gorm:"primaryKey;autoIncrement" json:"id"` UndianEventID int64 `gorm:"not null" json:"undian_event_id"` Rank int `gorm:"not null" json:"rank"` PrizeName string `gorm:"size:255;not null" json:"prize_name"` PrizeValue *float64 `gorm:"type:numeric(15,2)" json:"prize_value"` PrizeDescription *string `gorm:"type:text" json:"prize_description"` PrizeType string `gorm:"size:50;default:voucher" json:"prize_type"` PrizeImageURL *string `gorm:"size:500" json:"prize_image_url"` WinningVoucherID *int64 `json:"winning_voucher_id"` WinnerUserID *int64 `json:"winner_user_id"` Amount *int64 `json:"amount"` // Relations UndianEvent UndianEventDB `gorm:"foreignKey:UndianEventID" json:"undian_event,omitempty"` } func (UndianPrizeDB) TableName() string { return "undian_prizes" } // UndianVoucherDB represents the undian_vouchers table type UndianVoucherDB struct { ID int64 `gorm:"primaryKey;autoIncrement" json:"id"` UndianEventID int64 `gorm:"not null" json:"undian_event_id"` CustomerID int64 `gorm:"not null" json:"customer_id"` OrderID *int64 `json:"order_id"` VoucherCode string `gorm:"size:50;not null;uniqueIndex" json:"voucher_code"` VoucherNumber *int `json:"voucher_number"` IsWinner bool `gorm:"default:false" json:"is_winner"` PrizeRank *int `json:"prize_rank"` WonAt *time.Time `json:"won_at"` CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"` // Relations UndianEvent UndianEventDB `gorm:"foreignKey:UndianEventID" json:"undian_event,omitempty"` } func (UndianVoucherDB) TableName() string { return "undian_vouchers" } // Response Models type UndianListResponse struct { Events []*UndianEventResponse `json:"events"` } type UndianEventResponse struct { ID int64 `json:"id"` Title string `json:"title"` Description *string `json:"description"` ImageURL *string `json:"image_url"` Status string `json:"status"` StartDate time.Time `json:"start_date"` EndDate time.Time `json:"end_date"` DrawDate time.Time `json:"draw_date"` MinimumPurchase float64 `json:"minimum_purchase"` DrawCompleted bool `json:"draw_completed"` DrawCompletedAt *time.Time `json:"draw_completed_at"` TermsConditions *string `json:"terms_and_conditions"` Prefix *string `json:"prefix"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` VoucherCount int `json:"voucher_count"` Vouchers []*UndianVoucherResponse `json:"vouchers"` Prizes []*UndianPrizeResponse `json:"prizes"` } type UndianVoucherResponse struct { ID int64 `json:"id"` VoucherCode string `json:"voucher_code"` VoucherNumber *int `json:"voucher_number"` IsWinner bool `json:"is_winner"` PrizeRank *int `json:"prize_rank"` WonAt *time.Time `json:"won_at"` CreatedAt time.Time `json:"created_at"` } type UndianPrizeResponse struct { ID int64 `json:"id"` Rank int `json:"rank"` PrizeName string `json:"prize_name"` PrizeValue *float64 `json:"prize_value"` PrizeDescription *string `json:"prize_description"` PrizeType string `json:"prize_type"` PrizeImageURL *string `json:"prize_image_url"` WinningVoucherID *int64 `json:"winning_voucher_id"` WinnerUserID *int64 `json:"winner_user_id"` Amount *int64 `json:"amount"` }