From 1da29bb71520c0def0a59cf1344de2bae5ce3ffc Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 4 Sep 2023 15:00:11 +0800 Subject: [PATCH] fix --- server/websocket/internal/logic/commonnotifylogic.go | 4 ++-- server/websocket/internal/types/types.go | 6 ++++-- server_api/websocket.api | 6 ++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/server/websocket/internal/logic/commonnotifylogic.go b/server/websocket/internal/logic/commonnotifylogic.go index 5dba13b1..82c0f05a 100644 --- a/server/websocket/internal/logic/commonnotifylogic.go +++ b/server/websocket/internal/logic/commonnotifylogic.go @@ -97,8 +97,8 @@ func ConsumeCommonCacheData(ctx context.Context) { func (l *CommonNotifyLogic) CommonNotify(req *types.CommonNotifyReq, userinfo *auth.UserInfo) (resp *basic.Response) { searchConnectType := "uniqueId" if req.Wid == "" { - if !userinfo.IsUser() && !userinfo.IsGuest() { - return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "websocket connect id is empty") + if req.UserId == 0 && req.GuestId == 0 { + return resp.SetStatusWithMessage(basic.CodeOK, "用户信息或者连接标识必须保证至少有其中一个") } searchConnectType = "userInfo" } diff --git a/server/websocket/internal/types/types.go b/server/websocket/internal/types/types.go index 32263435..f56eb527 100644 --- a/server/websocket/internal/types/types.go +++ b/server/websocket/internal/types/types.go @@ -13,8 +13,10 @@ type RenderNotifyReq struct { } type CommonNotifyReq struct { - Wid string `json:"wid"` //websocket连接标识 - Data map[string]interface{} `json:"data"` //后端与前端约定好的数据 + Wid string `json:"wid,optional"` //websocket连接标识 + UserId int64 `json:"user_id,optional"` //用户id + GuestId int64 `json:"guest_id,optional"` //游客id + Data map[string]interface{} `json:"data"` //后端与前端约定好的数据 } type Request struct { diff --git a/server_api/websocket.api b/server_api/websocket.api index ad1cc925..34e02ad4 100644 --- a/server_api/websocket.api +++ b/server_api/websocket.api @@ -29,6 +29,8 @@ type RenderNotifyReq { } //通用回调接口 type CommonNotifyReq { - Wid string `json:"wid"` //websocket连接标识,(如果传了token,则以token为主寻找连接) - Data map[string]interface{} `json:"data"` //后端与前端约定好的数据 + Wid string `json:"wid,optional"` //websocket连接标识 + UserId int64 `json:"user_id,optional"` //用户id + GuestId int64 `json:"guest_id,optional"` //游客id + Data map[string]interface{} `json:"data"` //后端与前端约定好的数据 } \ No newline at end of file