Files
opsx-licence/backend/internal/model/sync.go
T

30 lines
1.2 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package model
import "time"
// Peer 节点状态:pending 已配置未握手,active 握手成功可同步,disabled 手动停用 // Logan.Li
const (
PeerStatusPending = "pending"
PeerStatusActive = "active"
PeerStatusDisabled = "disabled"
)
// PeerNode 互联节点:双向授权同步的对端(地址 + 互联密钥 + 游标) // Logan.Li
type PeerNode struct {
ID uint `json:"id" gorm:"primaryKey"`
Name string `json:"name" gorm:"size:100;not null"`
BaseURL string `json:"base_url" gorm:"size:255;not null"` // 对端 https 地址(含 /api)
SharedKey string `json:"-" gorm:"size:128;not null"` // 互联密钥,双向一致,HMAC 签名用
Status string `json:"status" gorm:"size:20;default:'pending'"`
RemoteNode string `json:"remote_node" gorm:"size:64"` // 对端节点 ID,握手后回填
LastSyncAt *time.Time `json:"last_sync_at,omitempty"` // 本地对端同步游标(增量起点)
LastResult string `json:"last_result" gorm:"size:255"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// TableName 指定表名 // Logan.Li
func (PeerNode) TableName() string {
return "peer_nodes"
}