main
parent
421cfb8cfa
commit
f722153536
|
@ -0,0 +1 @@
|
||||||
|
licserver.exe
|
|
@ -275,7 +275,7 @@ paths:
|
||||||
description: 生成数量
|
description: 生成数量
|
||||||
remark:
|
remark:
|
||||||
type: string
|
type: string
|
||||||
description: 备注说明
|
description: <EFBFBD><EFBFBD><EFBFBD>注说明
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: 生成成功
|
description: 生成成功
|
||||||
|
@ -365,6 +365,10 @@ paths:
|
||||||
tags:
|
tags:
|
||||||
- 设备管理
|
- 设备管理
|
||||||
summary: 设备注册
|
summary: 设备注册
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
parameters:
|
parameters:
|
||||||
- in: body
|
- in: body
|
||||||
name: body
|
name: body
|
||||||
|
@ -374,7 +378,6 @@ paths:
|
||||||
required:
|
required:
|
||||||
- uid
|
- uid
|
||||||
- device_model
|
- device_model
|
||||||
- license_code
|
|
||||||
properties:
|
properties:
|
||||||
uid:
|
uid:
|
||||||
type: string
|
type: string
|
||||||
|
@ -384,7 +387,7 @@ paths:
|
||||||
description: 设备型号
|
description: 设备型号
|
||||||
license_code:
|
license_code:
|
||||||
type: string
|
type: string
|
||||||
description: 授权码
|
description: 授权码(可选)
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: 注册成功
|
description: 注册成功
|
||||||
|
@ -393,13 +396,26 @@ paths:
|
||||||
properties:
|
properties:
|
||||||
code:
|
code:
|
||||||
type: integer
|
type: integer
|
||||||
|
example: 0
|
||||||
message:
|
message:
|
||||||
type: string
|
type: string
|
||||||
|
data:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
uid:
|
||||||
|
type: string
|
||||||
|
device_model:
|
||||||
|
type: string
|
||||||
|
status:
|
||||||
|
type: string
|
||||||
400:
|
400:
|
||||||
description: 注册失败
|
description: 请求错误
|
||||||
schema:
|
schema:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
code:
|
||||||
|
type: integer
|
||||||
|
example: -1
|
||||||
error:
|
error:
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
|
|
|
@ -148,13 +148,45 @@ func (h *DeviceHandler) DeleteDevice(c *gin.Context) {
|
||||||
|
|
||||||
func (h *DeviceHandler) RegisterDevice(c *gin.Context) {
|
func (h *DeviceHandler) RegisterDevice(c *gin.Context) {
|
||||||
var input service.DeviceRegisterInput
|
var input service.DeviceRegisterInput
|
||||||
if err := c.ShouldBindJSON(&input); err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
// 检查Content-Type
|
||||||
|
if c.ContentType() != "application/json" {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"error": "Content-Type must be application/json"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 绑定JSON数据
|
||||||
|
if err := c.ShouldBindJSON(&input); err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{
|
||||||
|
"code": -1,
|
||||||
|
"error": "无效的请求数据: " + err.Error(),
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证必填字段
|
||||||
|
if input.UID == "" {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{
|
||||||
|
"code": -1,
|
||||||
|
"error": "设备UID不能为空",
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if input.DeviceModel == "" {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{
|
||||||
|
"code": -1,
|
||||||
|
"error": "设备型号不能为空",
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 注册设备
|
||||||
if err := h.deviceService.RegisterDevice(&input, c.ClientIP()); err != nil {
|
if err := h.deviceService.RegisterDevice(&input, c.ClientIP()); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{
|
||||||
|
"code": -1,
|
||||||
|
"error": err.Error(),
|
||||||
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,6 +198,11 @@ func (h *DeviceHandler) RegisterDevice(c *gin.Context) {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 0,
|
"code": 0,
|
||||||
"message": fmt.Sprintf("设备注册成功,当前状态:%s", status),
|
"message": fmt.Sprintf("设备注册成功,当前状态:%s", status),
|
||||||
|
"data": gin.H{
|
||||||
|
"uid": input.UID,
|
||||||
|
"device_model": input.DeviceModel,
|
||||||
|
"status": status,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,7 @@ func SetupRouter(
|
||||||
api.POST("/captcha/register", userHandler.SendRegisterCaptcha)
|
api.POST("/captcha/register", userHandler.SendRegisterCaptcha)
|
||||||
api.POST("/captcha/reset-password", userHandler.SendResetPasswordCaptcha)
|
api.POST("/captcha/reset-password", userHandler.SendResetPasswordCaptcha)
|
||||||
api.POST("/validate-token", tokenHandler.ValidateToken)
|
api.POST("/validate-token", tokenHandler.ValidateToken)
|
||||||
|
api.POST("/devices/register", deviceHandler.RegisterDevice)
|
||||||
|
|
||||||
// 需要认证的API
|
// 需要认证的API
|
||||||
authorized := api.Group("")
|
authorized := api.Group("")
|
||||||
|
|
|
@ -198,19 +198,12 @@ func (s *MonitorService) getDiskInfo(status *model.SystemStatus) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
status.Disk.Partitions = append(status.Disk.Partitions, model.DiskPartition{
|
status.Disk.Partitions = append(status.Disk.Partitions, model.DiskPartition{
|
||||||
|
|
||||||
Device: partition.Device,
|
Device: partition.Device,
|
||||||
|
|
||||||
Mountpoint: partition.Mountpoint,
|
Mountpoint: partition.Mountpoint,
|
||||||
|
|
||||||
Fstype: partition.Fstype,
|
Fstype: partition.Fstype,
|
||||||
|
|
||||||
Total: usage.Total,
|
Total: usage.Total,
|
||||||
|
|
||||||
Used: usage.Used,
|
Used: usage.Used,
|
||||||
|
|
||||||
Free: usage.Free,
|
Free: usage.Free,
|
||||||
|
|
||||||
UsageRate: usage.UsedPercent,
|
UsageRate: usage.UsedPercent,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -247,13 +240,9 @@ func (s *MonitorService) getNetworkInfo(status *model.SystemStatus) error {
|
||||||
for _, io := range ioCounters {
|
for _, io := range ioCounters {
|
||||||
|
|
||||||
if io.Name == iface.Name {
|
if io.Name == iface.Name {
|
||||||
|
|
||||||
counter = io
|
counter = io
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取接口的地址列表
|
// 获取接口的地址列表
|
||||||
|
|
BIN
licserver.exe
BIN
licserver.exe
Binary file not shown.
|
@ -68,6 +68,8 @@ site:
|
||||||
# Compile program
|
# Compile program
|
||||||
Write-ColorOutput Green "Compiling program..."
|
Write-ColorOutput Green "Compiling program..."
|
||||||
try {
|
try {
|
||||||
|
go env -w GOPROXY=https://goproxy.cn,direct
|
||||||
|
go mod tidy
|
||||||
go build -o licserver.exe cmd/main.go
|
go build -o licserver.exe cmd/main.go
|
||||||
if ($LASTEXITCODE -ne 0) {
|
if ($LASTEXITCODE -ne 0) {
|
||||||
throw "Compilation failed"
|
throw "Compilation failed"
|
||||||
|
|
Loading…
Reference in New Issue