XinYeYouKu/app/models/productmodel/product.go

51 lines
1.4 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 productmodel
import (
"github.com/qit-team/snow-core/db"
"sync"
"time"
)
var (
once sync.Once
m *ProductModel
)
// 实体
type Product struct {
Id int `xorm:"'id' UNSIGNED BIGINT pk autoincr"`
Name string `xorm:"'name' varchar(255)"`
Brand string `xorm:"'brand' varchar(50)"`
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"`
ManagerId string `xorm:"'manager_id' UNSIGNED INT"`
Status string `xorm:"'status' UNSIGNED TINYINT"`
MainImage string `xorm:"'main_image' varchar(255)"`
Description string `xorm:"'description' varchar(500)"`
ThirdProductId int `xorm:"'third_product_Id' int(0)"`
}
// 表名
func (m *Product) TableName() string {
return "product"
}
// 私有化防止被外部new
type ProductModel struct {
db.Model //组合基础Model集成基础Model的属性和方法
}
// 单例模式
func GetInstance() *ProductModel {
once.Do(func() {
m = new(ProductModel)
//m.DiName = "" //设置数据库实例连接默认db.SingletonMain
})
return m
}