app-cloudep-notification-se.../internal/logic/senderservice/send_sms_logic.go

40 lines
914 B
Go
Raw Normal View History

2024-08-20 06:35:14 +00:00
package senderservicelogic
import (
"app-cloudep-notification-service/pkg/domain/usecase"
2024-08-20 06:35:14 +00:00
"context"
"app-cloudep-notification-service/gen_result/pb/notification"
"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 寄簡訊
2024-08-20 06:35:14 +00:00
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
}
2024-08-20 06:35:14 +00:00
return &notification.OKResp{}, nil
}