审查视图

pkg/infrastructure/dao/pg_order_bestshop.go 808 字节
唐旭辉 authored
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
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 OrderBestshopDao struct {
	transactionContext *transaction.TransactionContext
}

func NewOrderBestshopDao(transactionContext *transaction.TransactionContext) (*OrderBestshopDao, error) {
	if transactionContext == nil {
		return nil, fmt.Errorf("transactionContext参数不能为nil")
	} else {
		return &OrderBestshopDao{
			transactionContext: transactionContext,
		}, nil
	}
}

func (dao OrderBestshopDao) OrderExist(orderCode string) (bool, error) {
	tx := dao.transactionContext.GetDB()
	m := models.OrderBestshop{}
唐旭辉 authored
27
	query := tx.Model(&m).Where("order_code=?", orderCode)
唐旭辉 authored
28 29 30
	ok, err := query.Exists()
	return ok, err
}