package db import ( "applet/app/db/model" "xorm.io/xorm" ) func FindSkuByGoodsID(engine *xorm.Engine, goodsId string) ([]*model.Sku, error) { var skus []*model.Sku err := engine.Where("goods_id = ?", goodsId).Find(&skus) return skus, err } func GetMallSkuBySkuCode(engine *xorm.Engine, skuCode, goodsId string) (isHas bool, mm *model.Sku, err error) { isHas = false var m model.Sku isHas, err = engine.Where("sku_code=?", skuCode).And("goods_id!=?", goodsId).Get(&m) if err != nil { return isHas, &m, err } return isHas, &m, nil } func GetMallSkuBySkuId(engine *xorm.Engine, skuId, goodsId string) (isHas bool, mm *model.Sku, err error) { isHas = false var m model.Sku isHas, err = engine.Where("sku_id=?", skuId).And("goods_id=?", goodsId).Get(&m) if err != nil { return isHas, &m, err } return isHas, &m, nil } func GetSkuMore(engine *xorm.Engine, skuIds []int64) map[int64]model.Sku { skuMap := make(map[int64]model.Sku) var skus []model.Sku err := engine.Table("sku").In("sku_id", skuIds).Find(&skus) if err != nil { return skuMap } for _, v := range skus { skuMap[v.SkuId] = v } return skuMap }