YouChuKoffee/app/models/productsmodel/products.go

56 lines
1.5 KiB
Go
Raw Normal View History

2024-06-17 16:29:39 +08:00
package productsmodel
import (
"github.com/qit-team/snow-core/db"
"sync"
"time"
)
var (
once sync.Once
m *ProductsModel
)
// 实体
type Products struct {
Id string `xorm:"'id' UNSIGNED BIGINT pk autoincr"`
Name string `xorm:"'name' varchar(255)"`
MainImage string `xorm:"'main_image' varchar(255)"`
Brand string `xorm:"'brand' varchar(100)"`
BrandId int `xorm:"'brand_id' int(10)"`
Stock string `xorm:"'stock' UNSIGNED INT"`
ShowPrice string `xorm:"'show_price' decimal(10,2)"`
Price string `xorm:"'price' decimal(10,2)"`
Type string `xorm:"'type' UNSIGNED TINYINT"`
CreateTime time.Time `xorm:"'create_time' datetime"`
UpdateTime time.Time `xorm:"'update_time' datetime"`
Deleted time.Time `xorm:"'Deleted' datetime"`
Status string `xorm:"'status' UNSIGNED TINYINT"`
Description string `xorm:"'description' varchar(500)"`
2024-08-05 15:45:30 +08:00
ThirdProductId string `xorm:"'third_product_Id' varchar(100)"`
2024-06-17 16:29:39 +08:00
}
type MilkProductsList struct {
Products `xorm:"extends"`
Flag string `xorm:"'flag' varchar(50)"`
}
// 表名
func (m *Products) TableName() string {
2024-09-04 15:50:27 +08:00
return "products"
2024-06-17 16:29:39 +08:00
}
// 私有化防止被外部new
type ProductsModel struct {
db.Model //组合基础Model集成基础Model的属性和方法
}
// 单例模式
func GetInstance() *ProductsModel {
once.Do(func() {
m = new(ProductsModel)
//m.DiName = "" //设置数据库实例连接默认db.SingletonMain
})
return m
}