mail.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package service
  2. import (
  3. "context"
  4. "fmt"
  5. "go-common/library/log"
  6. )
  7. const (
  8. ISO8601Date = "2006-01-02"
  9. )
  10. // SendEmail is send the finished Task info to reciever
  11. func (s *Service) SendEmail(c context.Context, taskID int64) (err error) {
  12. task, err := s.dao.DetailTask(c, taskID)
  13. if err != nil {
  14. log.Error("s.SendEmail() error(%v)", err)
  15. return
  16. }
  17. createAt := task.CTime.Time().Format(ISO8601Date)
  18. var sourceDesc string
  19. if task.SourceType == 1 {
  20. sourceDesc = "创作姬"
  21. } else {
  22. sourceDesc = "其他"
  23. }
  24. var appStr string
  25. if task.Platform == 1 {
  26. appStr = "IOS"
  27. } else if task.Platform == 2 {
  28. appStr = "Android"
  29. }
  30. date := task.LogDate.Time().Format(ISO8601Date)
  31. subject := fmt.Sprintf(" %s 创建的日志上报完成通知", createAt)
  32. body := fmt.Sprintf("你于%s创建的一条日志上报任务(上报来源:%s,%s App端,采集的日志文件日期:%s,指定MID:%d),现已上报完毕。", createAt, sourceDesc, appStr, date, task.MID)
  33. err = s.dao.SendEmail(subject, task.ContactEmail, body)
  34. return
  35. }