package model import ( "time" "gorm.io/gorm" ) // Customer 客户模型 // Logan.Li type Customer struct { ID uint `json:"id" gorm:"primaryKey"` Name string `json:"name" gorm:"size:100;not null"` Company string `json:"company" gorm:"size:200"` Email string `json:"email" gorm:"size:100;uniqueIndex"` Phone string `json:"phone" gorm:"size:20"` Address string `json:"address" gorm:"size:500"` Notes string `json:"notes" gorm:"type:text"` Status int `json:"status" gorm:"default:1"` // 1: 启用, 0: 禁用 Licenses []License `json:"licenses,omitempty" gorm:"foreignKey:CustomerID"` Products []Product `json:"products,omitempty" gorm:"many2many:customer_products;"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt gorm.DeletedAt `json:"deleted_at,omitempty" gorm:"index"` } // TableName 指定表名 // Logan.Li func (Customer) TableName() string { return "customers" }