models

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(db *gorm.DB) error

Migrate 迁移模型,通过依赖注入的方式,使用gorm.DB进行数据库操作 Migrate models, using gorm.DB for database operations through dependency injection

Types

type ApiToken

type ApiToken struct {
	gorm.Model
	UserID    uint
	Token     string
	ExpiresAt time.Time
}

type File

type File struct {
	gorm.Model
	ID         uint   `gorm:"primaryKey"` // 文件ID File ID
	Hash       string `gorm:"not null"`   // 文件哈希值 File hash
	UploaderID uint   `gorm:"not null"`   // 上传者ID Uploader ID
}

func (File) TableName

func (File) TableName() string

TableName 自定义表名 Custom table name

type JsonWebToken

type JsonWebToken struct {
	gorm.Model
	UserID uint
}

type Node

type Node struct {
	gorm.Model
	Token string `gorm:"unique;not null"` // 节点创建Token
	Name  string `gorm:"not null"`        // 节点名称
	Host  string `gorm:"not null"`
	Port  int    `gorm:"not null"`
}

type OIDCConfig

type OIDCConfig struct {
	gorm.Model
	Name        string                       `gorm:"uniqueIndex"`
	AdminGroups orm.GenericJsonArray[string] `gorm:"type:json;column:admin_groups;default:'[]'"` // 平台管理员组,默认为:[]string{},*为匹配所有组,储存为逗号分隔的字符串
	// Admin groups, default is: []string{}, * matches all groups, stored as a comma-separated string
	AllowedGroups orm.GenericJsonArray[string] `gorm:"type:json;column:allowed_groups;default:'[\"*\"]'"` // 允许登录的组,默认为:[]string{"*"},*为匹配所有组,储存为逗号分隔的字符串
	// Allowed groups for login, default is: []string{"*"}, * matches all groups, stored as a comma-separated string
	ClientID string `gorm:"column:client_id"` // 客户端ID
	// Client ID
	ClientSecret string `gorm:"column:client_secret"` // 客户端密钥
	// Client Secret
	DisplayName string `gorm:"column:display_name"` // 显示名称,例如:轻雪通行证
	// Display name, e.g., Light Snow Passport
	GroupsClaim *string `gorm:"default:groups"` // 组声明,默认为:"groups"
	// Groups claim, default is: "groups"
	Icon *string `gorm:"column:icon"` // 图标url,为空则使用内置默认图标
	// Icon URL, if empty use the built-in default icon
	OidcDiscoveryUrl string `gorm:"column:oidc_discovery_url"` // OpenID自动发现URL,例如 :https://pass.liteyuki.icu/.well-known/openid-configuration
	// OpenID auto-discovery URL, e.g., https://pass.liteyuki.icu/.well-known/openid-configuration
	Enabled bool `gorm:"column:enabled;default:true"` // 是否启用

	// 以下为自动获取字段
	Issuer                string
	AuthorizationEndpoint string
	TokenEndpoint         string
	UserInfoEndpoint      string
	JwksUri               string
	RedirectUrl           string `gorm:"column:redirect_url"` // 自动生成
}

func (OIDCConfig) TableName

func (OIDCConfig) TableName() string

TableName 重写表名 Rewrite table name

type Organization

type Organization struct {
	gorm.Model
	Name         string  `gorm:"not null;uniqueIndex"`            // 组织的唯一名称 Organization's unique name
	DisplayName  *string `gorm:"column:display_name"`             // 组织的显示名称 Organization's display name
	Email        *string `gorm:"column:email"`                    // 组织的电子邮件地址 Organization's email address
	Description  string  `gorm:"default:'No description.'"`       // 组织描述 Organization description
	AvatarURL    *string `gorm:"column:avatar_url"`               // 留空以使用 Gravatar Leave blank to use Gravatar
	Members      []*User `gorm:"many2many:organization_members;"` // 组织的成员包含创建者 (including the creator)
	Owners       []User  `gorm:"many2many:organization_owners;"`  // 组织的所有者(无反向关系)包含创建者 (including the creator)
	IsPrivate    bool    `gorm:"default:false"`                   // 组织是否为私有组织,默认为 false,表示公开组织 Whether the organization is a private organization, default is false, meaning public organization
	ProjectLimit int     `gorm:"default:0"`                       // 组织的项目限制,0:遵循策略,-1:无限制 Organization's project limit, 0: follow the policy, -1: unlimited
}

Organization 组织模型

func (Organization) TableName

func (Organization) TableName() string

type Permission

type Permission struct {
	gorm.Model
	TargetType string
	TargetID   uint
}

type Project

type Project struct {
	gorm.Model
	Name        string  `gorm:"not null"`                   // 项目在一个主体下的唯一名称 Project's unique name
	DisplayName *string `gorm:"column:display_name"`        // 项目的显示名称 Project's display name
	Description string  `gorm:"default:'No description.'"`  // 项目描述 Project description
	OwnerID     uint    `gorm:"not null"`                   // 所有者 ID(用户 ID 或组织 ID) Owner ID (user ID or organization ID)
	OwnerType   string  `gorm:"not null"`                   // 所有者类型,可以是用户或组织 Owner type, can be user or organization
	Owners      []User  `gorm:"many2many:project_owners;"`  // 项目的所有者,无反向关系 Project's owners, no reverse relation
	Members     []*User `gorm:"many2many:project_members;"` // 项目的成员 Project's members
	SiteLimit   int     `gorm:"default:0"`                  // 项目的站点限制,0:遵循策略,-1:无限制 Project's site limit, 0: follow the policy, -1: unlimited
	IsPrivate   bool    `gorm:"default:false"`
}

Project 项目模型

func (Project) TableName

func (Project) TableName() string

type Site

type Site struct {
	gorm.Model
	Name        string   `gorm:"unique"`                                                            // 站点名称 Site name
	Description string   `gorm:"size:255"`                                                          // 站点描述 Site description
	ProjectID   uint     `gorm:"not null"`                                                          // 项目ID Project ID
	Project     Project  `gorm:"foreignKey:ProjectID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"` // 项目 Project
	SubDomain   string   `gorm:"unique;size:255"`                                                   // 子域前缀 Subdomain prefix
	Domains     []string `gorm:"type:json;default:'[]'"`                                            // 允许的域名,json格式 Allowed domains, json format
}

func (Site) TableName

func (Site) TableName() string

type SiteRelease

type SiteRelease struct {
	gorm.Model
	SiteID uint   `gorm:"not null"` // 站点ID Site ID
	Site   Site   `gorm:"foreignKey:SiteID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	Tag    string `gorm:"not null"`                                                        // 版本标签 Version tag
	FileID uint   `gorm:"not null"`                                                        // 版本文件ID Version file ID
	File   File   `gorm:"foreignKey:FileID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL"` // 版本文件 Version file
}

func (SiteRelease) TableName

func (SiteRelease) TableName() string

type User

type User struct {
	gorm.Model
	Name          string          `gorm:"not null;uniqueIndex"`            // 用户的唯一名称 User's unique name
	DisplayName   *string         `gorm:"column:display_name"`             // 用户的显示名称 User's display name
	Email         *string         `gorm:"unique"`                          // 用户的电子邮件地址,只有用户的电子邮件地址是唯一的(用于 oidc 身份验证) User's email address, only the user's email address is unique (used for oidc authentication)
	Description   string          `gorm:"default:'No description.'"`       // 用户描述 User description
	AvatarURL     *string         `gorm:"column:avatar_url"`               // 留空以使用 Gravatar Leave blank to use Gravatar
	Role          string          `gorm:"not null;default:user"`           // 用户的全局角色 User's global role
	Organizations []*Organization `gorm:"many2many:organization_members;"` // 隶属于许多组织 Many organizations the user belongs to
	ProjectLimit  int             `gorm:"default:-1"`                      // 用户的项目限制,0 表示无限制 User's project limit, 0 means no limit
	Language      string          `gorm:"default:'zh-cn'"`                 // 用户的语言,默认为英语 User's language, default to English
	Flag          string          `gorm:"default:'0'"`                     // system_admin 的另一面旗帜 The other side of system_admin flag
	IsPrivate     bool            `gorm:"default:false"`                   // 用户是否为私有用户,默认为 false,表示公开用户 Whether the user is a private user, default is false, meaning public user
	Password      *string         `gorm:"column:password"`                 // 用户的密码(经过哈希处理),仅用于本地身份验证 User's password (hashed), only used for local authentication
}

User 用户模型

func (User) TableName

func (User) TableName() string

Jump to

Keyboard shortcuts

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