|
@@ -0,0 +1,34 @@
|
|
|
+package wecom
|
|
|
+
|
|
|
+import (
|
|
|
+ "context"
|
|
|
+ "encoding/json"
|
|
|
+ "github.com/zeromicro/go-zero/core/logx"
|
|
|
+ "sync"
|
|
|
+ "wechat-api/internal/pkg/wechat_ws"
|
|
|
+ "wechat-api/internal/svc"
|
|
|
+ "wechat-api/workphone/wecom"
|
|
|
+)
|
|
|
+
|
|
|
+type ContactPushNoticeHandler struct {
|
|
|
+ svcCtx *svc.ServiceContext
|
|
|
+ lockMap sync.Map // 微信号 -> *sync.Mutex
|
|
|
+}
|
|
|
+
|
|
|
+func NewContactPushNoticeHandler(svcCtx *svc.ServiceContext) *ContactPushNoticeHandler {
|
|
|
+ return &ContactPushNoticeHandler{
|
|
|
+ svcCtx: svcCtx,
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// Handle 实现 MessageHandlerStrategy 接口
|
|
|
+func (f *ContactPushNoticeHandler) Handle(ctx context.Context, msg *wechat_ws.MsgJsonObject, svcCtx *svc.ServiceContext) error {
|
|
|
+ message := wecom.ContactPushNoticeMessage{}
|
|
|
+ err := json.Unmarshal([]byte(msg.Message), &message)
|
|
|
+ logx.Infof("msg.Message 的内容是:%s", msg.Message)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+
|
|
|
+ return nil
|
|
|
+}
|