This commit is contained in:
laodaming 2023-07-17 11:42:29 +08:00
parent ae1b3e1e64
commit fffdf448c4
2 changed files with 8 additions and 7 deletions

View File

@ -4,15 +4,16 @@ import (
"context"
)
func (t *FsProductTemplateV2Model) FindAllByProductIds(ctx context.Context, productIds []int64) (resp []FsProductTemplateV2, err error) {
func (t *FsProductTemplateV2Model) FindAllByProductIds(ctx context.Context, productIds []int64, fields ...string) (resp []FsProductTemplateV2, err error) {
if len(productIds) == 0 {
return
}
err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`product_id` in (?) and `is_del` = ? and `status` = ?", productIds, 0, 1).Find(&resp).Error
if err != nil {
return nil, err
db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`product_id` in (?) and `is_del` = ? and `status` = ?", productIds, 0, 1)
if len(fields) != 0 {
db = db.Select(fields[0])
}
return
err = db.Find(&resp).Error
return resp, err
}
func (t *FsProductTemplateV2Model) FindAllByIds(ctx context.Context, ids []int64) (resp []FsProductTemplateV2, err error) {
if len(ids) == 0 {

View File

@ -116,8 +116,8 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
sort.Ints(priceSlice)
mapProductMinPrice[v.ProductId] = int64(priceSlice[0])
}
//获取模板
productTemplatesV2, err := l.svcCtx.AllModels.FsProductTemplateV2.FindAllByProductIds(l.ctx, productIds)
//获取模板(只是获取产品product_id)
productTemplatesV2, err := l.svcCtx.AllModels.FsProductTemplateV2.FindAllByProductIds(l.ctx, productIds, "product_id")
if err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeServiceErr, "get product template_v2 err")