zhangqian
2023-08-17 a934b5ea45f84c71d9d309a1c69bfa21d1898b4a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package model
 
import (
    "github.com/shopspring/decimal"
    "gorm.io/gorm"
)
 
type Product struct {
    Id         uint            `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
    Name       string          `json:"name" gorm:"column:name;type:varchar(255);comment:产品名称"`
    Price      decimal.Decimal `json:"price" gorm:"column:price;type:decimal(10,2);comment:产品价格"`
    Number     string          `json:"number" gorm:"column:number;type:varchar(255);comment:产品编号"`
    Amount     decimal.Decimal `json:"amount" gorm:"column:amount;type:int;comment:产品数量"`
    Total      decimal.Decimal `json:"total" gorm:"column:total;type:decimal(10,2);comment:产品总价"`
    Desc       string          `json:"desc" gorm:"column:desc;type:varchar(255);comment:产品描述"`
    gorm.Model `json:"-"`
}
 
func (Product) TableName() string {
    return "products"
}