26 lines
721 B
Go
Executable File
26 lines
721 B
Go
Executable File
package gmodel
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"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
|
|
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
|
return FsProductDesign{}, err
|
|
}
|
|
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
|
|
}
|