send_batch_msg_text_logic.go 899 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package batch_msg
  2. import (
  3. "context"
  4. "wechat-api/hook/aliyun"
  5. "wechat-api/internal/svc"
  6. "wechat-api/internal/types"
  7. "github.com/zeromicro/go-zero/core/logx"
  8. )
  9. type SendBatchMsgTextLogic struct {
  10. logx.Logger
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. }
  14. func NewSendBatchMsgTextLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendBatchMsgTextLogic {
  15. return &SendBatchMsgTextLogic{
  16. Logger: logx.WithContext(ctx),
  17. ctx: ctx,
  18. svcCtx: svcCtx}
  19. }
  20. func (l *SendBatchMsgTextLogic) SendBatchMsgText(req *types.SendMsgReq) (*types.BaseMsgResp, error) {
  21. resp := types.BaseMsgResp{}
  22. result, err := aliyun.SendChatappMessage("template", *req.TemplateCode, *req.Lang, *req.Phone, *req.To)
  23. l.Logger.Infof("send chatapp message result=%v\n", result)
  24. if err != nil {
  25. resp.Code = 1
  26. resp.Msg = err.Error()
  27. } else {
  28. resp.Msg = *result.Body.Code
  29. }
  30. return &resp, nil
  31. }