Подготовить HY2XS к production-сборке
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package vo
|
||||
|
||||
type AccountVo struct {
|
||||
BaseVo
|
||||
Username string `json:"username"`
|
||||
Quota int64 `json:"quota"`
|
||||
Download int64 `json:"download"`
|
||||
Upload int64 `json:"upload"`
|
||||
ExpireTime int64 `json:"expireTime"`
|
||||
KickUtilTime int64 `json:"kickUtilTime"` // Offline remaining time
|
||||
DeviceNo int64 `json:"deviceNo"` // Limit the number of devices
|
||||
Role string `json:"role"`
|
||||
Deleted int64 `json:"deleted"`
|
||||
|
||||
Online bool `json:"online"` // online status
|
||||
Device int64 `json:"device"` // Number of online devices
|
||||
|
||||
LoginAt int64 `json:"loginAt"`
|
||||
ConAt int64 `json:"conAt"`
|
||||
Remark string `json:"remark"`
|
||||
}
|
||||
type AccountPageVo struct {
|
||||
AccountVos []AccountVo `json:"records"`
|
||||
Total int64 `json:"total"`
|
||||
}
|
||||
|
||||
type AccountInfoVo struct {
|
||||
Id int64 `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Roles []string `json:"roles"`
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package vo
|
||||
|
||||
type ConfigVo struct {
|
||||
Key string `json:"key"`
|
||||
Value string `json:"value"`
|
||||
Remark string `json:"remark"`
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package vo
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type hysteria2Result struct {
|
||||
Ok bool `json:"ok"`
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
func Hysteria2AuthSuccess(id string, c *gin.Context) {
|
||||
c.JSON(http.StatusOK, hysteria2Result{
|
||||
Ok: true,
|
||||
Id: id,
|
||||
})
|
||||
}
|
||||
|
||||
func Hysteria2AuthFail(id string, c *gin.Context) {
|
||||
c.JSON(http.StatusOK, hysteria2Result{
|
||||
Ok: false,
|
||||
Id: id,
|
||||
})
|
||||
}
|
||||
|
||||
type Hysteria2SubscribeVo struct {
|
||||
Url string `json:"url"`
|
||||
QrCode []byte `json:"qrCode"`
|
||||
}
|
||||
|
||||
type Hysteria2UrlVo struct {
|
||||
Url string `json:"url"`
|
||||
QrCode []byte `json:"qrCode"`
|
||||
}
|
||||
|
||||
type Hysteria2AcmePathVo struct {
|
||||
CrtPath string `json:"crtPath"`
|
||||
KeyPath string `json:"keyPath"`
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package vo
|
||||
|
||||
type JwtVo struct {
|
||||
TokenType string `json:"tokenType"`
|
||||
AccessToken string `json:"accessToken"`
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package vo
|
||||
|
||||
type LogSystemPage[T LogSystemVo | LogHysteria2Vo] struct {
|
||||
LogSystemVos []T `json:"records"`
|
||||
Total int64 `json:"total"`
|
||||
}
|
||||
|
||||
type LogSystemVo struct {
|
||||
ClientIP string `json:"clientIp"`
|
||||
LatencyTime int64 `json:"latencyTime"`
|
||||
Level string `json:"level"`
|
||||
Msg string `json:"msg"`
|
||||
ReqMethod string `json:"reqMethod"`
|
||||
ReqUri string `json:"reqUri"`
|
||||
StatusCode int64 `json:"statusCode"`
|
||||
Time string `json:"time"`
|
||||
}
|
||||
|
||||
type LogHysteria2Vo struct {
|
||||
Level string `json:"level"`
|
||||
Msg string `json:"msg"`
|
||||
Time string `json:"time"`
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package vo
|
||||
|
||||
type SystemMonitorVo struct {
|
||||
HUIVersion string `json:"huiVersion"`
|
||||
CpuPercent float64 `json:"cpuPercent"`
|
||||
MemPercent float64 `json:"memPercent"`
|
||||
DiskPercent float64 `json:"diskPercent"`
|
||||
}
|
||||
|
||||
type Hysteria2MonitorVo struct {
|
||||
UserTotal int64 `json:"userTotal"` // 在线用户数
|
||||
DeviceTotal int64 `json:"deviceTotal"` // 在线设备数
|
||||
Version string `json:"version"` // 版本
|
||||
Running bool `json:"running"` // 运行状态
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package vo
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"hy2xs-admin/model/constant"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type result struct {
|
||||
Code int `json:"code"`
|
||||
Type string `json:"type"`
|
||||
Message string `json:"message"`
|
||||
Data interface{} `json:"data"`
|
||||
}
|
||||
|
||||
const (
|
||||
TypeSuccess = "ok"
|
||||
TypeError = "no"
|
||||
)
|
||||
|
||||
func Success(data interface{}, c *gin.Context) {
|
||||
c.JSON(http.StatusOK, result{
|
||||
Code: constant.CodeSuccess,
|
||||
Type: TypeSuccess,
|
||||
Data: data,
|
||||
})
|
||||
}
|
||||
|
||||
func Fail(message string, c *gin.Context) {
|
||||
var code int
|
||||
if constant.UnauthorizedError == message {
|
||||
code = constant.CodeUnauthorizedError
|
||||
} else if constant.ForbiddenError == message {
|
||||
code = constant.CodeForbiddenError
|
||||
} else if constant.InvalidError == message {
|
||||
code = constant.CodeInvalidError
|
||||
} else {
|
||||
code = constant.CodeSysError
|
||||
}
|
||||
c.JSON(http.StatusOK, result{
|
||||
Code: code,
|
||||
Type: TypeError,
|
||||
Message: message,
|
||||
Data: nil,
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package vo
|
||||
|
||||
import "time"
|
||||
|
||||
type BaseVo struct {
|
||||
Id int64 `json:"id"`
|
||||
CreateTime time.Time `json:"createTime"`
|
||||
}
|
||||
Reference in New Issue
Block a user