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