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

41 lines
981 B
Go
Raw Permalink Normal View History

2024-08-20 06:35:14 +00:00
package senderservicelogic
import (
2025-03-08 03:01:44 +00:00
"code.30cm.net/digimon/app-cloudep-notification-service/pkg/domain/usecase"
2024-08-20 06:35:14 +00:00
"context"
2025-03-08 03:01:44 +00:00
"code.30cm.net/digimon/app-cloudep-notification-service/gen_result/pb/notification"
"code.30cm.net/digimon/app-cloudep-notification-service/internal/svc"
2024-08-20 06:35:14 +00:00
"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) {
2025-03-01 14:10:00 +00:00
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 {
2025-03-01 14:10:00 +00:00
return nil, err
}
2024-08-20 06:35:14 +00:00
return &notification.OKResp{}, nil
}