40 lines
		
	
	
		
			980 B
		
	
	
	
		
			Go
		
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			980 B
		
	
	
	
		
			Go
		
	
	
	
package senderservicelogic
 | 
						|
 | 
						|
import (
 | 
						|
	"code.30cm.net/digimon/app-cloudep-notification-service/pkg/domain/usecase"
 | 
						|
	"context"
 | 
						|
 | 
						|
	"code.30cm.net/digimon/app-cloudep-notification-service/gen_result/pb/notification"
 | 
						|
	"code.30cm.net/digimon/app-cloudep-notification-service/internal/svc"
 | 
						|
 | 
						|
	"github.com/zeromicro/go-zero/core/logx"
 | 
						|
)
 | 
						|
 | 
						|
type SendSmsLogic struct {
 | 
						|
	ctx    context.Context
 | 
						|
	svcCtx *svc.ServiceContext
 | 
						|
	logx.Logger
 | 
						|
}
 | 
						|
 | 
						|
func NewSendSmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendSmsLogic {
 | 
						|
	return &SendSmsLogic{
 | 
						|
		ctx:    ctx,
 | 
						|
		svcCtx: svcCtx,
 | 
						|
		Logger: logx.WithContext(ctx),
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
// SendSms 寄簡訊
 | 
						|
func (l *SendSmsLogic) SendSms(in *notification.SendSMSReq) (*notification.OKResp, error) {
 | 
						|
	err := l.svcCtx.DeliveryUseCase.SendMessage(l.ctx, usecase.SMSMessageRequest{
 | 
						|
		PhoneNumber:    in.GetTo(),
 | 
						|
		RecipientName:  in.GetRecipientName(),
 | 
						|
		MessageContent: in.GetBody(),
 | 
						|
	})
 | 
						|
	if err != nil {
 | 
						|
		return nil, err
 | 
						|
	}
 | 
						|
 | 
						|
	return ¬ification.OKResp{}, nil
 | 
						|
}
 |