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 OrderBaseDao struct { transactionContext *transaction.TransactionContext } func NewOrderBaseDao(transactionContext *transaction.TransactionContext) (*OrderBaseDao, error) { if transactionContext == nil { return nil, fmt.Errorf("transactionContext参数不能为nil") } else { return &OrderBaseDao{ transactionContext: transactionContext, }, nil } } func (dao OrderBaseDao) OrderCodeExist(code string, notId ...int64) (bool, error) { tx := dao.transactionContext.PgDd m := &models.OrderBase{} query := tx.Model(m).Where("order_code=?", code) if len(notId) > 0 { query = query.WhereIn("id not in(?)", notId) } ok, err := query.Exists() return ok, err } func (dao OrderBaseDao) DeliveryCodeExist(code string, notId ...int64) (bool, error) { tx := dao.transactionContext.PgDd m := &models.OrderBase{} query := tx.Model(m).Where("delivery_code=?", code) if len(notId) > 0 { query = query.WhereIn("id not in(?)", notId) } ok, err := query.Exists() return ok, err }