pg_log_sms_repository.go 962 字节
package repository

import (
	pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
	"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
	"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models"
)

type LogSmsRepository struct {
	transactionContext *pgTransaction.TransactionContext
}

func NewLogSmsRepository(transactionContext *pgTransaction.TransactionContext) *LogSmsRepository {
	return &LogSmsRepository{transactionContext: transactionContext}
}

var _ domain.LogSmsRepository = (*LogSmsRepository)(nil)

func (repo *LogSmsRepository) Insert(param *domain.LogSms) error {
	m := models.LogSms{
		Id:         param.Id,
		Phone:      param.Phone,
		TemplateId: param.TemplateId,
		Template:   param.Template,
		Value:      param.Value,
		CreatedAt:  param.CreatedAt,
		Result:     param.Result,
	}
	tx := repo.transactionContext.PgTx
	_, err := tx.Model(&m).Insert()
	if err != nil {
		return err
	}
	return nil
}