YouChuKoffee/app/models/productsmodel/products.go

56 lines
1.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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)"`
ThirdProductId string `xorm:"'third_product_Id' varchar(100)"`
}
type MilkProductsList struct {
Products `xorm:"extends"`
Flag string `xorm:"'flag' varchar(50)"`
}
// 表名
func (m *Products) TableName() string {
return "products"
}
// 私有化防止被外部new
type ProductsModel struct {
db.Model //组合基础Model集成基础Model的属性和方法
}
// 单例模式
func GetInstance() *ProductsModel {
once.Do(func() {
m = new(ProductsModel)
//m.DiName = "" //设置数据库实例连接默认db.SingletonMain
})
return m
}