41 lines
915 B
Go
41 lines
915 B
Go
package senderservicelogic
|
|
|
|
import (
|
|
"app-cloudep-notification-service/pkg/domain/usecase"
|
|
"context"
|
|
|
|
"app-cloudep-notification-service/gen_result/pb/notification"
|
|
"app-cloudep-notification-service/internal/svc"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type SendMailLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewSendMailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendMailLogic {
|
|
return &SendMailLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
// SendMail 寄信
|
|
func (l *SendMailLogic) SendMail(in *notification.SendMailReq) (*notification.OKResp, error) {
|
|
err := l.svcCtx.DeliveryUseCase.SendEmail(l.ctx, usecase.MailReq{
|
|
To: []string{in.GetTo()},
|
|
Subject: in.GetSubject(),
|
|
Body: in.GetBody(),
|
|
From: in.GetFrom(),
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return ¬ification.OKResp{}, nil
|
|
}
|