models

package
v1.13.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Activity

type Activity struct {
	ID int `gorm:"primaryKey;not null" json:"-"`
	// User 是觸發此事件之使用者的 UUID,若此事件無法對應到特定使用者,
	// 則為空字串,此時將視為系統使用者所觸發。
	User JsonNullString `gorm:"type:uuid" json:"user"`
	// Server 是此事件所關聯之伺服器的 UUID。
	Server string `gorm:"type:uuid;not null" json:"server"`
	// Event 是描述發生了什麼事的字串,供 Panel 實例用來在活動記錄中
	// 正確地對應此事件。
	Event Event `gorm:"index;not null" json:"event"`
	// Metadata 可以是空值、字串,或是提供額外事件特定中繼資料的 JSON 資料。
	Metadata ActivityMeta `gorm:"serializer:json" json:"metadata"`
	// IP 是觸發此事件的 IP 位址,若無法正確判斷則為空字串。此值應為
	// 連線使用者的 IP 位址,而非內部系統的 IP。
	IP        string    `gorm:"not null" json:"ip"`
	Timestamp time.Time `gorm:"not null" json:"timestamp"`
}

Activity 定義使用者對某伺服器實體所執行的活動記錄事件。這用於追蹤 指令、電源操作與 SFTP 事件,以便進行整合並回傳給 Panel 實例顯示給使用者。

func (*Activity) BeforeCreate

func (a *Activity) BeforeCreate(_ *gorm.DB) error

BeforeCreate 會在建立任何活動記錄之前執行,以確保 IP 位址 已去除多餘的資料,並將時間戳設定為目前的系統時間,再以 UTC 儲存。

func (Activity) SetUser

func (a Activity) SetUser(u string) *Activity

SetUser 設定執行此動作的目前使用者。若傳入空字串,儲存時會將其 轉換為空值。

type ActivityMeta

type ActivityMeta map[string]interface{}

type Event

type Event string

type JsonNullString

type JsonNullString struct {
	sql.NullString
}

func (JsonNullString) MarshalJSON

func (v JsonNullString) MarshalJSON() ([]byte, error)

func (*JsonNullString) UnmarshalJSON

func (v *JsonNullString) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL