fusenapi/model/gmodel/fs_order_logic.go
laodaming 47bf9580da fix
2023-06-16 15:11:37 +08:00

19 lines
573 B
Go
Executable File

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).First(&resp).Error
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return FsOrder{}, err
}
return resp, nil
}
func (o *FsOrderModel) Update(ctx context.Context, id int64, data FsOrder) error {
return o.db.WithContext(ctx).Model(&FsOrder{}).Where("`id` = ?", id).Updates(data).Error
}