contact_push_notice.go 845 B

12345678910111213141516171819202122232425262728293031323334
  1. package wecom
  2. import (
  3. "context"
  4. "encoding/json"
  5. "github.com/zeromicro/go-zero/core/logx"
  6. "sync"
  7. "wechat-api/internal/pkg/wechat_ws"
  8. "wechat-api/internal/svc"
  9. "wechat-api/workphone/wecom"
  10. )
  11. type ContactPushNoticeHandler struct {
  12. svcCtx *svc.ServiceContext
  13. lockMap sync.Map // 微信号 -> *sync.Mutex
  14. }
  15. func NewContactPushNoticeHandler(svcCtx *svc.ServiceContext) *ContactPushNoticeHandler {
  16. return &ContactPushNoticeHandler{
  17. svcCtx: svcCtx,
  18. }
  19. }
  20. // Handle 实现 MessageHandlerStrategy 接口
  21. func (f *ContactPushNoticeHandler) Handle(ctx context.Context, msg *wechat_ws.MsgJsonObject, svcCtx *svc.ServiceContext) error {
  22. message := wecom.ContactPushNoticeMessage{}
  23. err := json.Unmarshal([]byte(msg.Message), &message)
  24. logx.Infof("msg.Message 的内容是:%s", msg.Message)
  25. if err != nil {
  26. return err
  27. }
  28. return nil
  29. }