chore: sync local changes (2026-03-12)
This commit is contained in:
@@ -1,98 +1,113 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Website 网站信息
|
||||
type Website struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"` // 网站名称
|
||||
Group string `json:"group"` // 所属分组
|
||||
URLs []URLInfo `json:"urls"` // 网站访问地址列表
|
||||
Favicon string `json:"favicon"` // 网站图标URL
|
||||
Title string `json:"title"` // 网站标题
|
||||
CreatedAt time.Time `json:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// URLInfo 单个URL的信息
|
||||
type URLInfo struct {
|
||||
ID string `json:"id"`
|
||||
URL string `json:"url"` // 访问地址
|
||||
Remark string `json:"remark"` // 备注说明
|
||||
}
|
||||
|
||||
// MonitorRecord 监控记录
|
||||
type MonitorRecord struct {
|
||||
WebsiteID string `json:"website_id"`
|
||||
URLID string `json:"url_id"`
|
||||
URL string `json:"url"`
|
||||
StatusCode int `json:"status_code"` // HTTP状态码
|
||||
Latency int64 `json:"latency"` // 延迟(毫秒)
|
||||
IsUp bool `json:"is_up"` // 是否可访问
|
||||
Error string `json:"error"` // 错误信息
|
||||
CheckedAt time.Time `json:"checked_at"` // 检测时间
|
||||
}
|
||||
|
||||
// WebsiteStatus 网站状态(用于前端展示)
|
||||
type WebsiteStatus struct {
|
||||
Website Website `json:"website"`
|
||||
URLStatuses []URLStatus `json:"url_statuses"`
|
||||
Uptime24h float64 `json:"uptime_24h"` // 24小时可用率
|
||||
Uptime7d float64 `json:"uptime_7d"` // 7天可用率
|
||||
LastChecked time.Time `json:"last_checked"` // 最后检测时间
|
||||
}
|
||||
|
||||
// URLStatus 单个URL的状态
|
||||
type URLStatus struct {
|
||||
URLInfo URLInfo `json:"url_info"`
|
||||
CurrentState MonitorRecord `json:"current_state"` // 当前状态
|
||||
History24h []MonitorRecord `json:"history_24h"` // 24小时历史
|
||||
History7d []HourlyStats `json:"history_7d"` // 7天按小时统计
|
||||
Uptime24h float64 `json:"uptime_24h"` // 24小时可用率
|
||||
Uptime7d float64 `json:"uptime_7d"` // 7天可用率
|
||||
AvgLatency int64 `json:"avg_latency"` // 平均延迟
|
||||
}
|
||||
|
||||
// HourlyStats 每小时统计
|
||||
type HourlyStats struct {
|
||||
Hour time.Time `json:"hour"`
|
||||
TotalCount int `json:"total_count"`
|
||||
UpCount int `json:"up_count"`
|
||||
AvgLatency int64 `json:"avg_latency"`
|
||||
Uptime float64 `json:"uptime"`
|
||||
}
|
||||
|
||||
// Group 分组
|
||||
type Group struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// DefaultGroups 默认分组
|
||||
var DefaultGroups = []Group{
|
||||
{ID: "normal", Name: "普通网站"},
|
||||
{ID: "admin", Name: "管理员网站"},
|
||||
}
|
||||
|
||||
// CreateWebsiteRequest 创建网站请求
|
||||
type CreateWebsiteRequest struct {
|
||||
Name string `json:"name" binding:"required"`
|
||||
Group string `json:"group" binding:"required"`
|
||||
URLs []string `json:"urls" binding:"required,min=1"`
|
||||
}
|
||||
|
||||
// UpdateWebsiteRequest 更新网站请求
|
||||
type UpdateWebsiteRequest struct {
|
||||
Name string `json:"name"`
|
||||
Group string `json:"group"`
|
||||
URLs []string `json:"urls"`
|
||||
}
|
||||
|
||||
// APIResponse API响应
|
||||
type APIResponse struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Data interface{} `json:"data,omitempty"`
|
||||
}
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Website 网站信息
|
||||
type Website struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"` // 网站名称
|
||||
Groups []string `json:"groups"` // 所属分组列表(支持多分组)
|
||||
Group string `json:"group,omitempty"` // 已废弃,仅用于旧数据兼容
|
||||
URLs []URLInfo `json:"urls"` // 网站访问地址列表
|
||||
IPAddresses []string `json:"ip_addresses,omitempty"` // 域名解析的IP地址
|
||||
Favicon string `json:"favicon"` // 网站图标URL
|
||||
Title string `json:"title"` // 网站标题
|
||||
CreatedAt time.Time `json:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// URLInfo 单个URL的信息
|
||||
type URLInfo struct {
|
||||
ID string `json:"id"`
|
||||
URL string `json:"url"` // 访问地址
|
||||
Remark string `json:"remark"` // 备注说明
|
||||
}
|
||||
|
||||
// MonitorRecord 监控记录
|
||||
type MonitorRecord struct {
|
||||
WebsiteID string `json:"website_id"`
|
||||
URLID string `json:"url_id"`
|
||||
URL string `json:"url"`
|
||||
StatusCode int `json:"status_code"` // HTTP状态码
|
||||
Latency int64 `json:"latency"` // 延迟(毫秒)
|
||||
IsUp bool `json:"is_up"` // 是否可访问
|
||||
Error string `json:"error"` // 错误信息
|
||||
CheckedAt time.Time `json:"checked_at"` // 检测时间
|
||||
}
|
||||
|
||||
// WebsiteStatus 网站状态(用于前端展示)
|
||||
type WebsiteStatus struct {
|
||||
Website Website `json:"website"`
|
||||
URLStatuses []URLStatus `json:"url_statuses"`
|
||||
DailyHistory []DailyStats `json:"daily_history"` // 90天逐日统计
|
||||
Uptime24h float64 `json:"uptime_24h"` // 24小时可用率
|
||||
Uptime7d float64 `json:"uptime_7d"` // 7天可用率
|
||||
Uptime90d float64 `json:"uptime_90d"` // 90天可用率
|
||||
LastChecked time.Time `json:"last_checked"` // 最后检测时间
|
||||
}
|
||||
|
||||
// URLStatus 单个URL的状态
|
||||
type URLStatus struct {
|
||||
URLInfo URLInfo `json:"url_info"`
|
||||
CurrentState MonitorRecord `json:"current_state"` // 当前状态
|
||||
History24h []MonitorRecord `json:"history_24h"` // 24小时历史
|
||||
History7d []HourlyStats `json:"history_7d"` // 7天按小时统计
|
||||
Uptime24h float64 `json:"uptime_24h"` // 24小时可用率
|
||||
Uptime7d float64 `json:"uptime_7d"` // 7天可用率
|
||||
AvgLatency int64 `json:"avg_latency"` // 平均延迟
|
||||
}
|
||||
|
||||
// HourlyStats 每小时统计
|
||||
type HourlyStats struct {
|
||||
Hour time.Time `json:"hour"`
|
||||
TotalCount int `json:"total_count"`
|
||||
UpCount int `json:"up_count"`
|
||||
AvgLatency int64 `json:"avg_latency"`
|
||||
Uptime float64 `json:"uptime"`
|
||||
}
|
||||
|
||||
// DailyStats 每日统计
|
||||
type DailyStats struct {
|
||||
Date time.Time `json:"date"`
|
||||
TotalCount int `json:"total_count"`
|
||||
UpCount int `json:"up_count"`
|
||||
AvgLatency int64 `json:"avg_latency"`
|
||||
Uptime float64 `json:"uptime"`
|
||||
}
|
||||
|
||||
// Group 分组
|
||||
type Group struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// DefaultGroups 默认分组
|
||||
var DefaultGroups = []Group{
|
||||
{ID: "normal", Name: "普通网站"},
|
||||
{ID: "admin", Name: "管理员网站"},
|
||||
}
|
||||
|
||||
// CreateWebsiteRequest 创建网站请求
|
||||
type CreateWebsiteRequest struct {
|
||||
Name string `json:"name" binding:"required"`
|
||||
Groups []string `json:"groups" binding:"required,min=1"`
|
||||
Group string `json:"group"`
|
||||
URLs []string `json:"urls" binding:"required,min=1"`
|
||||
}
|
||||
|
||||
// UpdateWebsiteRequest 更新网站请求
|
||||
type UpdateWebsiteRequest struct {
|
||||
Name string `json:"name"`
|
||||
Groups []string `json:"groups"`
|
||||
Group string `json:"group"`
|
||||
URLs []string `json:"urls"`
|
||||
}
|
||||
|
||||
// APIResponse API响应
|
||||
type APIResponse struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Data interface{} `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user