fix
CI / changes (push) Successful in 1m31s
CI / ad (push) Successful in 26s
CI / admin (push) Successful in 15s
CI / bff (push) Successful in 14s
CI / chore (push) Successful in 15s
CI / equipment (push) Successful in 17s
CI / express (push) Successful in 13s
CI / factory (push) Successful in 13s
CI / message (push) Successful in 13s
CI / order (push) Successful in 13s
CI / payment (push) Successful in 13s
CI / percutaneous (push) Successful in 19s
CI / product (push) Successful in 17s
CI / record (push) Successful in 15s
CI / sale (push) Successful in 15s
CI / store (push) Successful in 15s
CI / support (push) Successful in 15s
CI / task (push) Successful in 14s
CI / user (push) Successful in 22s
CI / water (push) Successful in 16s
CI / wecom (push) Successful in 14s

This commit is contained in:
2026-10-22 14:30:18 +08:00
parent a7427c2766
commit a77fa23197
5 changed files with 21 additions and 3 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ import (
)
const (
RedisKeyQRSession = "qr:session:"
RedisKeyQRSession = "ws:session:"
RedisKeyQRShare = "qr:share:"
RedisKeyOssUpload = "oss:upload:task:"
RedisKeyTaskLights = "task:lights:"
@@ -3,11 +3,14 @@ package logic
import (
"context"
"fmt"
"lone-services/pkg/redis"
"lone-services/pkg/utils"
pkgws "lone-services/pkg/ws"
"lone-services/rpc/percutaneous/pb"
"lone-services/services/percutaneous/internal/dao"
"lone-services/services/percutaneous/internal/svc"
jsoniter "github.com/json-iterator/go"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -38,6 +41,17 @@ func (l *GetWsCodeLogic) GetWsCode(in *percutaneous.GetWsCodeRequest) (*percutan
}
key := utils.MD5Encrypt(fmt.Sprintf("%d%s%s", adminInfo.ID, dao.WsCode, Type))
redisKey := pkgws.RedisKeyQRSession + key
payload, err := jsoniter.MarshalToString(pkgws.Session{
Status: pkgws.StatusUsePosition,
ClientCode: key,
})
if err != nil {
return l.fail(utils.Fail)
}
if err := redis.Client.Set(l.ctx, redisKey, payload, pkgws.SessionTTL).Err(); err != nil {
return l.fail(utils.Fail)
}
return l.ok(key)
}
@@ -38,7 +38,7 @@ func (l *SetPositionLogic) SetPosition(in *percutaneous.SetPositionRequest) (*pe
return l.fail(utils.ErrorQRcodeExp)
}
data := map[string]int{"ws_type": pkgws.WsTypeScan}
data := in.Position
if err := pkgws.Publish(l.ctx, in.SessionId, pkgws.Success(data)); err != nil {
l.Errorf("qrcode scan publish: %v", err)
}
@@ -75,10 +75,12 @@ func (l *ConnectLogic) Connect(w http.ResponseWriter, r *http.Request, req *type
func (l *ConnectLogic) pushSnapshot(c *svc.Client, sess *pkgws.Session) error {
var data interface{}
l.Logger.Error(sess.Status)
switch sess.Status {
case pkgws.StatusPending:
data = nil
case pkgws.StatusScanned, pkgws.StatusLogined:
l.Logger.Error("status", sess.Status)
if len(sess.Data) > 0 && string(sess.Data) != "null" {
var parsed any
if err := jsoniter.Unmarshal(sess.Data, &parsed); err != nil {
@@ -92,8 +94,10 @@ func (l *ConnectLogic) pushSnapshot(c *svc.Client, sess *pkgws.Session) error {
data = nil
}
case pkgws.StatusUsePosition:
l.Logger.Error("use position")
if len(sess.Data) > 0 && string(sess.Data) != "null" {
data = sess.Data
l.Logger.Error("data=", data)
} else {
data = nil
}
+1 -1
View File
@@ -18,7 +18,7 @@
host = '39.106.171.204'
password = 'lLMLcuPpzSj'
port = 6379
db = 0
db = 1
[log-redis]
host = '39.106.171.204'