31 lines
1.3 KiB
Go
Executable File
31 lines
1.3 KiB
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
|
|
return resp, err
|
|
}
|
|
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
|
|
}
|
|
|
|
func (od *FsOrderDetailModel) GetOneOrderDetailByOrderId(ctx context.Context, orderId int64) (resp *FsOrderDetail, err error) {
|
|
err = od.db.WithContext(ctx).Model(&FsOrderDetail{}).Where("`order_id` = ?", orderId).Take(&resp).Error
|
|
return resp, err
|
|
}
|
|
func (d *FsProductDesignModel) FindOne(ctx context.Context, id int64, userId int64) (resp *FsProductDesign, err error) {
|
|
err = d.db.WithContext(ctx).Model(&FsProductDesign{}).Where("`id` = ? and `user_id` = ? and `status` = ?", id, userId, 1).First(&resp).Error
|
|
return resp, err
|
|
}
|
|
|
|
func (m *FsOrderDetailModel) TableName() string {
|
|
return m.name
|
|
}
|