fix
This commit is contained in:
@@ -96,3 +96,17 @@ func (c *FsCartModel) CountUserCart(ctx context.Context, userId int64) (total in
|
||||
}
|
||||
return
|
||||
}
|
||||
func (c *FsCartModel) GetAllByUserId(ctx context.Context, userId int64, sort string) (resp []FsCart, err error) {
|
||||
db := c.db.WithContext(ctx).Model(&FsCart{}).Where("`user_id` = ? and `status` = ?", userId, 1)
|
||||
switch sort {
|
||||
case "ctime-desc":
|
||||
db = db.Order("`ctime` DESC")
|
||||
case "ctime-asc":
|
||||
db = db.Order("`ctime` ASC")
|
||||
}
|
||||
err = db.Find(&resp).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -40,3 +40,13 @@ func (d *FsProductDesignModel) FindOneBySn(ctx context.Context, sn string) (resp
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
func (d *FsProductDesignModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsProductDesign, err error) {
|
||||
if len(ids) == 0 {
|
||||
return
|
||||
}
|
||||
err = d.db.WithContext(ctx).Model(&FsProductDesign{}).Where("`id` in (?) and `status` = ?", ids, 1).Find(&resp).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package gmodel
|
||||
|
||||
import "gorm.io/gorm"
|
||||
import (
|
||||
"context"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type FsProductModel3d struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"`
|
||||
@@ -29,3 +32,23 @@ type FsProductModel3dModel struct {
|
||||
func NewFsProductModel3dModel(db *gorm.DB) *FsProductModel3dModel {
|
||||
return &FsProductModel3dModel{db}
|
||||
}
|
||||
func (d *FsProductModel3dModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsProductModel3d, err error) {
|
||||
if len(ids) == 0 {
|
||||
return
|
||||
}
|
||||
err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`id` in (?) and `status` = ?", ids, 1).Find(&resp).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
func (d *FsProductModel3dModel) GetAllByIdsTag(ctx context.Context, ids []int64, tag int64) (resp []FsProductModel3d, err error) {
|
||||
if len(ids) == 0 {
|
||||
return
|
||||
}
|
||||
err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`id` in (?) and `status` = ? and `tag` = ?", ids, 1, tag).Find(&resp).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ type GetPriceListByProductIdsRsp struct {
|
||||
Price string `json:"price"`
|
||||
}
|
||||
|
||||
func (p *FsProductPriceModel) GetPriceListByProductIds(ctx context.Context, productIds []int64) (resp []GetPriceListByProductIdsRsp, err error) {
|
||||
func (p *FsProductPriceModel) GetSimplePriceListByProductIds(ctx context.Context, productIds []int64) (resp []GetPriceListByProductIdsRsp, err error) {
|
||||
if len(productIds) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -82,3 +82,14 @@ func (p *FsProductPriceModel) FindOneProductPriceByParams(ctx context.Context, r
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
func (p *FsProductPriceModel) GetPriceListByProductIds(ctx context.Context, productIds []int64) (resp []FsProductPrice, err error) {
|
||||
if len(productIds) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
db := p.db.WithContext(ctx).Model(&FsProductPrice{}).
|
||||
Where("`product_id` in (?) and `status` = ?", productIds, 1)
|
||||
if err = db.Find(&resp).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user