Files
gjs a77fa23197
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
fix
2026-10-22 14:30:18 +08:00

58 lines
1.3 KiB
Go

package ws
import (
"encoding/json"
"time"
)
const (
RedisKeyQRSession = "ws:session:"
RedisKeyQRShare = "qr:share:"
RedisKeyOssUpload = "oss:upload:task:"
RedisKeyTaskLights = "task:lights:"
RedisChannelQRPush = "ws:qr:push"
StatusPending = 1 // 待扫码
StatusScanned = 2 // 已扫码未登录
StatusLogined = 3 // 已扫码已登录
StatusUsePosition = 4 //使用位置
WsTypeLogin = 1 // 同意登录
WsTypeScanned = 2 // 拒绝授权 / 拒绝登录
WsTypeScan = 3 // 进入扫码页通知
WsUsePosition = 4 //使用位置
SessionTTL = 5 * time.Minute
CodeOK = 200
MsgOK = "success"
CodeErr = 500
)
type Session struct {
Status int `json:"status"`
ClientCode string `json:"client_code,omitempty"`
Data json.RawMessage `json:"data,omitempty"`
}
type Response struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data"`
}
type Event struct {
SessionID string `json:"session_id"`
Code int `json:"code"`
Message string `json:"message"`
Data json.RawMessage `json:"data"`
}
func Success(data interface{}) Response {
return Response{Code: CodeOK, Message: MsgOK, Data: data}
}
func Fail(msg string) Response {
return Response{Code: CodeErr, Message: msg, Data: nil}
}