|
@@ -178,16 +178,26 @@ func (f *FriendPushNoticeTypeHandler) Handle(ctx context.Context, msg *wechat_ws
|
|
|
logx.Error("label not found.fail: ", wxInfo.OrganizationID)
|
|
|
continue
|
|
|
}
|
|
|
- labelRelationshipCreates = append(labelRelationshipCreates,
|
|
|
- svcCtx.DB.LabelRelationship.Create().
|
|
|
- //SetID(int(label.LabelId)).
|
|
|
- SetOrganizationID(wxInfo.OrganizationID).
|
|
|
- SetContactID(friendId).
|
|
|
- SetStatus(1).
|
|
|
- SetLabelID(labelInfo.ID).
|
|
|
- SetCreatedAt(time.Now()).
|
|
|
- SetUpdatedAt(time.Now()),
|
|
|
- )
|
|
|
+
|
|
|
+ _, err = svcCtx.DB.LabelRelationship.Query().Where(
|
|
|
+ labelrelationship.LabelIDEQ(labelInfo.ID),
|
|
|
+ //label.StatusEQ(remoteLabel.LabelName),
|
|
|
+ labelrelationship.ContactIDEQ(friendId),
|
|
|
+ ).Only(ctx)
|
|
|
+
|
|
|
+ if err != nil || ent.IsNotFound(err) {
|
|
|
+ labelRelationshipCreates = append(labelRelationshipCreates,
|
|
|
+ svcCtx.DB.LabelRelationship.Create().
|
|
|
+ //SetID(int(label.LabelId)).
|
|
|
+ SetOrganizationID(wxInfo.OrganizationID).
|
|
|
+ SetContactID(friendId).
|
|
|
+ SetStatus(1).
|
|
|
+ SetLabelID(labelInfo.ID).
|
|
|
+ SetCreatedAt(time.Now()).
|
|
|
+ SetUpdatedAt(time.Now()),
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
//
|
|
|
}
|
|
|
}
|