mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-08-28 13:03:22 +08:00
This commit is contained in:
19
server/internal/model/input/msgin/auth.go
Normal file
19
server/internal/model/input/msgin/auth.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package msgin
|
||||
|
||||
import "github.com/gogf/gf/v2/os/gtime"
|
||||
|
||||
// AuthSummary 授权摘要
|
||||
type AuthSummary struct {
|
||||
Request
|
||||
}
|
||||
|
||||
// ResponseAuthSummary 响应授权摘要
|
||||
type ResponseAuthSummary struct {
|
||||
Response
|
||||
Data *AuthSummaryData `json:"data,omitempty" description:"数据集"`
|
||||
}
|
||||
|
||||
type AuthSummaryData struct {
|
||||
EndAt *gtime.Time `json:"end_at" description:"授权过期时间"`
|
||||
Online int `json:"online" description:"在线人数"`
|
||||
}
|
61
server/internal/model/input/msgin/common.go
Normal file
61
server/internal/model/input/msgin/common.go
Normal file
@@ -0,0 +1,61 @@
|
||||
package msgin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"hotgo/utility/encrypt"
|
||||
)
|
||||
|
||||
type Request struct {
|
||||
AppId string `json:"appID" v:"0" example:"d0bb93048bc5c9164cdee845dcb7f820" description:"应用ID"`
|
||||
TraceID string `json:"traceID" v:"0" example:"d0bb93048bc5c9164cdee845dcb7f820" description:"链路ID"`
|
||||
Timestamp int64 `json:"timestamp" example:"1640966400" description:"服务器时间戳"`
|
||||
Sign string `json:"sign" example:"d0bb93048bc5c9164cdee845dcb7f820" description:"签名"`
|
||||
}
|
||||
|
||||
func (i *Request) SetSign(traceID, appId, secretKey string) {
|
||||
i.AppId = appId
|
||||
i.TraceID = traceID
|
||||
i.Timestamp = gtime.Timestamp()
|
||||
i.Sign = i.GetSign(secretKey)
|
||||
}
|
||||
|
||||
func (i *Request) GetSign(secretKey string) string {
|
||||
return encrypt.Md5ToString(fmt.Sprintf("%s%s%s%s", i.AppId, i.TraceID, i.Timestamp, secretKey))
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
Code int `json:"code" example:"0" description:"状态码"`
|
||||
Message string `json:"message,omitempty" example:"操作成功" description:"提示消息"`
|
||||
//Data interface{} `json:"data,omitempty" description:"数据集"`
|
||||
}
|
||||
|
||||
// ServerHeartbeat 心跳
|
||||
type ServerHeartbeat struct {
|
||||
}
|
||||
|
||||
// ResponseServerHeartbeat 响应心跳
|
||||
type ResponseServerHeartbeat struct {
|
||||
Response
|
||||
}
|
||||
|
||||
// ServerLogin 服务登录
|
||||
type ServerLogin struct {
|
||||
Request
|
||||
Group string
|
||||
Name string
|
||||
}
|
||||
|
||||
// ResponseServerLogin 响应服务登录
|
||||
type ResponseServerLogin struct {
|
||||
Response
|
||||
}
|
||||
|
||||
// ServerOffline 服务离线
|
||||
type ServerOffline struct {
|
||||
}
|
||||
|
||||
// ResponseServerOffline 响应服务离线
|
||||
type ResponseServerOffline struct {
|
||||
Response
|
||||
}
|
Reference in New Issue
Block a user