biz

package
v0.0.0-...-d8a4e70 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	ID        uint      `gorm:"primaryKey" json:"id"`
	Slug      string    `gorm:"not null;unique" json:"slug"`
	Channel   string    `gorm:"not null" json:"channel"`
	Version   string    `gorm:"not null" json:"version"`
	Show      bool      `gorm:"not null" json:"show"`
	ShowOrder int       `gorm:"not null" json:"show_order"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type AppRepo

type AppRepo interface {
	All() api.Apps
	Get(slug string) (*api.App, error)
	UpdateExist(slug string) bool
	Installed() ([]*App, error)
	GetInstalled(slug string) (*App, error)
	GetInstalledAll(query string, cond ...string) ([]*App, error)
	GetHomeShow() ([]map[string]string, error)
	IsInstalled(query string, cond ...string) (bool, error)
	Install(channel, slug string) error
	UnInstall(slug string) error
	Update(slug string) error
	UpdateShow(slug string, show bool) error
}

type BackupRepo

type BackupRepo interface {
	List(typ BackupType) ([]*types.BackupFile, error)
	Create(typ BackupType, target string, path ...string) error
	Delete(typ BackupType, name string) error
	Restore(typ BackupType, backup, target string) error
	ClearExpired(path, prefix string, save int) error
	CutoffLog(path, target string) error
	GetPath(typ BackupType) (string, error)
	FixPanel() error
	UpdatePanel(version, url, checksum string) error
}

type BackupType

type BackupType string
const (
	BackupTypePath     BackupType = "path"
	BackupTypeWebsite  BackupType = "website"
	BackupTypeMySQL    BackupType = "mysql"
	BackupTypePostgres BackupType = "postgres"
	BackupTypeRedis    BackupType = "redis"
	BackupTypePanel    BackupType = "panel"
)

type Cache

type Cache struct {
	Key       CacheKey  `gorm:"primaryKey" json:"key"`
	Value     string    `gorm:"not null" json:"value"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type CacheKey

type CacheKey string
const (
	CacheKeyApps     CacheKey = "apps"
	CacheKeyRewrites CacheKey = "rewrites"
)

type CacheRepo

type CacheRepo interface {
	Get(key CacheKey, defaultValue ...string) (string, error)
	Set(key CacheKey, value string) error
	UpdateApps() error
	UpdateRewrites() error
}

type Cert

type Cert struct {
	ID        uint      `gorm:"primaryKey" json:"id"`
	AccountID uint      `gorm:"not null" json:"account_id"` // 关联的 ACME 账户 ID
	WebsiteID uint      `gorm:"not null" json:"website_id"` // 关联的网站 ID
	DNSID     uint      `gorm:"not null" json:"dns_id"`     // 关联的 DNS ID
	Type      string    `gorm:"not null" json:"type"`       // 证书类型 (P256, P384, 2048, 3072, 4096)
	Domains   []string  `gorm:"not null;serializer:json" json:"domains"`
	AutoRenew bool      `gorm:"not null" json:"auto_renew"` // 自动续签
	CertURL   string    `gorm:"not null" json:"cert_url"`   // 证书 URL (续签时使用)
	Cert      string    `gorm:"not null" json:"cert"`       // 证书内容
	Key       string    `gorm:"not null" json:"key"`        // 私钥内容
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`

	Website *Website     `gorm:"foreignKey:WebsiteID" json:"website"`
	Account *CertAccount `gorm:"foreignKey:AccountID" json:"account"`
	DNS     *CertDNS     `gorm:"foreignKey:DNSID" json:"dns"`
}

type CertAccount

type CertAccount struct {
	ID          uint      `gorm:"primaryKey" json:"id"`
	Email       string    `gorm:"not null" json:"email"`
	CA          string    `gorm:"not null" json:"ca"` // CA 提供商 (letsencrypt, zerossl, sslcom, google, buypass)
	Kid         string    `gorm:"not null" json:"kid"`
	HmacEncoded string    `gorm:"not null" json:"hmac_encoded"`
	PrivateKey  string    `gorm:"not null" json:"private_key"`
	KeyType     string    `gorm:"not null" json:"key_type"` // 密钥类型 (P256, P384, 2048, 3072, 4096)
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`

	Certs []*Cert `gorm:"foreignKey:AccountID" json:"-"`
}

type CertAccountRepo

type CertAccountRepo interface {
	List(page, limit uint) ([]*CertAccount, int64, error)
	GetDefault(userID uint) (*CertAccount, error)
	Get(id uint) (*CertAccount, error)
	Create(req *request.CertAccountCreate) (*CertAccount, error)
	Update(req *request.CertAccountUpdate) error
	Delete(id uint) error
}

type CertDNS

type CertDNS struct {
	ID        uint          `gorm:"primaryKey" json:"id"`
	Name      string        `gorm:"not null" json:"name"` // 备注名称
	Type      string        `gorm:"not null" json:"type"` // DNS 提供商 (tencent, aliyun, cloudflare)
	Data      acme.DNSParam `gorm:"not null;serializer:json" json:"dns_param"`
	CreatedAt time.Time     `json:"created_at"`
	UpdatedAt time.Time     `json:"updated_at"`

	Certs []*Cert `gorm:"foreignKey:DNSID" json:"-"`
}

type CertDNSRepo

type CertDNSRepo interface {
	List(page, limit uint) ([]*CertDNS, int64, error)
	Get(id uint) (*CertDNS, error)
	Create(req *request.CertDNSCreate) (*CertDNS, error)
	Update(req *request.CertDNSUpdate) error
	Delete(id uint) error
}

type CertRepo

type CertRepo interface {
	List(page, limit uint) ([]*types.CertList, int64, error)
	Get(id uint) (*Cert, error)
	GetByWebsite(WebsiteID uint) (*Cert, error)
	Upload(req *request.CertUpload) (*Cert, error)
	Create(req *request.CertCreate) (*Cert, error)
	Update(req *request.CertUpdate) error
	Delete(id uint) error
	ObtainAuto(id uint) (*acme.Certificate, error)
	ObtainManual(id uint) (*acme.Certificate, error)
	ObtainSelfSigned(id uint) error
	Renew(id uint) (*acme.Certificate, error)
	ManualDNS(id uint) ([]acme.DNSRecord, error)
	Deploy(ID, WebsiteID uint) error
}

type ContainerImageRepo

type ContainerImageRepo interface {
	List() ([]types.ContainerImage, error)
	Pull(req *request.ContainerImagePull) error
	Remove(id string) error
	Prune() error
}

type ContainerNetworkRepo

type ContainerNetworkRepo interface {
	List() ([]types.ContainerNetwork, error)
	Create(req *request.ContainerNetworkCreate) (string, error)
	Remove(id string) error
	Prune() error
}

type ContainerRepo

type ContainerRepo interface {
	ListAll() ([]types.Container, error)
	ListByName(name string) ([]types.Container, error)
	Create(req *request.ContainerCreate) (string, error)
	Remove(id string) error
	Start(id string) error
	Stop(id string) error
	Restart(id string) error
	Pause(id string) error
	Unpause(id string) error
	Kill(id string) error
	Rename(id string, newName string) error
	Logs(id string) (string, error)
	Prune() error
}

type ContainerVolumeRepo

type ContainerVolumeRepo interface {
	List() ([]types.ContainerVolume, error)
	Create(req *request.ContainerVolumeCreate) (string, error)
	Remove(id string) error
	Prune() error
}

type Cron

type Cron struct {
	ID        uint      `gorm:"primaryKey" json:"id"`
	Name      string    `gorm:"not null;unique" json:"name"`
	Status    bool      `gorm:"not null" json:"status"`
	Type      string    `gorm:"not null" json:"type"`
	Time      string    `gorm:"not null" json:"time"`
	Shell     string    `gorm:"not null" json:"shell"`
	Log       string    `gorm:"not null" json:"log"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type CronRepo

type CronRepo interface {
	Count() (int64, error)
	List(page, limit uint) ([]*Cron, int64, error)
	Get(id uint) (*Cron, error)
	Create(req *request.CronCreate) error
	Update(req *request.CronUpdate) error
	Delete(id uint) error
	Status(id uint, status bool) error
}

type Database

type Database struct {
	Type     DatabaseType `json:"type"`
	Name     string       `json:"name"`
	Server   string       `json:"server"`
	ServerID uint         `json:"server_id"`
	Encoding string       `json:"encoding"`
	Comment  string       `json:"comment"`
}

type DatabaseRepo

type DatabaseRepo interface {
	List(page, limit uint) ([]*Database, int64, error)
	Create(req *request.DatabaseCreate) error
	Delete(serverID uint, name string) error
	Comment(req *request.DatabaseComment) error
}

type DatabaseServer

type DatabaseServer struct {
	ID        uint                 `gorm:"primaryKey" json:"id"`
	Name      string               `gorm:"not null;unique" json:"name"`
	Type      DatabaseType         `gorm:"not null" json:"type"`
	Host      string               `gorm:"not null" json:"host"`
	Port      uint                 `gorm:"not null" json:"port"`
	Username  string               `gorm:"not null" json:"username"`
	Password  string               `gorm:"not null" json:"password"`
	Status    DatabaseServerStatus `gorm:"-:all" json:"status"`
	Remark    string               `gorm:"not null" json:"remark"`
	CreatedAt time.Time            `json:"created_at"`
	UpdatedAt time.Time            `json:"updated_at"`
}

func (*DatabaseServer) AfterFind

func (r *DatabaseServer) AfterFind(tx *gorm.DB) error

func (*DatabaseServer) BeforeSave

func (r *DatabaseServer) BeforeSave(tx *gorm.DB) error

type DatabaseServerRepo

type DatabaseServerRepo interface {
	Count() (int64, error)
	List(page, limit uint) ([]*DatabaseServer, int64, error)
	Get(id uint) (*DatabaseServer, error)
	GetByName(name string) (*DatabaseServer, error)
	Create(req *request.DatabaseServerCreate) error
	Update(req *request.DatabaseServerUpdate) error
	UpdateRemark(req *request.DatabaseServerUpdateRemark) error
	Delete(id uint) error
	ClearUsers(id uint) error
	Sync(id uint) error
}

type DatabaseServerStatus

type DatabaseServerStatus string
const (
	DatabaseServerStatusValid   DatabaseServerStatus = "valid"
	DatabaseServerStatusInvalid DatabaseServerStatus = "invalid"
)

type DatabaseType

type DatabaseType string
const (
	DatabaseTypeMysql      DatabaseType = "mysql"
	DatabaseTypePostgresql DatabaseType = "postgresql"
	DatabaseTypeMongoDB    DatabaseType = "mongodb"
	DatabaseSQLite         DatabaseType = "sqlite"
	DatabaseTypeRedis      DatabaseType = "redis"
)

type DatabaseUser

type DatabaseUser struct {
	ID         uint               `gorm:"primaryKey" json:"id"`
	ServerID   uint               `gorm:"not null" json:"server_id"`
	Username   string             `gorm:"not null" json:"username"`
	Password   string             `gorm:"not null" json:"password"`
	Host       string             `gorm:"not null" json:"host"`    // 仅 mysql
	Status     DatabaseUserStatus `gorm:"-:all" json:"status"`     // 仅显示
	Privileges []string           `gorm:"-:all" json:"privileges"` // 仅显示
	Remark     string             `gorm:"not null" json:"remark"`
	CreatedAt  time.Time          `json:"created_at"`
	UpdatedAt  time.Time          `json:"updated_at"`

	Server *DatabaseServer `gorm:"foreignKey:ServerID;references:ID" json:"server"`
}

func (*DatabaseUser) AfterFind

func (r *DatabaseUser) AfterFind(tx *gorm.DB) error

func (*DatabaseUser) BeforeSave

func (r *DatabaseUser) BeforeSave(tx *gorm.DB) error

type DatabaseUserRepo

type DatabaseUserRepo interface {
	Count() (int64, error)
	List(page, limit uint) ([]*DatabaseUser, int64, error)
	Get(id uint) (*DatabaseUser, error)
	Create(req *request.DatabaseUserCreate) error
	Update(req *request.DatabaseUserUpdate) error
	UpdateRemark(req *request.DatabaseUserUpdateRemark) error
	Delete(id uint) error
	DeleteByNames(serverID uint, names []string) error
}

type DatabaseUserStatus

type DatabaseUserStatus string
const (
	DatabaseUserStatusValid   DatabaseUserStatus = "valid"
	DatabaseUserStatusInvalid DatabaseUserStatus = "invalid"
)

type Monitor

type Monitor struct {
	ID        uint              `gorm:"primaryKey" json:"id"`
	Info      types.CurrentInfo `gorm:"not null;serializer:json" json:"info"`
	CreatedAt time.Time         `json:"created_at"`
	UpdatedAt time.Time         `json:"updated_at"`
}

type MonitorRepo

type MonitorRepo interface {
	GetSetting() (*request.MonitorSetting, error)
	UpdateSetting(setting *request.MonitorSetting) error
	Clear() error
	List(start, end time.Time) ([]*Monitor, error)
}

type SSH

type SSH struct {
	ID        uint             `gorm:"primaryKey" json:"id"`
	Name      string           `gorm:"not null" json:"name"`
	Host      string           `gorm:"not null" json:"host"`
	Port      uint             `gorm:"not null" json:"port"`
	Config    ssh.ClientConfig `gorm:"not null;serializer:json" json:"config"`
	Remark    string           `gorm:"not null" json:"remark"`
	CreatedAt time.Time        `json:"created_at"`
	UpdatedAt time.Time        `json:"updated_at"`
}

func (*SSH) AfterFind

func (r *SSH) AfterFind(tx *gorm.DB) error

func (*SSH) BeforeSave

func (r *SSH) BeforeSave(tx *gorm.DB) error

type SSHRepo

type SSHRepo interface {
	List(page, limit uint) ([]*SSH, int64, error)
	Get(id uint) (*SSH, error)
	Create(req *request.SSHCreate) error
	Update(req *request.SSHUpdate) error
	Delete(id uint) error
}

type SafeRepo

type SafeRepo interface {
	GetSSH() (uint, bool, error)
	UpdateSSH(port uint, status bool) error
	GetPingStatus() (bool, error)
	UpdatePingStatus(status bool) error
}

type Setting

type Setting struct {
	ID        uint       `gorm:"primaryKey" json:"id"`
	Key       SettingKey `gorm:"not null;unique" json:"key"`
	Value     string     `gorm:"not null" json:"value"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
}

type SettingKey

type SettingKey string
const (
	SettingKeyName              SettingKey = "name"
	SettingKeyVersion           SettingKey = "version"
	SettingKeyMonitor           SettingKey = "monitor"
	SettingKeyMonitorDays       SettingKey = "monitor_days"
	SettingKeyBackupPath        SettingKey = "backup_path"
	SettingKeyWebsitePath       SettingKey = "website_path"
	SettingKeyMySQLRootPassword SettingKey = "mysql_root_password"
	SettingKeyOfflineMode       SettingKey = "offline_mode"
)

type SettingRepo

type SettingRepo interface {
	Get(key SettingKey, defaultValue ...string) (string, error)
	GetBool(key SettingKey, defaultValue ...bool) (bool, error)
	Set(key SettingKey, value string) error
	Delete(key SettingKey) error
	GetPanelSetting(ctx context.Context) (*request.PanelSetting, error)
	UpdatePanelSetting(ctx context.Context, setting *request.PanelSetting) (bool, error)
}

type Task

type Task struct {
	ID        uint       `gorm:"primaryKey" json:"id"`
	Name      string     `gorm:"not null;index" json:"name"`
	Status    TaskStatus `gorm:"not null;default:'waiting'" json:"status"`
	Shell     string     `gorm:"not null" json:"-"`
	Log       string     `gorm:"not null" json:"log"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
}

type TaskRepo

type TaskRepo interface {
	HasRunningTask() bool
	List(page, limit uint) ([]*Task, int64, error)
	Get(id uint) (*Task, error)
	Delete(id uint) error
	UpdateStatus(id uint, status TaskStatus) error
	Push(task *Task) error
}

type TaskStatus

type TaskStatus string
const (
	TaskStatusWaiting TaskStatus = "waiting"
	TaskStatusRunning TaskStatus = "running"
	TaskStatusSuccess TaskStatus = "finished"
	TaskStatusFailed  TaskStatus = "failed"
)

type User

type User struct {
	ID        uint           `gorm:"primaryKey" json:"id"`
	Username  string         `gorm:"not null;unique" json:"username"`
	Password  string         `gorm:"not null" json:"password"`
	Email     string         `gorm:"not null" json:"email"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at"`
}

type UserRepo

type UserRepo interface {
	Create(username, password string) (*User, error)
	CheckPassword(username, password string) (*User, error)
	Get(id uint) (*User, error)
	Save(user *User) error
}

type Website

type Website struct {
	ID        uint      `gorm:"primaryKey" json:"id"`
	Name      string    `gorm:"not null;unique" json:"name"`
	Status    bool      `gorm:"not null;default:true" json:"status"`
	Path      string    `gorm:"not null" json:"path"`
	Https     bool      `gorm:"not null" json:"https"`
	Remark    string    `gorm:"not null" json:"remark"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`

	Cert *Cert `gorm:"foreignKey:WebsiteID" json:"cert"`
}

type WebsiteRepo

type WebsiteRepo interface {
	GetRewrites() (map[string]string, error)
	UpdateDefaultConfig(req *request.WebsiteDefaultConfig) error
	Count() (int64, error)
	Get(id uint) (*types.WebsiteSetting, error)
	GetByName(name string) (*types.WebsiteSetting, error)
	List(page, limit uint) ([]*Website, int64, error)
	Create(req *request.WebsiteCreate) (*Website, error)
	Update(req *request.WebsiteUpdate) error
	Delete(req *request.WebsiteDelete) error
	ClearLog(id uint) error
	UpdateRemark(id uint, remark string) error
	ResetConfig(id uint) error
	UpdateStatus(id uint, status bool) error
	ObtainCert(ctx context.Context, id uint) error
}

Jump to

Keyboard shortcuts

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