27 lines
748 B
Go
Executable File
27 lines
748 B
Go
Executable File
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type Product struct {
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
|
|
|
Name string `gorm:"size:200;not null" json:"name"`
|
|
Description string `gorm:"type:text" json:"description"`
|
|
Price float64 `gorm:"type:decimal(10,2);not null" json:"price"`
|
|
Stock int `gorm:"default:0" json:"stock"`
|
|
ImageURL string `gorm:"size:500" json:"image_url"`
|
|
Category string `gorm:"size:50" json:"category"`
|
|
Status int `gorm:"default:1" json:"status"`
|
|
}
|
|
|
|
func (Product) TableName() string {
|
|
return "products"
|
|
}
|