fix
This commit is contained in:
@@ -7,8 +7,8 @@ import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func (d *FsProductDesignModel) FindOneBySn(ctx context.Context, sn string) (resp FsProductDesign, err error) {
|
||||
err = d.db.WithContext(ctx).Model(&FsProductDesign{}).Where("`sn` = ? and `status` = ?", sn, 1).First(&resp).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
|
||||
}
|
||||
|
||||
@@ -2,8 +2,17 @@ package gmodel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func (s *FsProductSizeModel) FindOne(ctx context.Context, id int64) (resp FsProductSize, err error) {
|
||||
err = s.db.WithContext(ctx).Model(&FsProductSize{}).Where("`id` = ? and `status` = ?", id, 1).First(&resp).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return FsProductSize{}, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
func (s *FsProductSizeModel) GetAllByIds(ctx context.Context, ids []int64, sort string) (resp []FsProductSize, err error) {
|
||||
if len(ids) == 0 {
|
||||
return
|
||||
|
||||
@@ -2,15 +2,35 @@ package gmodel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func (t *FsProductTemplateV2Model) FindAllByProductIds(ctx context.Context, productIds []int64) (resp []FsProductTemplateV2, err error) {
|
||||
if len(productIds) == 0 {
|
||||
return
|
||||
}
|
||||
err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`id` in (?) and `is_del` = ? and `status` = ?", productIds, 0, 1).Find(&resp).Error
|
||||
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
|
||||
}
|
||||
return
|
||||
}
|
||||
func (t *FsProductTemplateV2Model) FindAllByIds(ctx context.Context, ids []int64) (resp []FsProductTemplateV2, err error) {
|
||||
if len(ids) == 0 {
|
||||
return
|
||||
}
|
||||
err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`id` in (?) and `is_del` = ? and `status` = ?", ids, 0, 1).Find(&resp).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
func (t *FsProductTemplateV2Model) FindOne(ctx context.Context, id int64) (resp FsProductTemplateV2, err error) {
|
||||
|
||||
err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`id` = ? and `is_del` = ? and `status` = ?", id, 0, 1).Find(&resp).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return FsProductTemplateV2{}, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user