- make SkuNameExt.Skus as real object (not string).
This commit is contained in:
@@ -12,7 +12,8 @@ import (
|
||||
|
||||
type SkuNameExt struct {
|
||||
model.SkuName
|
||||
Skus string `orm:"size(2000)" json:"skus"`
|
||||
Skus []*model.Sku `orm:"-" json:"skus"`
|
||||
SkusStr string `orm:"size(2000)" json:"-"`
|
||||
}
|
||||
|
||||
type SkuNamesInfo struct {
|
||||
@@ -233,7 +234,8 @@ func GetSkuNames(keyword string, params map[string]interface{}, offset, pageSize
|
||||
t1.unit,
|
||||
t1.price,
|
||||
t1.img,
|
||||
t1.elm_img_hash_code, CONCAT("[", GROUP_CONCAT(CONCAT('{"id":', t2.id, ',"specQuality":', t2.spec_quality, ',"specUnit":"', t2.spec_unit, '","weight":', t2.weight, ',"jdID":', t2.jd_id, "}")), "]") skus
|
||||
t1.elm_img_hash_code,
|
||||
CONCAT("[", GROUP_CONCAT(CONCAT('{"id":', t2.id, ',"createdAt":"', CONCAT(REPLACE(t2.created_at," ","T"),"+08:00"), '","updatedAt":"', CONCAT(REPLACE(t2.updated_at," ","T"),"+08:00"), '","lastOperator":"', t2.last_operator, '","specQuality":', t2.spec_quality, ',"specUnit":"', t2.spec_unit, '","weight":', t2.weight, ',"jdID":', t2.jd_id, ',"categoryID":', t2.category_id, ',"nameID":', t2.name_id, "}")), "]") skus_str
|
||||
` + sql + `
|
||||
ORDER BY t1.id
|
||||
LIMIT ? OFFSET ?`
|
||||
@@ -250,7 +252,20 @@ func GetSkuNames(keyword string, params map[string]interface{}, offset, pageSize
|
||||
countInfo := &struct{ Ct int }{}
|
||||
if err = dao.GetRow(db, countInfo, "SELECT FOUND_ROWS() ct"); err == nil {
|
||||
skuNamesInfo.TotalCount = countInfo.Ct
|
||||
for _, skuName := range skuNamesInfo.SkuNames {
|
||||
if err = utils.UnmarshalUseNumber([]byte(skuName.SkusStr), &skuName.Skus); err != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return skuNamesInfo, err
|
||||
}
|
||||
|
||||
func AddSkuName(skuNameID int, payload map[string]interface{}) (num int64, err error) {
|
||||
return num, err
|
||||
}
|
||||
|
||||
func UpdateSkuName(skuNameID int, payload map[string]interface{}) (num int64, err error) {
|
||||
return num, err
|
||||
}
|
||||
|
||||
@@ -122,13 +122,13 @@ type SkuName struct {
|
||||
type Sku struct {
|
||||
ModelIDCUL
|
||||
|
||||
CategoryID int `orm:"column(category_id)"` // 特殊类别,一般用于秒杀,特价之类的特殊类别
|
||||
NameID int `orm:"column(name_id)"` // todo 这个索引应该要求唯一
|
||||
SpecQuality float32
|
||||
SpecUnit string `orm:"size(8)"` // 质量或容量
|
||||
Weight int // 重量/质量,单位为克,当相应的SkuName的SpecUnit为g或kg时,必须等于SpecQuality
|
||||
CategoryID int `orm:"column(category_id)" json:"categoryID"` // 特殊类别,一般用于秒杀,特价之类的特殊类别
|
||||
NameID int `orm:"column(name_id)" json:"nameID"` // todo 这个索引应该要求唯一
|
||||
SpecQuality float32 `json:"specQuality"`
|
||||
SpecUnit string `orm:"size(8)" json:"specUnit"` // 质量或容量
|
||||
Weight int `json:"weight"` // 重量/质量,单位为克,当相应的SkuName的SpecUnit为g或kg时,必须等于SpecQuality
|
||||
|
||||
JdID int64 `orm:"column(jd_id)"`
|
||||
JdID int64 `orm:"column(jd_id)" json:"jdID"`
|
||||
}
|
||||
|
||||
func (*Sku) TableUnique() [][]string {
|
||||
|
||||
Reference in New Issue
Block a user