sendcommaillogic.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package logic
  2. import (
  3. "bp.jydev.jianyu360.cn/BaseService/biService/api/internal/svc"
  4. "bp.jydev.jianyu360.cn/BaseService/biService/api/internal/types"
  5. "bp.jydev.jianyu360.cn/BaseService/biService/rpc/biservice"
  6. "context"
  7. "github.com/zeromicro/go-zero/core/logx"
  8. )
  9. type SendComMailLogic struct {
  10. logx.Logger
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. }
  14. func NewSendComMailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendComMailLogic {
  15. return &SendComMailLogic{
  16. Logger: logx.WithContext(ctx),
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. }
  20. }
  21. func (l *SendComMailLogic) SendComMail(req *types.SendMailReq) (resp *types.BiResp, err error) {
  22. if req.Title == "" {
  23. return &types.BiResp{Error_code: -1, Error_msg: "邮件标题不能为空"}, err
  24. }
  25. if req.Mails == "" {
  26. return &types.BiResp{Error_code: -1, Error_msg: "邮件内容不能为空"}, err
  27. }
  28. if req.Mails == "" {
  29. return &types.BiResp{Error_code: -1, Error_msg: "邮箱地址不能为空"}, err
  30. }
  31. res, err := l.svcCtx.BiServiceRpc.SendCommonMail(l.ctx, &biservice.SendMailReq{
  32. Title: req.Title,
  33. Content: req.Content,
  34. Mails: req.Mails,
  35. })
  36. return &types.BiResp{Error_code: res.ErrorCode, Error_msg: res.ErrorMsg, Data: string(res.Data)}, err
  37. }