types

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

types 包提供 Leros 的核心数据类型定义

该包定义了数字助手、事件、用户、技能等核心领域模型, 以及相关的常量和数据库表名定义。

types 包提供 Leros 的核心数据类型定义

该包定义了数字助手、事件、用户、技能等核心领域模型, 以及相关的常量和数据库表名定义。

types 包提供 Leros 的核心数据类型定义

该包定义了数字助手、事件、用户、技能等核心领域模型, 以及相关的常量和数据库表名定义。

types 包提供 Leros 的核心数据类型定义

该包定义了数字助手、事件、用户、技能等核心领域模型, 以及相关的常量和数据库表名定义。

types 包提供 Leros 的核心数据类型定义

该包定义了数字助手、事件、用户、技能等核心领域模型, 以及相关的常量和数据库表名定义。

types 包提供 Leros 的核心数据类型定义

该包定义了数字助手、事件、用户、技能等核心领域模型, 以及相关的常量和数据库表名定义。

types 包提供 Leros 的核心数据类型定义

该包定义了数字助手、事件、用户、技能等核心领域模型, 以及相关的常量和数据库表名定义。

types 包提供 Leros 的核心数据类型定义

该包定义了数字助手、事件、用户、技能等核心领域模型, 以及相关的常量和数据库表名定义。

Index

Constants

View Source
const (
	SystemUin   uint = 1
	SystemOrgID uint = 1
)
View Source
const (

	// TableNameUser 用户表名
	TableNameUser = tablenamePrefix + "user"
	// TableNameOrganization 组织表名
	TableNameOrganization = tablenamePrefix + "organization"
	// TableNameUserOrg 用户组织关联表名
	TableNameUserOrg = tablenamePrefix + "user_org"
	// TableNameAuthRefreshToken 登录刷新令牌表名
	TableNameAuthRefreshToken = tablenamePrefix + "auth_refresh_token"
	// TableNameAuthLoginAttempt 登录失败尝试表名
	TableNameAuthLoginAttempt = tablenamePrefix + "auth_login_attempt"

	// TableNameDigitalAssistant 数字助手表名
	TableNameDigitalAssistant = tablenamePrefix + "digital_assistant"
	// TableNameDigitalAssistantInstance 数字助手实例表名
	TableNameDigitalAssistantInstance = tablenamePrefix + "digital_assistant_instance"

	// TableNameEvent 事件表名
	TableNameEvent = tablenamePrefix + "event"

	// TableNameSkill 技能表名
	TableNameSkill = tablenamePrefix + "skill"
	// TableNameSkillLog 技能执行日志表名
	TableNameSkillLog = tablenamePrefix + "skill_execution_log"
	// TableNameSkillRegistry 技能注册表名
	TableNameSkillRegistry = tablenamePrefix + "skill_registry"

	// TableNameSession 会话表名
	TableNameSession = tablenamePrefix + "session"
	// TableNameSessionMessage 会话消息表名
	TableNameSessionMessage = tablenamePrefix + "session_message"

	// TableNameLLMModel LLM模型配置表名
	TableNameLLMModel = tablenamePrefix + "llm_model"

	// TableNameProject 项目表名
	TableNameProject = tablenamePrefix + "project"
	// TableNameProjectMember 项目成员表名
	TableNameProjectMember = tablenamePrefix + "project_member"

	// TableNameTask 任务表名
	TableNameTask = tablenamePrefix + "task"

	// TableNameArtifact 任务产出物表名
	TableNameArtifact = tablenamePrefix + "artifact"

	// TableNameFileUpload 文件上传表名
	TableNameFileUpload = tablenamePrefix + "file_upload"
	// TableNameBuiltinSkillMarketplaceItem 内置 Skill 市场条目表名
	TableNameBuiltinSkillMarketplaceItem = tablenamePrefix + "builtin_skill_marketplace_item"
)

数据库表名常量定义

View Source
const (
	DefaultPageSize = 10
	PageMaxCount    = 150
)

分页默认值

Variables

This section is empty.

Functions

This section is empty.

Types

type Artifact

type Artifact struct {
	gorm.Model
	PublicID string `gorm:"column:public_id;type:varchar(255);not null;uniqueIndex"`
	OrgID    uint   `gorm:"column:org_id;type:integer;not null;index"`
	OwnerID  uint   `gorm:"column:owner_id;type:bigint;not null;index"`
	TaskID   uint   `gorm:"column:task_id;type:bigint;not null;index"`

	// ProjectID 关联项目(冗余字段,便于项目资产聚合查询)
	ProjectID uint  `gorm:"column:project_id;type:bigint;not null;index"`
	SessionID *uint `gorm:"column:session_id;type:bigint;index"`
	MessageID *uint `gorm:"column:message_id;type:bigint;index"`

	Title       string `gorm:"column:title;type:varchar(500);not null"`
	Filename    string `gorm:"column:filename;type:varchar(500)"`
	Description string `gorm:"column:description;type:text"`

	// ArtifactType 产出物类型,使用 ArtifactType 常量值
	ArtifactType string `gorm:"column:artifact_type;type:varchar(50);not null;index"`

	// FileURL 文件链接或路径
	FileURL      string `gorm:"column:file_url;type:varchar(2000);not null"`
	FilePublicID string `gorm:"column:file_public_id;type:varchar(255);index"`
	MimeType     string `gorm:"column:mime_type;type:varchar(100)"`
	FileSize     int64  `gorm:"column:file_size;type:bigint"`
	RelativePath string `gorm:"column:relative_path;type:varchar(2000)"`
	StorageKey   string `gorm:"column:storage_key;type:varchar(500);index"`
	Sha256       string `gorm:"column:sha256;type:varchar(64);index"`
	Source       string `gorm:"column:source;type:varchar(50);not null;default:'agent_declared';index"`

	// ExportFormat 导出格式:markdown / pdf / word / html
	ExportFormat string `gorm:"column:export_format;type:varchar(50)"`

	// Version 版本号,从 1 起递增
	Version  int   `gorm:"column:version;type:integer;not null;default:1"`
	ParentID *uint `gorm:"column:parent_id;type:bigint"`

	// Status 状态,使用 ArtifactStatus 常量值
	Status string `gorm:"column:status;type:varchar(50);not null;default:'completed';index"`

	Metadata ObjectMetadata `gorm:"column:metadata;type:jsonb"`
}

Artifact 表示任务产出物(交付件)

Artifact 是任务执行后的产出物记录。每个 Artifact 必须关联一个 Task, project_id 为冗余字段便于项目资产聚合查询。Artifact 不存储 inline 内容正文, 统一以 file_url 指向文件路径或存储链接。 通过 version + parent_id 构建版本链,支持产出物变更追溯。

func (Artifact) TableName

func (Artifact) TableName() string

TableName 指定 Artifact 结构体对应的数据库表名

type ArtifactSource

type ArtifactSource string

ArtifactSource 表示产出物记录来源。

const (
	// ArtifactSourceAgentDeclared 表示 Agent 通过 manifest 显式声明的产物。
	ArtifactSourceAgentDeclared ArtifactSource = "agent_declared"
	// ArtifactSourceDiff 表示通过执行前后文件变更自动检测到的产物。
	ArtifactSourceDiff ArtifactSource = "diff"
)

type ArtifactStatus

type ArtifactStatus string

ArtifactStatus 表示产出物的状态

const (
	// ArtifactStatusGenerating 产出物生成中
	ArtifactStatusGenerating ArtifactStatus = "generating"
	// ArtifactStatusCompleted 产出物已完成
	ArtifactStatusCompleted ArtifactStatus = "completed"
	// ArtifactStatusFailed 产出物生成失败
	ArtifactStatusFailed ArtifactStatus = "failed"
)

type ArtifactType

type ArtifactType string

ArtifactType 表示产出物的类型

const (
	// ArtifactTypeText 文本内容(文档、代码、报告等)
	ArtifactTypeText ArtifactType = "text"
	// ArtifactTypeStructuredData 结构化数据(JSON、表格、CSV)
	ArtifactTypeStructuredData ArtifactType = "structured_data"
	// ArtifactTypeFile 文件附件(图片、压缩包、二进制)
	ArtifactTypeFile ArtifactType = "file"
	// ArtifactTypeComposite 复合产物(多种类型混合)
	ArtifactTypeComposite ArtifactType = "composite"
)

type AuthLoginAttempt

type AuthLoginAttempt struct {
	gorm.Model
	Identifier      string    `gorm:"column:identifier;type:varchar(255);uniqueIndex;not null"`
	FailureCount    int       `gorm:"column:failure_count;type:integer;default:0;not null"`
	WindowExpiresAt time.Time `gorm:"column:window_expires_at;index;not null"`
}

AuthLoginAttempt stores failed login counters in a rolling window.

func (AuthLoginAttempt) TableName

func (AuthLoginAttempt) TableName() string

TableName 指定AuthLoginAttempt结构体对应的数据库表名。

type AuthRefreshToken

type AuthRefreshToken struct {
	gorm.Model
	TokenHash string     `gorm:"column:token_hash;type:varchar(64);uniqueIndex;not null"`
	UserID    uint       `gorm:"column:user_id;type:bigint;index;not null"`
	ExpiresAt time.Time  `gorm:"column:expires_at;index;not null"`
	RevokedAt *time.Time `gorm:"column:revoked_at;index"`
}

AuthRefreshToken stores a hashed refresh token for local account sessions.

func (AuthRefreshToken) TableName

func (AuthRefreshToken) TableName() string

TableName 指定AuthRefreshToken结构体对应的数据库表名。

type AuthState

type AuthState int

AuthState 认证状态

const (
	AuthStateNil    AuthState = 0
	AuthStateSucc   AuthState = 1
	AuthStateFailed AuthState = 2
)

type BuiltinSkillMarketplaceItem added in v0.1.1

type BuiltinSkillMarketplaceItem struct {
	gorm.Model

	// SkillID 是内置 Skill 的唯一业务编码。
	SkillID string `gorm:"column:skill_id;type:varchar(100);not null;uniqueIndex:idx_builtin_skill_id_version" json:"skill_id"`

	// Name 是 Skill 在市场页面展示的名称。
	Name string `gorm:"column:name;type:varchar(255);not null" json:"name"`

	// Description 是 Skill 的简短说明。
	Description string `gorm:"column:description;type:text" json:"description"`

	// Version 是当前发布版本。
	Version string `gorm:"column:version;type:varchar(50);not null;uniqueIndex:idx_builtin_skill_id_version" json:"version"`

	// Author 是 Skill 作者或发布方。
	Author string `gorm:"column:author;type:varchar(255);not null;default:Leros" json:"author"`

	// Category 是 Skill 分类。
	Category string `gorm:"column:category;type:varchar(100);not null;index" json:"category"`

	// Tags 是 Skill 标签列表。
	Tags SkillStringList `gorm:"column:tags;type:jsonb" json:"tags"`

	// Icon 是 Skill 图标地址或内置图标标识。
	Icon string `gorm:"column:icon;type:varchar(1000)" json:"icon"`

	// LocalPath 是内置 Skill 在服务端的本地路径或打包路径。
	LocalPath string `gorm:"column:local_path;type:varchar(1000);not null" json:"local_path"`

	// PackageSHA256 是内置 Skill 包的 SHA256 校验值。
	PackageSHA256 string `gorm:"column:package_sha256;type:char(64)" json:"package_sha256"`

	// Verified 表示该 Skill 是否经过官方验证。
	Verified bool `gorm:"column:verified;type:boolean;not null;default:true" json:"verified"`

	// Status 表示市场条目状态:active、deprecated、hidden。
	Status string `gorm:"column:status;type:varchar(50);not null;default:active;index" json:"status"`

	// PublishedAt 是该 Skill 发布到市场的时间。
	PublishedAt *time.Time `gorm:"column:published_at" json:"published_at"`

	// Installs 是下载量/安装量计数。
	Installs int64 `gorm:"column:installs;type:bigint;not null;default:0" json:"installs"`
}

BuiltinSkillMarketplaceItem 内置 Skill 市场条目。

func (BuiltinSkillMarketplaceItem) TableName added in v0.1.1

func (BuiltinSkillMarketplaceItem) TableName() string

TableName 返回数据库表名。

type Caller

type Caller struct {
	Uin   uint      `json:"uin"`
	OrgID uint      `json:"org_id"`
	State AuthState `json:"state"`
}

Caller 定义了一个执行身份,包含用户 ID、租户 ID 和认证状态。

func SystemIdentity

func SystemIdentity() *Caller

SystemIdentity 返回一个预定义的系统身份,通常用于系统内部调用或没有特定用户上下文的场景。

type ChannelType

type ChannelType string

ChannelType 表示渠道类型标识

const (
	// ChannelTypeGitHub 表示GitHub渠道
	ChannelTypeGitHub ChannelType = "github"
	// ChannelTypeGitLab 表示GitLab渠道
	ChannelTypeGitLab ChannelType = "gitlab"
	// ChannelTypeWeChat 表示微信渠道
	ChannelTypeWeChat ChannelType = "wechat"
	// ChannelTypeWeWork 表示企业微信渠道
	ChannelTypeWeWork ChannelType = "wework"
	// ChannelTypeFeishu 表示飞书渠道
	ChannelTypeFeishu ChannelType = "feishu"
)

type DigitalAssistant

type DigitalAssistant struct {
	gorm.Model
	// digital_assistant - 助手标识符,在组织内唯一标识数字助手,VARCHAR(255),NOT NULL
	Code string `gorm:"column:code;type:varchar(255);not null;index"`

	// digital_assistant - 所属组织ID,INTEGER,NOT NULL
	OrgID uint `gorm:"column:org_id;type:integer;not null;index"`
	// digital_assistant - 拥有者ID,INTEGER,NOT NULL
	OwnerID uint `gorm:"column:owner_id;type:integer;not null;index"`

	// digital_assistant - 数字助手名称,VARCHAR(255),NOT NULL
	Name string `gorm:"column:name;type:varchar(255);not null"`

	// digital_assistant - 描述信息,TEXT,允许为空
	Description string `gorm:"column:description;type:text"`
	// digital_assistant - 头像URL地址,VARCHAR(500),允许为空
	Avatar string `gorm:"column:avatar;type:varchar(500)"`

	// digital_assistant - 状态,表示数字助手当前运行状态,VARCHAR(50),NOT NULL
	Status string `gorm:"column:status;type:varchar(50);not null"`
	// digital_assistant - 版本号,跟踪配置变动版本,INTEGER,默认值0
	Version int `gorm:"column:version;type:integer;default:0"`
	// digital_assistant - 系统提示词,定义数字助手的角色和行为,TEXT,允许为空
	SystemPrompt string `gorm:"column:system_prompt;type:text"`
}

DigitalAssistant 数字助手结构体定义了AI数字助手的基本信息与配置

func (DigitalAssistant) TableName

func (DigitalAssistant) TableName() string

TableName 指定DigitalAssistant结构体对应的数据库表名

type DigitalAssistantStatus

type DigitalAssistantStatus string

DigitalAssistantStatus 表示数字助手的当前运行状态

const (
	// DigitalAssistantStatusActive 表示数字助手处于激活状态
	DigitalAssistantStatusActive DigitalAssistantStatus = "active"
	// DigitalAssistantStatusInactive 表示数字助手处于非激活状态
	DigitalAssistantStatusInactive DigitalAssistantStatus = "inactive"
	// DigitalAssistantStatusPaused 表示数字助手处于暂停状态
	DigitalAssistantStatusPaused DigitalAssistantStatus = "paused"
	// DigitalAssistantStatusError 表示数字助手处于错误状态
	DigitalAssistantStatusError DigitalAssistantStatus = "error"
)

type Event

type Event struct {
	gorm.Model

	MessageID string // 消息唯一标识符
	TraceID   string // 分布式追踪 ID
	Source    string // 事件来源
	Type      string // 事件类型(建议使用 types.EventType 定义的常量值)
	Action    string // 事件动作(建议使用 types.EventAction 定义的常量值)

	Actor  string // 事件触发者
	Target string // 事件目标

	Payload map[string]interface{} `gorm:"type:jsonb"` // 事件负载数据

	Timestamp int64 // 事件时间戳
}

Event 表示系统中持久化存储的事件记录

该结构用于将事件信息存储到数据库中,包含事件的基本信息、 来源、类型、动作、参与者、目标和负载数据等。

type EventAction

type EventAction string

EventAction 表示事件的动作行为

const (
	// EventActionOpened 表示打开或创建事件
	EventActionOpened EventAction = "opened"
	// EventActionClosed 表示关闭或删除事件
	EventActionClosed EventAction = "closed"
	// EventActionUpdated 表示更新事件
	EventActionUpdated EventAction = "updated"
	// EventActionCommented 表示评论事件
	EventActionCommented EventAction = "commented"
)

type EventType

type EventType string

EventType 表示事件的类型

const (
	// EventTypeGitHub 表示GitHub类型的事件
	EventTypeGitHub EventType = "github"
	// EventTypeGitLab 表示GitLab类型的事件
	EventTypeGitLab EventType = "gitlab"
	// EventTypeWebhook 表示Webhook类型的事件
	EventTypeWebhook EventType = "webhook"
)

type FileUpload added in v0.1.2

type FileUpload struct {
	gorm.Model
	PublicID     string         `gorm:"column:public_id;type:varchar(255);not null;uniqueIndex"`
	OrgID        uint           `gorm:"column:org_id;type:integer;not null;index"`
	OwnerID      uint           `gorm:"column:owner_id;type:integer;not null;index"`
	Filename     string         `gorm:"column:filename;type:varchar(500)"`
	OriginalName string         `gorm:"column:original_name;type:varchar(500)"`
	MimeType     string         `gorm:"column:mime_type;type:varchar(100)"`
	FileSize     int64          `gorm:"column:file_size;type:bigint"`
	StoragePath  string         `gorm:"column:storage_path;type:varchar(500);not null"`
	Sha256       string         `gorm:"column:sha256;type:varchar(64);index"`
	Purpose      string         `gorm:"column:purpose;type:varchar(50);index"`
	Status       string         `gorm:"column:status;type:varchar(50);not null;default:'active';index"`
	Metadata     ObjectMetadata `gorm:"column:metadata;type:jsonb"`
}

FileUpload 表示用户上传的文件

func (FileUpload) TableName added in v0.1.2

func (FileUpload) TableName() string

TableName 指定 FileUpload 结构体对应的数据库表名

type Filter

type Filter struct {
	Field      string   `json:"field"`
	Value      []string `json:"value"`
	ExactMatch bool     `json:"exact_match"`
}

Filter 过滤条件

type IdentityContext

type IdentityContext struct {
	Caller *Caller `json:"caller"`
	Trace  *Trace  `json:"trace"`
}

IdentityContext 携带执行身份与跟踪信息。

type KnowledgeType

type KnowledgeType string

KnowledgeType 表示知识库类型标识

const (
	// KnowledgeTypeVectorStorage 表示向量存储知识库
	KnowledgeTypeVectorStorage KnowledgeType = "vector_storage"
	// KnowledgeTypeDocument 表示文档知识库
	KnowledgeTypeDocument KnowledgeType = "document"
	// KnowledgeTypeDatabase 表示数据库知识库
	KnowledgeTypeDatabase KnowledgeType = "database"
)

type LLMModel

type LLMModel struct {
	gorm.Model

	// 模型所属组织ID,用于隔离不同组织的模型配置
	OrgID uint `` /* 168-byte string literal not displayed */
	// 模型配置编码,在组织内唯一,用于业务配置引用
	Code string `gorm:"column:code;type:varchar(128);not null;uniqueIndex:idx_llm_model_org_code"`
	// 模型展示名称,用于前端列表和选择器展示
	Name string `gorm:"column:name;type:varchar(255);not null"`
	// 模型描述,用于记录用途、额度、注意事项等说明
	Description string `gorm:"column:description;type:text"`

	// 模型供应商标识,例如 openai、anthropic、deepseek、custom
	Provider string `gorm:"column:provider;type:varchar(64);not null;index"` // 建议使用 types.LLMProviderType 定义的常量值
	// 实际传递给供应商API或CLI的模型名称
	ModelName string `gorm:"column:model;type:varchar(255);not null"`
	// API基础地址,官方默认地址可为空,自定义网关或兼容接口需填写
	BaseURL string `gorm:"column:base_url;type:varchar(500)"`
	// 是否已确认基础地址包含 /v1 前缀,记录连通性探测结果。默认 true 以兼容已有数据。
	BaseURLHasV1 bool `gorm:"column:base_url_has_v1;type:boolean;default:true"`

	// API Key密文,业务读取时需要通过统一密钥服务解密
	APIKeyEncrypted string `gorm:"column:api_key_encrypted;type:text"`
	// API Key脱敏展示值,仅用于前端展示,禁止用于真实调用
	APIKeyMasked string `gorm:"column:api_key_masked;type:varchar(128)"`

	// 默认最大输出Token数,运行请求可按需覆盖
	MaxTokens int `gorm:"column:max_tokens;type:integer;default:4096"`
	// 默认采样温度,运行请求可按需覆盖
	Temperature float64 `gorm:"column:temperature;type:decimal(4,3);default:0.7"`
	// 默认请求超时时间,单位秒
	TimeoutSec int `gorm:"column:timeout_sec;type:integer;default:120"`

	// 模型状态,inactive状态下不应被新任务选择
	Status string `gorm:"column:status;type:varchar(32);not null;default:active;index"` // 建议使用 types.LLMModelStatus 定义的常量值
	// 是否为组织默认模型,业务未显式选择模型时可回退到该模型
	IsDefault bool `gorm:"column:is_default;type:boolean;default:false;index"`
	// 是否为系统内置配置,内置配置可用于初始化或演示场景
	IsSystem bool `gorm:"column:is_system;type:boolean;default:false"`

	// 扩展配置,保存能力标记、上下文窗口、价格、额外Header等非核心字段
	Config LLMModelConfig `gorm:"column:config;type:jsonb"`
}

LLMModel 定义一个在数据库中持久化的LLM模型配置

该表以“可直接调用的模型配置”为最小管理单元,暂时将供应商、 模型、凭证、默认参数和扩展配置放在同一张表中,便于MVP阶段快速接入多模型配置。

func (LLMModel) TableName

func (LLMModel) TableName() string

TableName 指定LLMModel对应的数据库表名

type LLMModelConfig

type LLMModelConfig map[string]interface{}

LLMModelConfig 表示LLM模型配置的扩展JSON字段

func (*LLMModelConfig) Scan

func (c *LLMModelConfig) Scan(value interface{}) error

Scan 实现 sql.Scanner 接口,用于从数据库中读取 JSON 数据

func (LLMModelConfig) Value

func (c LLMModelConfig) Value() (driver.Value, error)

Value 实现 driver.Valuer 接口,用于将扩展配置转换为 JSON 存储

type LLMModelStatus

type LLMModelStatus string

LLMModelStatus 表示LLM模型配置的启用状态

const (
	// LLMModelStatusActive 表示模型配置可被业务使用
	LLMModelStatusActive LLMModelStatus = "active"
	// LLMModelStatusInactive 表示模型配置暂不可被业务使用
	LLMModelStatusInactive LLMModelStatus = "inactive"
)

type LLMProviderType

type LLMProviderType string

LLMProviderType 表示LLM提供商类型标识

const (
	// LLMProviderOpenAI 表示OpenAI提供商
	LLMProviderOpenAI LLMProviderType = "openai"
	// LLMProviderAnthropic 表示Anthropic提供商
	LLMProviderAnthropic LLMProviderType = "anthropic"
	// LLMProviderDeepSeek 表示DeepSeek提供商
	LLMProviderDeepSeek LLMProviderType = "deepseek"
	// LLMProviderQwen 表示通义千问提供商
	LLMProviderQwen LLMProviderType = "qwen"
	// LLMProviderGemini 表示Google Gemini提供商
	LLMProviderGemini LLMProviderType = "gemini"
	// LLMProviderArk 表示火山方舟提供商
	LLMProviderArk LLMProviderType = "ark"
	// LLMProviderOpenRouter 表示OpenRouter提供商
	LLMProviderOpenRouter LLMProviderType = "openrouter"
	// LLMProviderCustom 表示自定义提供商
	LLMProviderCustom LLMProviderType = "custom"
)

type MemberRole

type MemberRole string

MemberRole 成员角色

const (
	MemberRoleOwner  MemberRole = "owner"
	MemberRoleAdmin  MemberRole = "admin"
	MemberRoleMember MemberRole = "member"
	MemberRoleViewer MemberRole = "viewer"
)

type MemberType

type MemberType string

MemberType 成员类型

const (
	MemberTypeUser      MemberType = "user"
	MemberTypeAssistant MemberType = "assistant"
)

type MemoryType

type MemoryType string

MemoryType 表示记忆存储类型标识

const (
	// MemoryTypePostgres 表示基于PostgreSQL的记忆存储
	MemoryTypePostgres MemoryType = "postgres"
	// MemoryTypeInMemory 表示内存记忆存储
	MemoryTypeInMemory MemoryType = "in_memory"
)

type MessageArtifact

type MessageArtifact struct {
	ArtifactID   string `json:"artifact_id,omitempty"`
	Title        string `json:"title,omitempty"`
	Filename     string `json:"filename,omitempty"`
	MimeType     string `json:"mime_type,omitempty"`
	ArtifactType string `json:"artifact_type,omitempty"`
}

MessageArtifact stores one lightweight artifact reference for a session message.

type MessageArtifactSlice

type MessageArtifactSlice []MessageArtifact

MessageArtifactSlice stores artifact references in JSONB.

func (*MessageArtifactSlice) Scan

func (m *MessageArtifactSlice) Scan(value interface{}) error

Scan implements sql.Scanner.

func (MessageArtifactSlice) Value

func (m MessageArtifactSlice) Value() (driver.Value, error)

Value implements driver.Valuer.

type MessageAttachment added in v0.1.2

type MessageAttachment struct {
	FileUploadID string `json:"file_upload_id"`
	Name         string `json:"name"`
	MimeType     string `json:"mime_type"`
	Size         int64  `json:"size"`
	Purpose      string `json:"purpose,omitempty"`
	PublicURL    string `json:"PublicURL"` // resolved at runtime, not exposed to front end
}

type MessageAttachmentSlice added in v0.1.2

type MessageAttachmentSlice []MessageAttachment

func (*MessageAttachmentSlice) Scan added in v0.1.2

func (m *MessageAttachmentSlice) Scan(value interface{}) error

func (MessageAttachmentSlice) Value added in v0.1.2

type MessageChunk

type MessageChunk struct {
	Seq       int64           `json:"seq,omitempty"`
	LastSeq   int64           `json:"last_seq,omitempty"`
	Type      string          `json:"type"`
	Timestamp int64           `json:"timestamp,omitempty"`
	Payload   json.RawMessage `json:"payload,omitempty" swaggertype:"object"`
}

MessageChunk stores one archived runtime event for a completed session message.

type MessageChunkSlice

type MessageChunkSlice []MessageChunk

MessageChunkSlice stores structured message chunks in JSONB.

func (*MessageChunkSlice) Scan

func (m *MessageChunkSlice) Scan(value interface{}) error

Scan 实现 sql.Scanner 接口

func (MessageChunkSlice) Value

func (m MessageChunkSlice) Value() (driver.Value, error)

Value 实现 driver.Valuer 接口

type MessageRole

type MessageRole string

MessageRole 消息角色常量

const (
	MessageRoleUser      MessageRole = "user"
	MessageRoleAssistant MessageRole = "assistant"
	MessageRoleSystem    MessageRole = "system"
	MessageRoleTool      MessageRole = "tool"
)

type MessageStatus

type MessageStatus string

MessageStatus 消息状态常量

const (
	MessageStatusPending    MessageStatus = "pending"
	MessageStatusProcessing MessageStatus = "processing"
	MessageStatusCompleted  MessageStatus = "completed"
	MessageStatusFailed     MessageStatus = "failed"
	MessageStatusCancelled  MessageStatus = "cancelled"
)

type MessageType

type MessageType string

MessageType 消息类型常量

const (
	MessageTypeText  MessageType = "text"
	MessageTypeImage MessageType = "image"
	MessageTypeCode  MessageType = "code"
	MessageTypeFile  MessageType = "file"
)

type MessageUsage

type MessageUsage struct {
	InputTokens  int `json:"input_tokens,omitempty"`
	OutputTokens int `json:"output_tokens,omitempty"`
	TotalTokens  int `json:"total_tokens,omitempty"`
}

MessageUsage stores model token usage for a session message.

func (*MessageUsage) Scan

func (mu *MessageUsage) Scan(value interface{}) error

Scan 瀹炵幇 sql.Scanner 鎺ュ彛

func (MessageUsage) Value

func (mu MessageUsage) Value() (driver.Value, error)

Value 瀹炵幇 driver.Valuer 鎺ュ彛

type ObjectMetadata

type ObjectMetadata struct {
	// 元数据 - 项目标签
	Tags []string `json:"tags,omitempty"`
	// 元数据 - 项目类型/模板标识
	Type string `json:"type,omitempty"`
	// 元数据 - 对象存储桶
	Bucket string `json:"bucket,omitempty"`
	// 元数据 - 对象存储键
	Key string `json:"key,omitempty"`
	// 元数据 - 其他扩展字段
	Extra map[string]interface{} `json:"extra,omitempty"`
}

ObjectMetadata 项目元数据结构

func (*ObjectMetadata) Scan

func (pm *ObjectMetadata) Scan(value interface{}) error

Scan 实现 sql.Scanner 接口

func (ObjectMetadata) Value

func (pm ObjectMetadata) Value() (driver.Value, error)

Value 实现 driver.Valuer 接口

type Organization

type Organization struct {
	gorm.Model
	PublicID string `gorm:"column:public_id;type:varchar(64);uniqueIndex;not null;default:''"` // 组织公开ID
	Type     string `gorm:"column:type;type:varchar(50);default:'company'"`                    // 组织类型: company/team/project
	Code     string `gorm:"column:code;type:varchar(255);unique_index;not null"`               // 组织代码(唯一)
	Name     string `gorm:"column:name;type:varchar(255);not null"`                            // 组织名称
	Status   string `gorm:"column:status;type:varchar(20);default:'active'"`                   // 状态: active/inactive
}

Organization 表示系统中的组织/企业信息

组织是系统中的顶级实体,可以代表公司、团队或项目。 多个用户可以关联到同一个组织。

func (Organization) TableName

func (Organization) TableName() string

TableName 重写表名

type PageQuery

type PageQuery struct {
	Filters    []Filter `json:"filters,omitempty"`
	OrderBy    []string `json:"order_by,omitempty"`
	Caller     `json:"-"`
	Pagination `json:",inline"`
}

PageQuery 通用分页查询参数

func NewPageQuery

func NewPageQuery(caller Caller, offset, limit int) *PageQuery

NewPageQuery 快速创建 PageQuery,接受 Caller 和分页参数。

func (*PageQuery) AddExactFilter

func (pq *PageQuery) AddExactFilter(field string, values ...string) *PageQuery

AddExactFilter 链式添加精确过滤条件。

func (*PageQuery) AddFilter

func (pq *PageQuery) AddFilter(field string, values ...string) *PageQuery

AddFilter 链式添加过滤条件。

type Pagination

type Pagination struct {
	Offset  int  `json:"offset,omitempty"`
	Limit   int  `json:"limit,omitempty"`
	ListAll bool `json:"list_all,omitempty"`
}

Pagination pagination request base

func (*Pagination) Fill

func (p *Pagination) Fill()

Fill 设置分页默认值

type Project

type Project struct {
	gorm.Model
	// project - 项目唯一标识,格式如:prj_xxx,VARCHAR(255),NOT NULL,UNIQUE
	PublicID string `gorm:"column:public_id;type:varchar(255);not null;uniqueIndex"`

	// project - 所属组织ID,INTEGER,NOT NULL,INDEX
	OrgID uint `gorm:"column:org_id;type:integer;not null;index"`

	// project - 创建者用户ID,INTEGER,NOT NULL,INDEX
	OwnerID uint `gorm:"column:owner_id;type:integer;not null;index"`

	// project - 项目名称,VARCHAR(255),NOT NULL
	Name string `gorm:"column:name;type:varchar(255);not null"`

	// project - 项目描述,TEXT,允许为空
	Description string `gorm:"column:description;type:text"`

	// project - 项目目标,TEXT,允许为空
	Objective string `gorm:"column:objective;type:text"`

	// project - 项目状态,VARCHAR(50),NOT NULL,DEFAULT 'active'
	Status string `gorm:"column:status;type:varchar(50);not null;default:'active';index"`

	// project - 元数据(JSON格式存储标签等扩展信息),JSONB,允许为空
	Metadata ObjectMetadata `gorm:"column:metadata;type:jsonb"`
}

Project 表示系统中的项目

项目是长期工作的核心容器,承载会话、任务、AI队友、知识库和项目资产。 项目提供了长期上下文和协作空间。

func (Project) TableName

func (Project) TableName() string

TableName 指定Project结构体对应的数据库表名

type ProjectMember

type ProjectMember struct {
	gorm.Model
	// project_member - 关联项目ID,BIGINT,NOT NULL,INDEX
	ProjectID uint `gorm:"column:project_id;type:bigint;not null;index"`

	// project_member - 成员ID(用户ID或数字助手ID),BIGINT,NOT NULL,INDEX
	MemberID uint `gorm:"column:member_id;type:bigint;not null;index"`

	// project_member - 成员类型(user/assistant),VARCHAR(50),NOT NULL
	MemberType MemberType `gorm:"column:member_type;type:varchar(50);not null;default:'user'"`

	// project_member - 成员角色(owner/admin/member/viewer),VARCHAR(50),NOT NULL
	MemberRole MemberRole `gorm:"column:member_role;type:varchar(50);not null;default:'member'"`

	// project_member - 加入时间,TIMESTAMP,NOT NULL
	JoinedAt time.Time `gorm:"column:joined_at;not null;default:now()"`
}

ProjectMember 项目成员关联表

关联项目与用户或数字助手,定义项目中的成员类型和角色。

func (ProjectMember) TableName

func (ProjectMember) TableName() string

TableName 指定ProjectMember结构体对应的数据库表名

type ProjectStatus

type ProjectStatus string

ProjectStatus 项目生命周期状态

const (
	ProjectStatusActive    ProjectStatus = "active"
	ProjectStatusPaused    ProjectStatus = "paused"
	ProjectStatusCompleted ProjectStatus = "completed"
	ProjectStatusArchived  ProjectStatus = "archived"
)

type RuntimeType

type RuntimeType string

RuntimeType 表示运行时环境类型标识

const (
	// RuntimeTypeDocker 表示Docker容器运行时
	RuntimeTypeDocker RuntimeType = "docker"
	// RuntimeTypeProcess 表示进程运行时
	RuntimeTypeProcess RuntimeType = "process"
)

type Session

type Session struct {
	gorm.Model
	// session - 会话对外唯一标识,格式如:sess_xxx,VARCHAR(255),NOT NULL,UNIQUE
	PublicID string `gorm:"column:public_id;type:varchar(255);not null;uniqueIndex"`

	// session - 会话类型,VARCHAR(50),NOT NULL
	Type SessionType `gorm:"column:type;type:varchar(50);not null"`

	// session - 关联用户UIN,0表示不关联,BIGINT,DEFAULT 0
	Uin uint `gorm:"column:uin;type:bigint;default:0;index"`

	// session - 所属组织ID,0表示未设置,INTEGER,NOT NULL,DEFAULT 0
	OrgID uint `gorm:"column:org_id;type:integer;default:0;not null;index"`

	// session - 关联数字助手ID,0表示不关联,BIGINT,DEFAULT 0
	AssistantID uint `gorm:"column:assistant_id;type:bigint;default:0;index"`

	// session - 分配的数字员工ID,0表示未分配,BIGINT,DEFAULT 0
	AllocatedAssistantID uint `gorm:"column:allocated_assistant_id;type:bigint;default:0;index"`

	// session - 关联任务ID,允许为空,BIGINT,INDEX(scope=task时绑定)
	TaskID *uint `gorm:"column:task_id;type:bigint;uniqueIndex:uni_session_project_task"`

	// session - 关联项目ID,允许为空,BIGINT,INDEX(scope=project时绑定)
	ProjectID *uint `gorm:"column:project_id;type:bigint;uniqueIndex:uni_session_project_task"`

	// session - 会话状态,VARCHAR(50),NOT NULL,DEFAULT 'active'
	Status string `gorm:"column:status;type:varchar(50);not null;default:'active'"`

	// session - 会话标题,VARCHAR(500),允许为空
	Title string `gorm:"column:title;type:varchar(500)"`

	// session - 用户是否手动修改过标题
	TitleManuallySet bool `gorm:"column:title_manually_set;type:boolean;default:false;not null"`

	// session - 元数据,JSON格式存储额外信息,JSONB,允许为空
	Metadata ObjectMetadata `gorm:"column:metadata;type:jsonb"`

	// session - 消息数量,INTEGER,DEFAULT 0
	MessageCount int `gorm:"column:message_count;type:integer;default:0"`

	// session - 最后消息时间,TIMESTAMP,允许为空
	LastMessageAt *time.Time `gorm:"column:last_message_at"`

	// session - 过期时间,TIMESTAMP,允许为空
	ExpiredAt *time.Time `gorm:"column:expired_at;index"`
}

Session 会话结构体定义了用户与数字助手之间的会话信息

func (Session) TableName

func (Session) TableName() string

TableName 指定Session结构体对应的数据库表名

type SessionMessage

type SessionMessage struct {
	gorm.Model
	// session_message - 关联会话ID(FK -> Session.ID),BIGINT,NOT NULL,INDEX
	SessionID uint `gorm:"column:session_id;type:bigint;not null;index"`

	// session_message - 消息角色(user/assistant/system/tool),VARCHAR(50),NOT NULL
	Role string `gorm:"column:role;type:varchar(50);not null"`

	// session_message - 消息内容,TEXT,NOT NULL
	Content string `gorm:"column:content;type:text;not null"`

	// session_message - 消息类型(text/image/code/file),VARCHAR(50),DEFAULT 'text'
	MessageType string `gorm:"column:message_type;type:varchar(50);default:'text'"`

	// session_message - 消息状态(sending/streaming/complete/error),VARCHAR(50),DEFAULT 'complete'
	Status string `gorm:"column:status;type:varchar(50);default:'complete'"`

	// session_message - 流式片段(JSON数组),JSONB,允许为空
	Chunks MessageChunkSlice `gorm:"column:chunks;type:jsonb"`

	// session_message - assistant message artifact references.
	Artifacts MessageArtifactSlice `gorm:"column:artifacts;type:jsonb"`

	// session_message - file attachment references.
	Attachments MessageAttachmentSlice `gorm:"column:attachments;type:jsonb"`

	// session_message - 消息元数据,JSONB,允许为空
	Metadata ObjectMetadata `gorm:"column:metadata;type:jsonb"`

	Usage MessageUsage `gorm:"column:usage;type:jsonb"`

	// session_message - 消息序号(用于排序),BIGINT,NOT NULL
	Sequence int64 `gorm:"column:sequence;type:bigint;not null;index"`

	// session_message - 时间戳(Unix毫秒),BIGINT,允许为空
	Timestamp int64 `gorm:"column:timestamp;type:bigint"`
}

SessionMessage 会话消息结构体

func (SessionMessage) TableName

func (SessionMessage) TableName() string

TableName 指定SessionMessage结构体对应的数据库表名

type SessionStatus

type SessionStatus string

SessionStatus 会话状态常量

const (
	SessionStatusActive  SessionStatus = "active"
	SessionStatusPaused  SessionStatus = "paused"
	SessionStatusEnded   SessionStatus = "ended"
	SessionStatusExpired SessionStatus = "expired"
)

type SessionType

type SessionType string

SessionType 会话类型常量

const (
	SessionTypeUserChat SessionType = "chat"
	SessionTypeTask     SessionType = "task"
	SessionTypeProject  SessionType = "project"
)

type Skill

type Skill struct {
	gorm.Model
	// 技能唯一标识符,与技能实现相关联的ID
	Code string `gorm:"column:code;type:varchar(255);not null;uniqueIndex"`
	// 技能所属组织ID
	OrgID uint `gorm:"column:org_id;type:integer;not null;index"`
	// 技能拥有者ID
	OwnerID uint `gorm:"column:owner_id;type:integer;not null;index"`
	// 技能名称
	Name string `gorm:"column:name;type:varchar(255);not null"`
	// 技能描述
	Description string `gorm:"column:description;type:text"`
	// 技能图标URL
	Icon string `gorm:"column:icon;type:varchar(500)"`
	// 技能版本号
	Version string `gorm:"column:version;type:varchar(50);not null"`
	// 技能类别(例如:"integration","tool","workflow","ai"等)
	Category string `gorm:"column:category;type:varchar(100);not null;index"` // 建议使用 types.SkillCategory 定义的常量值
	// 技能类型(本地技能或远程技能)
	SkillType string `gorm:"column:skill_type;type:varchar(50);not null"` // 建议使用 types.SkillType 定义的常量值
	// 技能作者
	Author string `gorm:"column:author;type:varchar(255)"`
	// 输入参数Schema定义
	InputSchema map[string]interface{} `gorm:"column:input_schema;type:jsonb"`
	// 输出参数Schema定义
	OutputSchema map[string]interface{} `gorm:"column:output_schema;type:jsonb"`
	// 技能所需权限
	Permissions []interface{} `gorm:"column:permissions;type:jsonb"`
	// 技能配置
	Config map[string]interface{} `gorm:"column:config;type:jsonb"`
	// 状态:active, inactive, deprecated
	Status string `gorm:"column:status;type:varchar(50);not null;default:active"` // 建议使用 types.SkillStatus 定义的常量值
	// 是否为系统内置技能
	IsSystem bool `gorm:"column:is_system;type:boolean;default:false"`
}

Skill 定义一个在数据库中持久化的技能实体

func (Skill) TableName

func (Skill) TableName() string

TableName 指定Skill对应的数据库表名

type SkillCategory

type SkillCategory string

SkillCategory 表示技能的类别(如 integration, tool, workflow, ai 等)

const (
	// SkillCategoryIntegration 表示集成类技能
	SkillCategoryIntegration SkillCategory = "integration"
	// SkillCategoryTool 表示工具类技能
	SkillCategoryTool SkillCategory = "tool"
	// SkillCategoryWorkflow 表示工作流技能
	SkillCategoryWorkflow SkillCategory = "workflow"
	// SkillCategoryAI 表示AI类技能
	SkillCategoryAI SkillCategory = "ai"
)

type SkillExecutionLog

type SkillExecutionLog struct {
	gorm.Model
	// 关联的技能ID
	SkillID uint `gorm:"column:skill_id;type:integer;not null;index"`
	// 执行会话ID
	SessionID string `gorm:"column:session_id;type:varchar(255);index"`
	// 用户UIN
	Uin string `gorm:"column:uin;type:varchar(255);index"`
	// 数字助手ID
	AssistantID string `gorm:"column:assistant_id;type:varchar(255);index"`
	// 输入参数
	Input map[string]interface{} `gorm:"column:input;type:jsonb"`
	// 输出结果
	Output map[string]interface{} `gorm:"column:output;type:jsonb"`
	// 是否成功
	Success bool `gorm:"column:success;type:boolean"`
	// 错误信息
	ErrorMsg string `gorm:"column:error_msg;type:text"`
	// 执行耗时(毫秒)
	Duration int64 `gorm:"column:duration;type:bigint"`
}

SkillExecutionLog 记录技能执行日志

func (SkillExecutionLog) TableName

func (SkillExecutionLog) TableName() string

TableName 指定SkillExecutionLog对应的数据库表名

type SkillRegistry

type SkillRegistry struct {
	gorm.Model
	// 关联的技能ID
	SkillID uint `gorm:"column:skill_id;type:integer;not null;uniqueIndex"`
	// 技能服务地址(如果是远程技能)
	ServiceEndpoint string `gorm:"column:service_endpoint;type:varchar(500)"`
	// 技能执行路径
	ExecutionPath string `gorm:"column:execution_path;type:varchar(500)"`
	// 技能认证令牌
	Token string `gorm:"column:token;type:varchar(255)"`
	// 注册状态(registered, unregistered, unhealthy等)
	Status string `gorm:"column:status;type:varchar(50);not null;default:registered"` // 建议使用 types.SkillRegistryStatus 定义的常量值
	// 最后心跳时间
	LastHeartbeat string `gorm:"column:last_heartbeat;type:timestamp"`
	// 健康状态
	IsHealthy bool `gorm:"column:is_healthy;type:boolean;default:true"`
}

SkillRegistry 记录技能在系统中的注册信息

func (SkillRegistry) TableName

func (SkillRegistry) TableName() string

TableName 指定SkillRegistry对应的数据库表名

type SkillRegistryStatus

type SkillRegistryStatus string

SkillRegistryStatus 表示技能注册状态

const (
	// SkillRegistryStatusRegistered 表示已注册
	SkillRegistryStatusRegistered SkillRegistryStatus = "registered"
	// SkillRegistryStatusUnregistered 表示未注册
	SkillRegistryStatusUnregistered SkillRegistryStatus = "unregistered"
	// SkillRegistryStatusUnhealthy 表示不健康
	SkillRegistryStatusUnhealthy SkillRegistryStatus = "unhealthy"
)

type SkillStatus

type SkillStatus string

SkillStatus 表示技能的状态(active, inactive, deprecated)

const (
	// SkillStatusActive 表示技能处于激活状态
	SkillStatusActive SkillStatus = "active"
	// SkillStatusInactive 表示技能处于非激活状态
	SkillStatusInactive SkillStatus = "inactive"
	// SkillStatusDeprecated 表示技能已被弃用
	SkillStatusDeprecated SkillStatus = "deprecated"
)

type SkillStringList added in v0.1.1

type SkillStringList []string

SkillStringList 是 []string 的 JSONB 存储类型。

func (*SkillStringList) Scan added in v0.1.1

func (s *SkillStringList) Scan(value interface{}) error

Scan 实现 sql.Scanner 接口。

func (SkillStringList) Value added in v0.1.1

func (s SkillStringList) Value() (driver.Value, error)

Value 实现 driver.Valuer 接口。

type SkillType

type SkillType string

SkillType 表示技能类型(本地技能或远程技能)

const (
	// SkillTypeLocal 表示本地技能
	SkillTypeLocal SkillType = "local"
	// SkillTypeRemote 表示远程技能
	SkillTypeRemote SkillType = "remote"
)

type Task

type Task struct {
	gorm.Model
	PublicID  string `gorm:"column:public_id;type:varchar(255);not null;uniqueIndex"`
	OrgID     uint   `gorm:"column:org_id;type:integer;not null;index"`
	OwnerID   uint   `gorm:"column:owner_id;type:integer;not null;index"`
	ProjectID uint   `gorm:"column:project_id;type:bigint;not null;index"`
	SessionID *uint  `gorm:"column:session_id;type:bigint;index"`

	// TaskType 任务类型(如:general/general、cron/定时任务等),VARCHAR(16),NOT NULL,DEFAULT 'general'
	TaskType TaskType `gorm:"column:task_type;type:varchar(16);not null;default:'general';index"`

	AssigneeID *uint `gorm:"column:assignee_id;type:bigint;index"`

	Title       string     `gorm:"column:title;type:varchar(500);not null"`
	Description string     `gorm:"column:description;type:text"`
	Status      string     `gorm:"column:status;type:varchar(50);not null;default:'created';index"`
	Deadline    *time.Time `gorm:"column:deadline;index"`

	Metadata ObjectMetadata `gorm:"column:metadata;type:jsonb"`
}

Task 表示系统中的任务

任务是项目中的最小执行单元,由 AI 队友(DigitalAssistant)执行, 支持子任务拆分(通过 ParentTaskID 自引用)和状态生命周期管理。

func (Task) TableName

func (Task) TableName() string

TableName 指定Task结构体对应的数据库表名

type TaskStatus

type TaskStatus string

TaskStatus 表示任务的当前状态

const (
	TaskStatusCreated           TaskStatus = "created"
	TaskStatusPendingAssignment TaskStatus = "pending_assignment"
	TaskStatusInProgress        TaskStatus = "in_progress"
	TaskStatusPendingApproval   TaskStatus = "pending_approval"
	TaskStatusCompleted         TaskStatus = "completed"
	TaskStatusFailed            TaskStatus = "failed"
	TaskStatusCancelled         TaskStatus = "cancelled"
	TaskStatusPaused            TaskStatus = "paused"
)

type TaskType

type TaskType string
const (
	TaskTypeGeneral TaskType = "general"
	TaskTypeCron    TaskType = "cron"
)

type Trace

type Trace struct {
	RequestID string   `json:"request_id"`
	TraceID   string   `json:"trace_id"`
	SpanID    []string `json:"span_id"`
}

Trace 定义了一个跟踪信息结构体,用于在请求链路中传递跟踪标识符,帮助进行分布式追踪和日志关联。

type User

type User struct {
	gorm.Model
	PublicID    string `gorm:"column:public_id;type:varchar(64);uniqueIndex;not null;default:''"` // 用户公开ID
	GithubID    int64  `gorm:"column:github_id;type:bigint;unique_index"`                         // GitHub 用户 ID
	GithubLogin string `gorm:"column:github_login;type:varchar(255);not null;unique_index"`       // GitHub 登录名
	Password    string `gorm:"column:password;type:varchar(255)"`                                 // 密码(本地认证用)
	Name        string `gorm:"column:name;type:varchar(255)"`                                     // 用户姓名
	Email       string `gorm:"column:email;type:varchar(255)"`                                    // 用户邮箱
	AvatarURL   string `gorm:"column:avatar_url;type:varchar(500)"`                               // 头像 URL
	Bio         string `gorm:"column:bio;type:text"`                                              // 个人简介
	Company     string `gorm:"column:company;type:varchar(255)"`                                  // 公司信息
	Location    string `gorm:"column:location;type:varchar(255)"`                                 // 地理位置
	PublicRepos int    `gorm:"column:public_repos;type:integer"`                                  // 公开仓库数量
	Followers   int    `gorm:"column:followers;type:integer"`                                     // 关注者数量
}

User 表示系统中的用户信息

该结构存储用户的基本信息,包括 GitHub 关联信息、 个人资料、头像等。

func (User) TableName

func (User) TableName() string

TableName 重写表名

type UserOrg

type UserOrg struct {
	gorm.Model
	Uin       uint `gorm:"column:uin;type:bigint;unique_index;not null"` // 关联ID,JWT中的Uin
	UserID    uint `gorm:"column:user_id;type:bigint;index;not null"`    // 用户ID
	OrgID     uint `gorm:"column:org_id;type:bigint;index;not null"`     // 组织ID
	IsDefault bool `gorm:"column:is_default;type:boolean;default:false"` // 是否为默认组织
}

UserOrg 表示用户与组织的关联关系

该表是多对多关系的中间表,用于关联用户和组织。 每个用户可以关联多个组织,其中一个可以标记为默认组织。

func (UserOrg) TableName

func (UserOrg) TableName() string

TableName 重写表名

Jump to

Keyboard shortcuts

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