This commit is contained in:
2026-08-14 16:34:17 +08:00
parent e0b0e1d8c8
commit f63acae353
53 changed files with 2488 additions and 350 deletions
+1 -16
View File
@@ -16,23 +16,8 @@ type EmailUsecase struct{ repo EmailRepo }
func NewEmailUsecase(repo EmailRepo) *EmailUsecase { return &EmailUsecase{repo: repo} }
func splitRecipients(value string) []string {
parts := strings.Split(value, ",")
result := make([]string, 0, len(parts))
for _, part := range parts {
if recipient := strings.TrimSpace(part); recipient != "" {
result = append(result, recipient)
}
}
return result
}
func (uc *EmailUsecase) Send(ctx context.Context, to, subject, body string) error {
recipients := splitRecipients(to)
if len(recipients) == 0 || subject == "" {
return errors.New("收件人和邮件标题不能为空")
}
return uc.repo.Send(ctx, recipients, subject, body)
return uc.repo.Send(ctx, strings.Split(to, ","), subject, body)
}
func (uc *EmailUsecase) Test(ctx context.Context) error {