first commit
This commit is contained in:
16
internal/model/captcha.go
Normal file
16
internal/model/captcha.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Captcha struct {
|
||||
gorm.Model
|
||||
Code string `gorm:"size:6"` // 验证码
|
||||
Type string `gorm:"size:20"` // 验证码类型:register/login/reset
|
||||
Target string `gorm:"size:255"` // 目标(邮箱或手机号)
|
||||
ExpiresAt time.Time `gorm:"index"` // 过期时间
|
||||
Used bool `gorm:"default:false"` // 是否已使用
|
||||
}
|
20
internal/model/chunk.go
Normal file
20
internal/model/chunk.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type UploadChunk struct {
|
||||
gorm.Model
|
||||
FileHash string `gorm:"size:64;index"` // 完整文件的哈希值
|
||||
ChunkNumber int `gorm:"index"` // 分片序号
|
||||
ChunkSize int64 `gorm:""` // 分片大小
|
||||
ChunkPath string `gorm:"size:255"` // 分片存储路径
|
||||
TotalChunks int `gorm:""` // 总分片数
|
||||
TotalSize int64 `gorm:""` // 文件总大小
|
||||
Filename string `gorm:"size:255"` // 原始文件名
|
||||
FileType string `gorm:"size:50"` // 文件类型
|
||||
UploadedBy uint `gorm:"index"` // 上传者ID
|
||||
DeviceUID string `gorm:"size:255;index"` // 关联的设备UID
|
||||
Completed bool `gorm:"default:false"` // 是否已完成合并
|
||||
}
|
13
internal/model/device_log.go
Normal file
13
internal/model/device_log.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type DeviceLog struct {
|
||||
gorm.Model
|
||||
DeviceUID string `gorm:"index" json:"device_uid"` // 设备UID
|
||||
Action string `json:"action"` // 操作类型
|
||||
Message string `json:"message"` // 详细信息
|
||||
Status string `json:"status"` // 状态:success/failed
|
||||
}
|
19
internal/model/device_model.go
Normal file
19
internal/model/device_model.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type DeviceModel struct {
|
||||
gorm.Model
|
||||
ModelName string `gorm:"uniqueIndex" json:"model_name" form:"model_name"` // 设备型号名称
|
||||
DeviceType string `gorm:"size:50" json:"device_type" form:"device_type"` // 设备类型
|
||||
Company string `gorm:"size:255" json:"company" form:"company"` // 所属公司
|
||||
Remark string `gorm:"size:500" json:"remark" form:"remark"` // 备注说明
|
||||
DeviceCount int `gorm:"-" json:"device_count"` // 设备数量(非数据库字段)
|
||||
CreatedBy uint `gorm:"index" json:"created_by"` // 创建者ID
|
||||
CurrentVersion string `gorm:"size:50" json:"current_version"` // 当前版本
|
||||
UpdateURL string `gorm:"size:255" json:"update_url"` // 更新地址
|
||||
UpdateDesc string `gorm:"size:500" json:"update_desc"` // 更新说明
|
||||
Status string `gorm:"size:20;default:active" json:"status"` // 状态:active/disabled
|
||||
}
|
33
internal/model/license.go
Normal file
33
internal/model/license.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type LicenseCode struct {
|
||||
gorm.Model
|
||||
Code string `gorm:"uniqueIndex" json:"code"` // 授权码
|
||||
LicenseType string `gorm:"size:20" json:"license_type"` // 授权类型:time/count/permanent
|
||||
Duration int `json:"duration"` // 授权时长(分钟),仅当类型为time时有效
|
||||
MaxUses int `json:"max_uses"` // 最大使用次数,仅当类型为count时有效
|
||||
UsedCount int `gorm:"default:0" json:"used_count"` // 已使用次数
|
||||
Status string `gorm:"size:20" json:"status"` // 状态:unused/used/expired/revoked
|
||||
UsedBy string `gorm:"index" json:"used_by"` // 使用此授权码的设备UID
|
||||
UsedAt time.Time `json:"used_at"` // 使用时间
|
||||
CreatedBy uint `gorm:"index" json:"created_by"` // 创建者ID
|
||||
BatchNo string `gorm:"size:50;index" json:"batch_no"` // 批次号
|
||||
Remark string `gorm:"size:500" json:"remark"` // 备注
|
||||
BindCount int `gorm:"default:-1" json:"bind_count"` // 可绑定次数,-1表示无限制,0表示不能绑定
|
||||
}
|
||||
|
||||
type LicenseLog struct {
|
||||
gorm.Model
|
||||
LicenseID uint `gorm:"index" json:"license_id"` // 关联的授权码ID
|
||||
DeviceUID string `gorm:"index" json:"device_uid"` // 设备UID
|
||||
Action string `gorm:"size:20" json:"action"` // 操作类型:create/use/verify
|
||||
IP string `gorm:"size:50" json:"ip"` // 操作IP
|
||||
Status string `gorm:"size:20" json:"status"` // 状态:success/failed
|
||||
Message string `gorm:"size:500" json:"message"` // 详细信息
|
||||
}
|
35
internal/model/models.go
Normal file
35
internal/model/models.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Device struct {
|
||||
gorm.Model
|
||||
UID string `gorm:"uniqueIndex" json:"uid"`
|
||||
IPPort string `json:"ip_port"`
|
||||
ChipID string `json:"chip_id"`
|
||||
DeviceType string `json:"device_type"`
|
||||
DeviceModel string `json:"device_model"`
|
||||
Company string `json:"company"`
|
||||
RegisterTime time.Time `json:"register_time"`
|
||||
ExpireTime time.Time `json:"expire_time"`
|
||||
LicenseType string `json:"license_type"`
|
||||
StartCount int `json:"start_count"`
|
||||
Status string `json:"status"`
|
||||
LicenseCode string `json:"license_code"`
|
||||
MaxUses int `json:"max_uses"`
|
||||
Duration int `json:"duration"`
|
||||
LastActiveAt time.Time `json:"last_active_at"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
gorm.Model
|
||||
Username string `gorm:"uniqueIndex" json:"username"`
|
||||
Password string `json:"-"`
|
||||
Email string `gorm:"uniqueIndex" json:"email"`
|
||||
Role string `json:"role"`
|
||||
LastLogin time.Time `json:"last_login"`
|
||||
}
|
127
internal/model/monitor.go
Normal file
127
internal/model/monitor.go
Normal file
@@ -0,0 +1,127 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type SystemStatus struct {
|
||||
CPU struct {
|
||||
Usage float64 `json:"usage"` // CPU使用率
|
||||
|
||||
LoadAvg []float64 `json:"load_avg"` // 系统负载
|
||||
|
||||
CoreCount int `json:"core_count"` // CPU核心数
|
||||
|
||||
ModelName string `json:"model_name"` // CPU型号
|
||||
|
||||
MHz float64 `json:"mhz"` // CPU频率
|
||||
|
||||
} `json:"cpu"`
|
||||
|
||||
Memory struct {
|
||||
Total uint64 `json:"total"` // 总内存
|
||||
|
||||
Used uint64 `json:"used"` // 已用内存
|
||||
|
||||
Free uint64 `json:"free"` // 空闲内存
|
||||
|
||||
UsageRate float64 `json:"usage_rate"` // 使用率
|
||||
|
||||
SwapTotal uint64 `json:"swap_total"` // 交换分区总大小
|
||||
|
||||
SwapUsed uint64 `json:"swap_used"` // 交换分区已用
|
||||
|
||||
SwapFree uint64 `json:"swap_free"` // 交换分区空闲
|
||||
|
||||
SwapUsageRate float64 `json:"swap_usage_rate"` // 交换分区使用率
|
||||
|
||||
} `json:"memory"`
|
||||
|
||||
Disk struct {
|
||||
Partitions []DiskPartition `json:"partitions"` // 磁盘分区信息
|
||||
|
||||
} `json:"disk"`
|
||||
|
||||
Network struct {
|
||||
Interfaces []NetworkInterface `json:"interfaces"` // 网络接口信息
|
||||
|
||||
} `json:"network"`
|
||||
|
||||
Process struct {
|
||||
Total int `json:"total"` // 进程总数
|
||||
|
||||
List []ProcessInfo `json:"list"` // 进程列表(Top N)
|
||||
|
||||
} `json:"process"`
|
||||
|
||||
Host struct {
|
||||
Hostname string `json:"hostname"` // 主机名
|
||||
|
||||
OS string `json:"os"` // 操作系统
|
||||
|
||||
Platform string `json:"platform"` // 平台
|
||||
|
||||
PlatformVersion string `json:"platform_version"` // 平台版本
|
||||
|
||||
KernelVersion string `json:"kernel_version"` // 内核版本
|
||||
|
||||
BootTime time.Time `json:"boot_time"` // 启动时间
|
||||
|
||||
} `json:"host"`
|
||||
|
||||
System struct {
|
||||
Uptime time.Duration `json:"uptime"` // 系统运行时间
|
||||
|
||||
CurrentTime time.Time `json:"current_time"` // 当前时间
|
||||
|
||||
ActiveUsers int `json:"active_users"` // 活跃用户数
|
||||
|
||||
TotalDevices int `json:"total_devices"` // 设备总数
|
||||
|
||||
} `json:"system"`
|
||||
}
|
||||
|
||||
type DiskPartition struct {
|
||||
Device string `json:"device"` // 设备名
|
||||
|
||||
Mountpoint string `json:"mountpoint"` // 挂载点
|
||||
|
||||
Fstype string `json:"fstype"` // 文件系统类型
|
||||
|
||||
Total uint64 `json:"total"` // 总空间
|
||||
|
||||
Used uint64 `json:"used"` // 已用空间
|
||||
|
||||
Free uint64 `json:"free"` // 空闲空间
|
||||
|
||||
UsageRate float64 `json:"usage_rate"` // 使用率
|
||||
|
||||
}
|
||||
|
||||
type NetworkInterface struct {
|
||||
Name string `json:"name"` // 接口名称
|
||||
|
||||
BytesSent uint64 `json:"bytes_sent"` // 发送字节数
|
||||
|
||||
BytesRecv uint64 `json:"bytes_recv"` // 接收字节数
|
||||
|
||||
PacketsSent uint64 `json:"packets_sent"` // 发送包数
|
||||
|
||||
PacketsRecv uint64 `json:"packets_recv"` // 接收包数
|
||||
|
||||
Addrs []string `json:"addrs"` // IP地址列表,改为字符串数组
|
||||
|
||||
}
|
||||
|
||||
type ProcessInfo struct {
|
||||
PID int `json:"pid"` // 进程ID
|
||||
|
||||
Name string `json:"name"` // 进程名称
|
||||
|
||||
CPU float64 `json:"cpu"` // CPU使用率
|
||||
|
||||
Memory float64 `json:"memory"` // 内存使用率
|
||||
|
||||
Created int64 `json:"created"` // 创建时间
|
||||
|
||||
}
|
15
internal/model/reset_token.go
Normal file
15
internal/model/reset_token.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type PasswordResetToken struct {
|
||||
gorm.Model
|
||||
UserID uint `gorm:"index"`
|
||||
Token string `gorm:"uniqueIndex"`
|
||||
ExpiresAt time.Time
|
||||
Used bool
|
||||
}
|
40
internal/model/token.go
Normal file
40
internal/model/token.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type AccessToken struct {
|
||||
gorm.Model
|
||||
Token string `gorm:"uniqueIndex" json:"token"` // 访问令牌
|
||||
DeviceUID string `gorm:"index" json:"device_uid"` // 关联的设备UID
|
||||
Type string `gorm:"size:20" json:"type"` // 令牌类型:api/device
|
||||
Status string `gorm:"size:20" json:"status"` // 状态:active/revoked
|
||||
ExpireTime time.Time `json:"expire_time"` // 过期时间
|
||||
LastUsed time.Time `json:"last_used"` // 最后使用时间
|
||||
UsageCount int `gorm:"default:0" json:"usage_count"` // 使用次数
|
||||
IPList string `gorm:"type:text" json:"ip_list"` // 允许的IP列表,逗号分隔
|
||||
CreatedBy uint `gorm:"index" json:"created_by"` // 创建者ID
|
||||
}
|
||||
|
||||
// TableName 指定表名
|
||||
func (AccessToken) TableName() string {
|
||||
return "access_tokens"
|
||||
}
|
||||
|
||||
type TokenLog struct {
|
||||
gorm.Model
|
||||
TokenID uint `gorm:"index" json:"token_id"` // 关联的令牌ID
|
||||
Action string `gorm:"size:20" json:"action"` // 操作类型:create/use/revoke
|
||||
IP string `gorm:"size:50" json:"ip"` // 操作IP
|
||||
UserAgent string `gorm:"size:255" json:"user_agent"` // User-Agent
|
||||
Status string `gorm:"size:20" json:"status"` // 状态:success/failed
|
||||
Message string `gorm:"size:500" json:"message"` // 详细信息
|
||||
}
|
||||
|
||||
// TableName 指定表名
|
||||
func (TokenLog) TableName() string {
|
||||
return "token_logs"
|
||||
}
|
25
internal/model/upload.go
Normal file
25
internal/model/upload.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type FileUpload struct {
|
||||
gorm.Model
|
||||
FileName string `gorm:"size:255" json:"file_name"` // 文件名
|
||||
FilePath string `gorm:"size:255" json:"file_path"` // 文件路径
|
||||
FileSize int64 `json:"file_size"` // 文件大小
|
||||
FileType string `gorm:"size:50" json:"file_type"` // 文件类型
|
||||
UploadedBy uint `gorm:"index" json:"uploaded_by"` // 上传者ID
|
||||
DeviceModel string `gorm:"size:255;index" json:"device_model"` // 设备型号
|
||||
Version string `gorm:"size:50" json:"version"` // 文件版本
|
||||
Description string `gorm:"size:500" json:"description"` // 文件描述
|
||||
IsUpdate bool `gorm:"default:false" json:"is_update"` // 是否为更新文件
|
||||
Downloads int `gorm:"default:0" json:"downloads"` // 下载次数
|
||||
LastDownload time.Time `json:"last_download"` // 最后下载时间
|
||||
MD5 string `gorm:"size:32" json:"md5"` // 文件MD5值
|
||||
ForceUpdate bool `gorm:"default:false" json:"force_update"` // 是否强制更新
|
||||
DeviceUID string `gorm:"size:255;index" json:"device_uid"` // 关联的设备UID
|
||||
}
|
Reference in New Issue
Block a user