pg_order_payment_dao.go
866 字节
package dao
import (
"fmt"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/models"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/transaction"
)
type OrderPayment struct {
transactionContext *transaction.TransactionContext
}
//删除数据
func (o *OrderPayment) Remove(orderId int64, status int, idList []int) error {
if len(idList) == 0 {
return nil
}
tx := o.transactionContext.PgTx
m := new(models.OrderPayment)
q := tx.Model(m).Where("order_id=?", orderId).
WhereIn("id not in(?)", idList)
_, err := q.Delete()
return err
}
func NewOrderPayment(transactionContext *transaction.TransactionContext) (*OrderPayment, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
} else {
return &OrderPayment{
transactionContext: transactionContext,
}, nil
}
}