This commit is contained in:
laodaming 2023-09-04 15:00:11 +08:00
parent f6e2edf3a8
commit 1da29bb715
3 changed files with 10 additions and 6 deletions

View File

@ -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"
}

View File

@ -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 {

View File

@ -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"` //后端与前端约定好的数据
}