pg_users_dao.go 765 字节
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 UsersDao struct {
	transactionContext *transaction.TransactionContext
}

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

func (dao UsersDao) UpdateUserStatus(ids []int64, ststus int8) error {
	tx := dao.transactionContext.PgTx
	m := &models.Users{}
	_, err := tx.Model(m).
		Set("status=?", ststus).
		Where("id in(?)", ids).
		Update()
	return err
}