fusenapi/model/gmodel/fs_order_logic.go

23 lines
726 B
Go
Raw Normal View History

2023-06-16 07:11:37 +00:00
package gmodel
import (
"context"
)
2023-06-20 09:28:28 +00:00
func (o *FsOrderModel) FindOneBySn(ctx context.Context, userId int64, sn string) (resp *FsOrder, err error) {
2023-06-21 04:34:57 +00:00
err = o.db.WithContext(ctx).Model(&FsOrder{}).Where(" `user_id` = ? and `sn` = ? ", userId, sn).Take(&resp).Error
2023-06-20 09:28:28 +00:00
return resp, err
2023-06-16 07:11:37 +00:00
}
2023-06-20 08:46:56 +00:00
2023-06-20 09:28:28 +00:00
func (o *FsOrderModel) FindOne(ctx context.Context, userId int64, OrderId int64) (order *FsOrder, err error) {
2023-06-21 04:34:57 +00:00
err = o.db.WithContext(ctx).Model(&order).Where("`user_id` = ? and `id` = ?", userId, OrderId).Take(&order).Error
2023-06-20 09:28:28 +00:00
if err != nil {
return nil, err
}
return
2023-06-20 08:46:56 +00:00
}
2023-06-20 09:29:02 +00:00
func (o *FsOrderModel) Update(ctx context.Context, data *FsOrder) error {
return o.db.WithContext(ctx).Model(data).Where("`id` = ?", data.Id).Updates(data).Error
2023-06-16 07:11:37 +00:00
}