package mixrepoimpl import ( "context" "voucher/internal/biz/mixrepos" "voucher/internal/conf" "voucher/internal/pkg/sms" ) type SmsMixRepoImpl struct { bc *conf.Bootstrap smsService sms.Service } func NewSmsMixRepoImpl(bc *conf.Bootstrap) (mixrepos.SmsMixRepo, error) { config := sms.Config{ AccessKeyID: bc.AliYunSms.AccessKeyId, AccessKeySecret: bc.AliYunSms.AccessKeySecret, Endpoint: bc.AliYunSms.Endpoint, SignName: bc.AliYunSms.SignName, RetryTimes: 0, Timeout: 15, } smsService, err := sms.NewService(config) if err != nil { return nil, err } return &SmsMixRepoImpl{bc: bc, smsService: smsService}, nil } func (s *SmsMixRepoImpl) SendCode(ctx context.Context, phone, code string) error { return s.smsService.SendSMS(ctx, []string{phone}, s.bc.AliYunSms.TemplateSendCode, map[string]string{"code": code}) }