Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
@@ -2,8 +2,12 @@ package gmodel
|
||||
|
||||
import "context"
|
||||
|
||||
func (p *FsProductModel) FindOne(ctx context.Context, id int64) (resp *FsProduct, err error) {
|
||||
err = p.db.WithContext(ctx).Model(&FsProduct{}).Where("`id` = ? ", id).First(&resp).Error
|
||||
func (p *FsProductModel) FindOne(ctx context.Context, id int64, fields ...string) (resp *FsProduct, err error) {
|
||||
db := p.db.WithContext(ctx).Model(&FsProduct{}).Where("`id` = ? ", id)
|
||||
if len(fields) != 0 {
|
||||
db = db.Select(fields[0])
|
||||
}
|
||||
err = db.Take(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
func (p *FsProductModel) FindOneBySn(ctx context.Context, sn string, fields ...string) (resp *FsProduct, err error) {
|
||||
|
||||
Reference in New Issue
Block a user