fix
This commit is contained in:
@@ -2,17 +2,12 @@ package gmodel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func (a *FsAddressModel) GetOne(ctx context.Context, id int64, userId int64) (resp FsAddress, err error) {
|
||||
err = a.db.WithContext(ctx).Model(&FsAddress{}).Where("`id` = ? and `user_id` = ? and `status` = ? ", id, userId, 1).Take(&resp).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return FsAddress{}, err
|
||||
}
|
||||
return resp, nil
|
||||
func (a *FsAddressModel) GetOne(ctx context.Context, id int64, userId int64) (resp *FsAddress, err error) {
|
||||
err = a.db.WithContext(ctx).Model(&FsAddress{}).Where("`id` = ? and `user_id` = ? and `status` = ? ", id, userId, 1).Take(resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (a *FsAddressModel) GetUserAllAddress(ctx context.Context, userId int64) (resp []FsAddress, err error) {
|
||||
|
||||
@@ -2,9 +2,6 @@ package gmodel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// FsGetTypeCanteenType GetType返回前端的结构
|
||||
@@ -22,10 +19,7 @@ func (c *FsCanteenTypeModel) FindAllGetType(ctx context.Context) (resp []*FsGetT
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
func (c *FsCanteenTypeModel) FindOne(ctx context.Context, id int64) (resp FsCanteenType, err error) {
|
||||
err = c.db.WithContext(ctx).Model(&FsCanteenType{}).Where("`id` = ?", id).First(&resp).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp, err
|
||||
}
|
||||
return resp, nil
|
||||
func (c *FsCanteenTypeModel) FindOne(ctx context.Context, id int64) (resp *FsCanteenType, err error) {
|
||||
err = c.db.WithContext(ctx).Model(&FsCanteenType{}).Where("`id` = ?", id).First(resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
@@ -4,8 +4,6 @@ package gmodel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type FindOneCartByParamsReq struct {
|
||||
@@ -18,14 +16,11 @@ type FindOneCartByParamsReq struct {
|
||||
Status *int64
|
||||
}
|
||||
|
||||
func (c *FsCartModel) FindOne(ctx context.Context, id int64) (resp FsCart, err error) {
|
||||
err = c.db.WithContext(ctx).Model(&FsCart{}).Where("`id` = ?", id).First(&resp).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return FsCart{}, err
|
||||
}
|
||||
return resp, nil
|
||||
func (c *FsCartModel) FindOne(ctx context.Context, id int64) (resp *FsCart, err error) {
|
||||
err = c.db.WithContext(ctx).Model(&FsCart{}).Where("`id` = ?", id).First(resp).Error
|
||||
return resp, err
|
||||
}
|
||||
func (c *FsCartModel) FindOneCartByParams(ctx context.Context, req FindOneCartByParamsReq) (resp FsCart, err error) {
|
||||
func (c *FsCartModel) FindOneCartByParams(ctx context.Context, req FindOneCartByParamsReq) (resp *FsCart, err error) {
|
||||
db := c.db.WithContext(ctx).Model(&FsCart{})
|
||||
if req.UserId != nil {
|
||||
db = db.Where("`user_id` = ?", req.UserId)
|
||||
@@ -48,10 +43,11 @@ func (c *FsCartModel) FindOneCartByParams(ctx context.Context, req FindOneCartBy
|
||||
if req.Status != nil {
|
||||
db = db.Where("`status` = ?", req.Status)
|
||||
}
|
||||
if err = db.First(&resp).Error; err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return FsCart{}, err
|
||||
err = db.First(&resp).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
return
|
||||
}
|
||||
func (c *FsCartModel) Create(ctx context.Context, data FsCart) error {
|
||||
return c.db.WithContext(ctx).Model(&FsCart{}).Create(&data).Error
|
||||
|
||||
@@ -2,22 +2,19 @@ package gmodel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func (o *FsOrderModel) FindOneBySn(ctx context.Context, userId int64, sn string) (resp FsOrder, err error) {
|
||||
err = o.db.WithContext(ctx).Model(&FsOrder{}).Where(" `user_id` = ? and `sn` = ? ", userId, sn).Take(&resp).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return FsOrder{}, err
|
||||
}
|
||||
return resp, nil
|
||||
func (o *FsOrderModel) FindOneBySn(ctx context.Context, userId int64, sn string) (resp *FsOrder, err error) {
|
||||
err = o.db.WithContext(ctx).Model(&FsOrder{}).Where(" `user_id` = ? and `sn` = ? ", userId, sn).Take(resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (o *FsOrderModel) FindOne(ctx context.Context, userId int64, OrderId int64) (order FsOrder, err error) {
|
||||
err = o.db.WithContext(ctx).Model(&order).Where("`user_id` = ? and `id` = ?", userId, OrderId).Take(&order).Error
|
||||
return order, err
|
||||
func (o *FsOrderModel) FindOne(ctx context.Context, userId int64, OrderId int64) (order *FsOrder, err error) {
|
||||
err = o.db.WithContext(ctx).Model(&order).Where("`user_id` = ? and `id` = ?", userId, OrderId).Take(order).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (o *FsOrderModel) Update(ctx context.Context, id int64, data FsOrder) error {
|
||||
|
||||
@@ -2,17 +2,11 @@ package gmodel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func (d *FsProductDesignModel) FindOneBySn(ctx context.Context, sn string, userId int64) (resp FsProductDesign, err error) {
|
||||
func (d *FsProductDesignModel) FindOneBySn(ctx context.Context, sn string, userId int64) (resp *FsProductDesign, err error) {
|
||||
err = d.db.WithContext(ctx).Model(&FsProductDesign{}).Where("`sn` = ? and `user_id` = ? and `status` = ?", sn, userId, 1).First(&resp).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return FsProductDesign{}, err
|
||||
}
|
||||
return resp, nil
|
||||
return resp, err
|
||||
}
|
||||
func (d *FsProductDesignModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsProductDesign, err error) {
|
||||
if len(ids) == 0 {
|
||||
|
||||
@@ -2,18 +2,15 @@ package gmodel
|
||||
|
||||
import "context"
|
||||
|
||||
func (p *FsProductModel) FindOne(ctx context.Context, id int64) (resp FsProduct, err error) {
|
||||
err = p.db.Model(&FsProduct{}).Where("`id` = ? and `is_del` =? and `is_shelf` = ? and `status` =?", id, 0, 1, 1).First(&resp).Error
|
||||
if err != nil {
|
||||
return FsProduct{}, err
|
||||
}
|
||||
return resp, nil
|
||||
func (p *FsProductModel) FindOne(ctx context.Context, id int64) (resp *FsProduct, err error) {
|
||||
err = p.db.WithContext(ctx).Model(&FsProduct{}).Where("`id` = ? and `is_del` =? and `is_shelf` = ? and `status` =?", id, 0, 1, 1).First(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
func (p *FsProductModel) GetProductListByIds(ctx context.Context, productIds []int64, sort string) (resp []FsProduct, err error) {
|
||||
if len(productIds) == 0 {
|
||||
return
|
||||
}
|
||||
db := p.db.Model(&FsProduct{}).
|
||||
db := p.db.Model(&FsProduct{}).WithContext(ctx).
|
||||
Where("`id` in (?) and `is_del` =? and `is_shelf` = ? and `status` =?", productIds, 0, 1, 1)
|
||||
switch sort {
|
||||
case "sort-asc":
|
||||
|
||||
@@ -2,16 +2,11 @@ package gmodel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func (d *FsProductModel3dModel) FindOne(ctx context.Context, id int64) (resp FsProductModel3d, err error) {
|
||||
func (d *FsProductModel3dModel) FindOne(ctx context.Context, id int64) (resp *FsProductModel3d, err error) {
|
||||
err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`id` = ? ", id).Find(&resp).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return FsProductModel3d{}, err
|
||||
}
|
||||
return resp, nil
|
||||
return resp, err
|
||||
}
|
||||
func (d *FsProductModel3dModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsProductModel3d, err error) {
|
||||
if len(ids) == 0 {
|
||||
|
||||
@@ -2,16 +2,11 @@ package gmodel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func (s *FsProductSizeModel) FindOne(ctx context.Context, id int64) (resp FsProductSize, err error) {
|
||||
func (s *FsProductSizeModel) FindOne(ctx context.Context, id int64) (resp *FsProductSize, err error) {
|
||||
err = s.db.WithContext(ctx).Model(&FsProductSize{}).Where("`id` = ? ", id).First(&resp).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return FsProductSize{}, err
|
||||
}
|
||||
return resp, nil
|
||||
return resp, err
|
||||
}
|
||||
func (s *FsProductSizeModel) GetAllByIds(ctx context.Context, ids []int64, sort string) (resp []FsProductSize, err error) {
|
||||
if len(ids) == 0 {
|
||||
|
||||
@@ -2,8 +2,6 @@ package gmodel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func (t *FsProductTemplateV2Model) FindAllByProductIds(ctx context.Context, productIds []int64) (resp []FsProductTemplateV2, err error) {
|
||||
@@ -26,11 +24,8 @@ func (t *FsProductTemplateV2Model) FindAllByIds(ctx context.Context, ids []int64
|
||||
}
|
||||
return
|
||||
}
|
||||
func (t *FsProductTemplateV2Model) FindOne(ctx context.Context, id int64) (resp FsProductTemplateV2, err error) {
|
||||
func (t *FsProductTemplateV2Model) FindOne(ctx context.Context, id int64) (resp *FsProductTemplateV2, err error) {
|
||||
|
||||
err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`id` = ? ", id).Find(&resp).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return FsProductTemplateV2{}, err
|
||||
}
|
||||
return resp, nil
|
||||
return resp, err
|
||||
}
|
||||
|
||||
@@ -2,9 +2,6 @@ package gmodel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func (q *FsQrcodeSetModel) GetAll(ctx context.Context) (resp []FsQrcodeSet, err error) {
|
||||
@@ -14,10 +11,7 @@ func (q *FsQrcodeSetModel) GetAll(ctx context.Context) (resp []FsQrcodeSet, err
|
||||
}
|
||||
return
|
||||
}
|
||||
func (q *FsQrcodeSetModel) FindOne(ctx context.Context, id int64) (resp FsQrcodeSet, err error) {
|
||||
func (q *FsQrcodeSetModel) FindOne(ctx context.Context, id int64) (resp *FsQrcodeSet, err error) {
|
||||
err = q.db.WithContext(ctx).Model(&FsQrcodeSet{}).Where("`id` = ?", id).First(&resp).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return FsQrcodeSet{}, err
|
||||
}
|
||||
return resp, nil
|
||||
return resp, err
|
||||
}
|
||||
|
||||
@@ -2,17 +2,11 @@ package gmodel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func (t *FsTagsModel) FindOne(ctx context.Context, id int64) (resp FsTags, err error) {
|
||||
func (t *FsTagsModel) FindOne(ctx context.Context, id int64) (resp *FsTags, err error) {
|
||||
err = t.db.WithContext(ctx).Model(&FsTags{}).Where("`id` = ? and `status` = ?", id, 1).First(&resp).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return FsTags{}, err
|
||||
}
|
||||
return resp, nil
|
||||
return resp, err
|
||||
}
|
||||
func (t *FsTagsModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsTags, err error) {
|
||||
if len(ids) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user