21 lines
762 B
Go
Executable File
21 lines
762 B
Go
Executable File
package gmodel
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
func (od *FsOrderDetailModel) GetOrderDetailsByOrderId(ctx context.Context, orderId int64) (resp []FsOrderDetail, err error) {
|
|
err = od.db.WithContext(ctx).Model(&FsOrderDetail{}).Where("`order_id` = ?", orderId).Find(&resp).Error
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return
|
|
}
|
|
func (od *FsOrderDetailModel) FindOneByOrderDetailTemplateId(ctx context.Context, templateId int64) (resp *FsOrderDetail, err error) {
|
|
err = od.db.WithContext(ctx).Model(&FsOrderDetail{}).Where("`order_detail_template_id` = ?", templateId).Take(&resp).Error
|
|
return resp, err
|
|
}
|
|
func (od *FsOrderDetailModel) Create(ctx context.Context, data *FsOrderDetail) error {
|
|
return od.db.WithContext(ctx).Model(&FsOrderDetail{}).Create(&data).Error
|
|
}
|