add and fix apis

This commit is contained in:
2026-10-28 13:27:20 +08:00
parent 38cffc2f2a
commit 8775847d20
12 changed files with 176 additions and 43 deletions
@@ -30,22 +30,13 @@ func NewWsClientStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ws
}
func (l *WsClientStatusLogic) WsClientStatus(in *percutaneous.GetWsCodeRequest) (*percutaneous.Response, error) {
id := in.UserId
if id < utils.NumberOne {
adminInfo := utils.GetUserFromCtx(l.ctx)
if adminInfo.ID < utils.NumberOne {
return l.fail(utils.ErrorNoLoginInfo)
}
id = adminInfo.ID
}
Type := WsTypeApp
//1为web,2为设备
if in.Type == utils.NumberOne {
Type = WsTypeOperation
}
key := utils.MD5Encrypt(fmt.Sprintf("%d%s%s", id, dao.WsCode, Type))
key := utils.MD5Encrypt(fmt.Sprintf("%s%s", dao.WsCode, Type))
redisKey := pkgws.RedisKeyQRSession + key
val, err := redis.Client.Get(l.ctx, redisKey).Result()
@@ -58,7 +49,7 @@ func (l *WsClientStatusLogic) WsClientStatus(in *percutaneous.GetWsCodeRequest)
keys := []string{WsTypeApp, WsTypeOperation}
for _, k := range keys {
key = utils.MD5Encrypt(fmt.Sprintf("%d%s%s", id, dao.WsCode, k))
key = utils.MD5Encrypt(fmt.Sprintf("%s%s", dao.WsCode, k))
redisKey = pkgws.RedisKeyQRSession + key
if err = pkgws.Publish(l.ctx, redisKey, pkgws.Success(data)); err != nil {
l.Errorf("ws client publish: %v", err)