Documentation
¶
Index ¶
- Constants
- type AIRun
- type AdminUser
- type Attachment
- type Base
- type Category
- type ChatConversation
- type ChatEvent
- type ChatMember
- type ChatMessage
- type Department
- type File
- type KnowledgeEntry
- type KnowledgeSource
- type Log
- type Menu
- type Post
- type Role
- type RolePermission
- type Setting
- type SupportApp
- type SupportSession
- type User
- type UserPost
- type UserProfile
- type UserRole
- type UserTraits
Constants ¶
View Source
const ( Enabled = 1 Disabled = 2 )
View Source
const ( MenuDirectory = 1 MenuPage = 2 MenuAction = 3 MenuLink = 4 )
View Source
const ( ScopeAll = "all" ScopeSelf = "self" ScopeDepartment = "department" ScopeDepartments = "departments" )
View Source
const ( UserGuest = "guest" UserMember = "member" UserAI = "ai" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AIRun ¶ added in v0.1.3
type AIRun struct {
RequestKey *string `json:"-" gorm:"size:180;uniqueIndex;comment:跨渠道执行幂等标识"`
ID uint `json:"id" gorm:"primaryKey"`
AppID uint `json:"app_id" gorm:"not null;index;comment:所属客服应用ID"`
ConversationID uint `json:"conversation_id" gorm:"not null;default:0;index;comment:所属会话ID"`
MessageID uint `json:"message_id" gorm:"not null;default:0;comment:触发消息ID"`
ReplyID uint `json:"reply_id" gorm:"not null;default:0;comment:回复消息ID"`
ParentID uint `json:"parent_id" gorm:"not null;default:0;index;comment:父执行ID:0为根执行"`
Kind string `json:"kind" gorm:"not null;size:32;comment:reply回复 draft人工草稿 import知识导入 index索引重建 tool工具"`
Status string `` /* 142-byte string literal not displayed */
Version uint `json:"version" gorm:"not null;default:1;comment:绑定的会话或知识版本"`
Attempt uint `json:"attempt" gorm:"not null;default:0;comment:领取次数与流式尝试编号"`
LeaseToken string `json:"-" gorm:"not null;default:'';size:64;comment:领取者随机租约"`
AvailableAt int64 `` /* 128-byte string literal not displayed */
DeadlineAt int64 `json:"deadline_at" gorm:"not null;default:0;comment:整体截止时间(Unix毫秒)"`
Input json.RawMessage `json:"input" gorm:"type:json;comment:经白名单处理的执行输入"`
Output json.RawMessage `json:"output" gorm:"type:json;comment:执行结果、来源与恢复检查点"`
Error string `json:"error" gorm:"not null;type:text;comment:脱敏执行错误"`
CreatedAt int64 `json:"created_at" gorm:"not null;autoCreateTime:milli"`
UpdatedAt int64 `json:"updated_at" gorm:"not null;autoUpdateTime:milli"`
}
type AdminUser ¶ added in v0.1.3
type AdminUser struct {
Base
UserID *uint `json:"user_id" gorm:"uniqueIndex;comment:关联普通用户ID"`
Username string `json:"username" gorm:"not null;size:80;uniqueIndex;comment:登录账号" binding:"required,max=80"`
Password string `json:"-" gorm:"not null;size:100;comment:密码哈希"`
Realname string `json:"realname" gorm:"not null;size:100;comment:姓名"`
Email string `json:"email" gorm:"not null;size:180;comment:邮箱"`
Phone string `json:"phone" gorm:"not null;size:40;comment:手机号"`
Avatar string `json:"avatar" gorm:"not null;size:500;comment:头像地址"`
Gender string `json:"gender" gorm:"not null;size:1;default:0;comment:性别:0未知 1男 2女"`
DepartmentID uint `json:"dept_id" gorm:"not null;default:0;index;comment:所属部门ID"`
Status int `json:"status" gorm:"not null;type:smallint;default:1;comment:状态:1正常 2停用"`
Super bool `json:"is_super" gorm:"not null;default:false;comment:超级管理员:0否 1是"`
Dashboard string `` /* 126-byte string literal not displayed */
Remark string `json:"remark" gorm:"not null;comment:备注;size:500"`
LoginTime int64 `json:"login_time" gorm:"not null;default:0;comment:最后登录时间(Unix毫秒)"`
Roles []Role `json:"role_list" gorm:"many2many:admin_user_roles;joinForeignKey:UserID;joinReferences:RoleID"`
Posts []Post `json:"post_list" gorm:"many2many:admin_user_posts;joinForeignKey:UserID;joinReferences:PostID"`
}
type Attachment ¶
type Attachment struct {
Base
Scope string `` /* 137-byte string literal not displayed */
Name string `json:"name" gorm:"not null;size:255;comment:附件名称" binding:"required,max=255"`
FileID uint `json:"file_id" gorm:"not null;default:0;uniqueIndex:idx_admin_attachment_file;comment:文件ID"`
CategoryID uint `json:"category_id" gorm:"not null;default:0;index;comment:附件分类ID:0为未分类"`
CreatedBy uint `json:"created_by" gorm:"not null;default:0;index;comment:上传者ID"`
File File `json:"file" gorm:"foreignKey:FileID"`
}
func (Attachment) TableName ¶
func (Attachment) TableName() string
type Base ¶
type Base struct {
ID uint `json:"id" gorm:"not null;primaryKey"`
CreatedAt int64 `json:"created_at" gorm:"not null;autoCreateTime:milli"`
UpdatedAt int64 `json:"updated_at" gorm:"not null;autoUpdateTime:milli"`
DeletedAt soft_delete.DeletedAt `json:"-" gorm:"not null;softDelete:milli;index;default:0"`
}
Base 复用主键、UTC 时间和软删除字段.
type Category ¶
type Category struct {
Base
Code *string `json:"code" gorm:"size:30;uniqueIndex;comment:自动分类标识,空值为自建分类"`
Name string `json:"name" gorm:"not null;size:100;comment:附件分类名称" binding:"required,max=100"`
ParentID uint `json:"parent_id" gorm:"not null;default:0;comment:上级分类ID:0为顶级;index"`
Sort int `json:"sort" gorm:"not null;default:0;comment:排序:升序"`
}
type ChatConversation ¶ added in v0.1.1
type ChatConversation struct {
VisitorOnline *bool `json:"visitor_online" gorm:"-"`
VisitorLastOnlineAt int64 `json:"visitor_last_online_at" gorm:"-"`
VisitorOfflineEndAt int64 `json:"visitor_offline_end_at" gorm:"-"`
SupportSession *SupportSession `json:"support_session,omitempty" gorm:"-"`
ID uint `json:"id" gorm:"primaryKey"`
Type string `json:"type" gorm:"not null;size:16;comment:会话类型:direct单聊 support客服"`
AppID uint `json:"app_id" gorm:"not null;default:0;index:idx_support_inbox,priority:1;comment:客服应用ID:0为管理员私聊"`
UserID uint `json:"-" gorm:"not null;default:0;index;comment:客户用户ID"`
EntryKey string `json:"entry_key" gorm:"not null;default:'';size:80;comment:入口稳定标识"`
Status string `` /* 160-byte string literal not displayed */
AssignedAdminID uint `json:"assigned_admin_id" gorm:"not null;default:0;index;comment:当前负责管理员ID"`
Version uint `json:"version" gorm:"not null;default:1;comment:接待并发控制版本"`
Round uint `json:"round" gorm:"not null;default:1;comment:接待轮次"`
Context json.RawMessage `json:"context" gorm:"type:json;comment:渠道、外部消息、摘要与评价上下文"`
Identify string `json:"-" gorm:"not null;size:180;uniqueIndex;comment:包含身份域的会话唯一标识"`
LastMessageID uint `json:"last_message_id" gorm:"not null;default:0;index;comment:最后消息ID"`
LastMessageAt int64 `json:"last_message_at" gorm:"not null;default:0;comment:最后消息时间(Unix毫秒)"`
CreatedAt int64 `json:"created_at" gorm:"not null;autoCreateTime:milli"`
UpdatedAt int64 `json:"updated_at" gorm:"not null;autoUpdateTime:milli"`
}
func (ChatConversation) TableName ¶ added in v0.1.1
func (ChatConversation) TableName() string
type ChatEvent ¶ added in v0.1.1
type ChatEvent struct {
ID uint `json:"id" gorm:"primaryKey;index:idx_chat_event_pending,priority:3"`
ConversationID uint `json:"conversation_id" gorm:"not null;index;comment:会话ID"`
Type string `json:"type" gorm:"not null;size:64;comment:实时事件类型"`
Data json.RawMessage `json:"data" gorm:"not null;type:json;comment:公开事件数据"`
Attempts int `json:"-" gorm:"not null;default:0;comment:投递尝试次数"`
AvailableAt int64 `json:"-" gorm:"not null;default:0;index:idx_chat_event_pending,priority:2;comment:下次投递或租约到期时间"`
PublishedAt int64 `json:"-" gorm:"not null;default:0;index:idx_chat_event_pending,priority:1;comment:发布到WS收件流的时间"`
CreatedAt int64 `json:"created_at" gorm:"not null;autoCreateTime:milli"`
}
type ChatMember ¶ added in v0.1.1
type ChatMember struct {
ConversationID uint `json:"conversation_id" gorm:"primaryKey;comment:会话ID"`
Realm string `json:"realm" gorm:"primaryKey;size:32;index:idx_chat_member_identity;comment:身份域:admin或业务定义"`
Subject string `json:"subject" gorm:"primaryKey;size:64;index:idx_chat_member_identity;comment:身份域内的主体ID"`
LastReadMessageID uint `json:"last_read_message_id" gorm:"not null;default:0;comment:已读消息位置"`
Extra json.RawMessage `json:"-" gorm:"type:json;comment:内部输入预览与设备草稿快照"`
CreatedAt int64 `json:"created_at" gorm:"not null;autoCreateTime:milli"`
}
func (ChatMember) TableName ¶ added in v0.1.1
func (ChatMember) TableName() string
type ChatMessage ¶ added in v0.1.1
type ChatMessage struct {
ExternalID *string `json:"-" gorm:"size:120;uniqueIndex;comment:外部渠道消息唯一标识"`
ID uint `json:"id" gorm:"primaryKey;index:idx_chat_message_history,priority:2"`
ConversationID uint `json:"conversation_id" gorm:"not null;index:idx_chat_message_history,priority:1;comment:会话ID"`
SenderRealm string `` /* 159-byte string literal not displayed */
SenderSubject string `` /* 160-byte string literal not displayed */
RequestID string `json:"request_id" gorm:"not null;size:64;uniqueIndex:idx_chat_message_request;comment:发送幂等标识"`
Type string `json:"type" gorm:"not null;size:24;default:text;comment:消息类型:text文本 event事件"`
Visibility string `json:"visibility" gorm:"not null;size:16;default:public;comment:public公开 internal内部 draft客服草稿"`
Status string `json:"status" gorm:"not null;size:16;default:completed;comment:queued streaming completed failed cancelled"`
Content string `json:"content" gorm:"not null;type:text;comment:消息正文"`
ReplyToID uint `json:"reply_to_id" gorm:"not null;default:0;comment:同会话被回复消息ID"`
Payload json.RawMessage `json:"payload" gorm:"type:json;comment:按消息类型定义的扩展数据"`
CreatedAt int64 `json:"created_at" gorm:"not null;autoCreateTime:milli;index:idx_chat_message_sender_time,priority:3"`
UpdatedAt int64 `json:"updated_at" gorm:"not null;autoUpdateTime:milli"`
}
func (ChatMessage) TableName ¶ added in v0.1.1
func (ChatMessage) TableName() string
type Department ¶
type Department struct {
Base
Name string `json:"name" gorm:"not null;size:100;comment:部门名称" binding:"required,max=100"`
ParentID uint `json:"parent_id" gorm:"not null;default:0;index;comment:上级部门ID:0为顶级"`
Leader string `json:"leader" gorm:"not null;size:100;comment:负责人"`
Phone string `json:"phone" gorm:"not null;size:40;comment:联系电话"`
Email string `json:"email" gorm:"not null;size:180;comment:联系邮箱"`
Sort int `json:"sort" gorm:"not null;default:0;comment:排序:升序"`
Status int `json:"status" gorm:"not null;type:smallint;default:1;comment:状态:1正常 2停用" binding:"oneof=1 2"`
Remark string `json:"remark" gorm:"not null;comment:备注;size:500"`
}
func (Department) TableName ¶
func (Department) TableName() string
type File ¶
type File struct {
Location storage.Config `json:"-" gorm:"not null;serializer:json;type:text;comment:上传时的存储位置(JSON):驱动和路径参数,不含密钥"`
ID uint `json:"id" gorm:"not null;primaryKey"`
MD5 string `json:"md5" gorm:"not null;size:32;index:idx_admin_file_lookup;comment:文件MD5摘要"`
SHA256 string `json:"sha256" gorm:"not null;size:64;uniqueIndex;comment:文件SHA-256摘要"`
Size int64 `json:"size" gorm:"not null;default:0;index:idx_admin_file_lookup;comment:文件大小(字节)"`
Path string `json:"-" gorm:"not null;size:500;comment:存储路径"`
MIME string `json:"mime" gorm:"not null;size:150;comment:文件媒体类型"`
CreatedAt int64 `json:"created_at" gorm:"not null;autoCreateTime:milli"`
UpdatedAt int64 `json:"updated_at" gorm:"not null;autoUpdateTime:milli;comment:最后一次被内容引用的时间"`
UsedCount int64 `json:"used_count" gorm:"not null;default:0;comment:累计被内容引用次数"`
}
type KnowledgeEntry ¶ added in v0.1.3
type KnowledgeEntry struct {
Base
AppID uint `json:"app_id" gorm:"not null;index:idx_knowledge_scope,priority:1;comment:所属客服应用ID"`
SourceID uint `json:"source_id" gorm:"not null;default:0;index;comment:资料来源ID"`
Question string `json:"question" gorm:"not null;size:1000;comment:知识标题或问题"`
Answer string `json:"answer" gorm:"not null;type:text;comment:审核答案或原始文档分块"`
Keywords string `json:"keywords" gorm:"not null;type:text;comment:关键词与相似问法"`
Conditions string `json:"conditions" gorm:"not null;type:text;comment:知识适用条件"`
Locale string `json:"locale" gorm:"not null;size:16;default:zh;comment:知识语言"`
ReplyMode string `json:"reply_mode" gorm:"not null;size:16;default:reference;comment:fixed固定原文 reference依据知识回答"`
Status string `` /* 145-byte string literal not displayed */
Version uint `json:"version" gorm:"not null;default:1;comment:内容版本"`
Experts json.RawMessage `json:"experts" gorm:"type:json;comment:已绑定Telegram的协助用户ID列表"`
Location string `json:"location" gorm:"not null;default:'';size:1000;comment:来源链接或标题位置"`
}
func (KnowledgeEntry) TableName ¶ added in v0.1.3
func (KnowledgeEntry) TableName() string
type KnowledgeSource ¶ added in v0.1.3
type KnowledgeSource struct {
Base
AppID uint `json:"app_id" gorm:"not null;index;comment:所属客服应用ID"`
Name string `json:"name" gorm:"not null;size:200;comment:资料名称"`
Kind string `json:"kind" gorm:"not null;size:24;comment:来源:text文本 url网页 markdown文档"`
Content string `json:"content" gorm:"not null;type:text;comment:原始资料或来源地址"`
Status string `` /* 142-byte string literal not displayed */
ContentHash string `json:"content_hash" gorm:"not null;default:'';size:64;comment:已处理内容SHA256"`
Error string `json:"error" gorm:"not null;type:text;comment:可公开的处理错误"`
}
func (KnowledgeSource) TableName ¶ added in v0.1.3
func (KnowledgeSource) TableName() string
type Log ¶
type Log struct {
Location string `json:"location" gorm:"not null;default:'';size:255;comment:IP地理位置"`
CountryCode string `json:"country_code" gorm:"not null;default:'';size:2;comment:IP所在国家代码"`
RequestData string `json:"request_data" gorm:"not null;type:text;comment:请求参数:敏感字段脱敏"`
ResponseData string `json:"response_data" gorm:"not null;type:text;comment:响应摘要:敏感字段脱敏"`
Sender string `json:"sender" gorm:"not null;default:'';size:180;comment:邮件发件地址:非邮件日志为空"`
Recipient string `json:"recipient" gorm:"not null;default:'';size:180;comment:邮件收件地址:非邮件日志为空"`
ID uint `json:"id" gorm:"not null;primaryKey"`
Kind string `` /* 127-byte string literal not displayed */
UserID uint `json:"user_id" gorm:"not null;default:0;index;comment:管理员ID"`
Username string `json:"username" gorm:"not null;size:80;comment:管理员账号"`
Method string `json:"method" gorm:"not null;size:10;comment:HTTP请求方法"`
Path string `json:"path" gorm:"not null;size:500;comment:请求路径"`
IP string `json:"ip" gorm:"not null;size:80;comment:客户端IP"`
Status int `json:"status" gorm:"not null;default:0;comment:HTTP响应状态码"`
Duration int64 `json:"duration" gorm:"not null;default:0;comment:请求耗时(毫秒)"`
Message string `json:"message" gorm:"not null;type:text;comment:日志内容"`
CreatedAt int64 `json:"created_at" gorm:"not null;autoCreateTime:milli;index:idx_admin_logs_kind_time"`
}
type Menu ¶
type Menu struct {
Base
Type int `json:"type" gorm:"not null;default:0;comment:类型:1目录 2菜单 3按钮 4外链" binding:"required,oneof=1 2 3 4"`
Path string `json:"path" gorm:"not null;size:500;comment:前端路由路径"`
Component string `json:"component" gorm:"not null;size:500;comment:前端组件路径"`
Status int `json:"status" gorm:"not null;type:smallint;default:1;comment:状态:1正常 2停用" binding:"required,oneof=1 2"`
Hidden bool `json:"hidden" gorm:"not null;default:false;comment:隐藏菜单:0否 1是"`
KeepAlive bool `json:"keep_alive" gorm:"not null;default:false;comment:缓存页面:0否 1是"`
FixedTab bool `json:"fixed_tab" gorm:"not null;default:false;comment:固定页签:0否 1是"`
FullPage bool `json:"full_page" gorm:"not null;default:false;comment:独立全屏:0否 1是"`
Key string `` /* 129-byte string literal not displayed */
ParentKey string `json:"parent_key" gorm:"not null;size:150;index;comment:上级菜单Key:空为顶级"`
Title string `json:"title" gorm:"not null;size:100;comment:菜单或权限名称" binding:"required,max=100"`
URL string `json:"url" gorm:"not null;size:1500;comment:菜单目标地址:站内路径或HTTP(S)地址" binding:"max=1500"`
Icon string `json:"icon" gorm:"not null;size:100;comment:菜单图标"`
Mode string `json:"mode" gorm:"not null;size:20;comment:打开方式:iframe后台内嵌 new_tab新窗口"`
SystemKey string `json:"system_key" gorm:"not null;size:100;comment:受控外部系统Key"`
Sort int `json:"sort" gorm:"not null;default:0;comment:排序:升序"`
}
Menu 保存自定义目录、外链菜单和操作权限, 内置菜单由代码定义.
type Post ¶
type Post struct {
Base
Name string `json:"name" gorm:"not null;size:100;comment:岗位名称" binding:"required,max=100"`
Code string `json:"code" gorm:"not null;size:100;uniqueIndex;comment:岗位唯一编码" binding:"required,max=100"`
Sort int `json:"sort" gorm:"not null;default:0;comment:排序:升序"`
Status int `json:"status" gorm:"not null;type:smallint;default:1;comment:状态:1正常 2停用" binding:"oneof=1 2"`
Remark string `json:"remark" gorm:"not null;comment:备注;size:500"`
}
type Role ¶
type Role struct {
Base
Name string `json:"name" gorm:"not null;size:100;comment:角色名称" binding:"required,max=100"`
Code string `json:"code" gorm:"not null;size:100;uniqueIndex;comment:角色唯一编码" binding:"required,max=100"`
Level int `json:"level" gorm:"not null;default:1;comment:管理级别:数值越大级别越高"`
Status int `json:"status" gorm:"not null;type:smallint;default:1;comment:状态:1正常 2停用" binding:"oneof=1 2"`
Sort int `json:"sort" gorm:"not null;default:0;comment:排序:升序"`
Remark string `json:"remark" gorm:"not null;comment:备注;size:500"`
DataScope string `` /* 140-byte string literal not displayed */
DepartmentIDs []uint `json:"department_ids" gorm:"not null;serializer:json;default:'[]';comment:指定部门ID列表(JSON)"`
}
type RolePermission ¶
type RolePermission struct {
RoleID uint `json:"role_id" gorm:"not null;primaryKey;comment:角色ID"`
Key string `json:"key" gorm:"not null;size:150;primaryKey;comment:授权权限Key"`
}
func (RolePermission) TableName ¶
func (RolePermission) TableName() string
type Setting ¶
type Setting struct {
ID uint `json:"id" gorm:"primaryKey"`
Key string `json:"key" gorm:"not null;size:100;uniqueIndex;comment:配置唯一标识"`
Name string `json:"name" gorm:"not null;size:100;comment:配置名称"`
Value string `json:"value" gorm:"not null;type:json;comment:配置内容JSON:保密字段保存密文"`
Revision int64 `json:"revision" gorm:"not null;default:1;comment:配置版本:防止并发写入旧缓存"`
CreatedAt int64 `json:"created_at" gorm:"not null;autoCreateTime:milli"`
UpdatedAt int64 `json:"updated_at" gorm:"not null;autoUpdateTime:milli"`
UpdatedBy uint `json:"updated_by" gorm:"not null;default:0;comment:最后修改管理员ID"`
}
type SupportApp ¶ added in v0.1.3
type SupportApp struct {
Base
Name string `json:"name" gorm:"not null;size:100;comment:客服应用名称"`
CreatedBy uint `json:"created_by" gorm:"not null;default:0;index;comment:创建管理员ID"`
PublicKey string `json:"public_key" gorm:"not null;size:64;uniqueIndex;comment:公开接入标识"`
Avatar string `json:"avatar" gorm:"not null;default:'';size:500;comment:品牌头像"`
AIUserID uint `json:"ai_user_id" gorm:"not null;comment:应用AI用户ID"`
Status int `json:"status" gorm:"not null;default:1;comment:状态:1启用 2停用"`
TelegramBotID *int64 `json:"telegram_bot_id" gorm:"uniqueIndex;comment:应用独占的Telegram机器人ID"`
Config json.RawMessage `json:"config" gorm:"type:json;comment:入口、模型、知识、工具与接待配置"`
Secrets string `json:"-" gorm:"not null;type:text;comment:加密保存的模型、身份与机器人密钥"`
Revision uint `json:"revision" gorm:"not null;default:1;comment:配置并发控制版本"`
}
func (SupportApp) TableName ¶ added in v0.1.3
func (SupportApp) TableName() string
type SupportSession ¶ added in v0.1.3
type SupportSession struct {
ID uint `json:"id" gorm:"primaryKey"`
ConversationID uint `json:"conversation_id" gorm:"not null;uniqueIndex:idx_support_session_round;index;comment:聊天会话ID"`
Round uint `json:"round" gorm:"not null;uniqueIndex:idx_support_session_round;comment:接待轮次"`
AssignedAdminID uint `json:"assigned_admin_id" gorm:"not null;default:0;index;comment:负责客服ID"`
Status string `` /* 190-byte string literal not displayed */
Version uint `json:"version" gorm:"not null;default:1;comment:接待状态版本"`
Rating *int `json:"rating" gorm:"comment:评分1差评 2一般 3好评:空表示未评价"`
Comment string `json:"comment" gorm:"not null;type:text;comment:客户评价"`
StartedAt int64 `json:"started_at" gorm:"not null;default:0;comment:首次接待时间(Unix毫秒),0表示尚未接待"`
OfflineSince int64 `json:"offline_since" gorm:"not null;default:0;comment:持续离线起点(Unix毫秒),0表示未离线"`
LastOnlineAt int64 `json:"last_online_at" gorm:"not null;default:0;comment:最近确认在线时间(Unix毫秒)"`
ClosingRequestedAt int64 `json:"closing_requested_at" gorm:"not null;default:0;comment:申请结束时间(Unix毫秒)"`
CloseReason string `` /* 151-byte string literal not displayed */
ClosedAt int64 `json:"closed_at" gorm:"not null;default:0;comment:结束时间(Unix毫秒)"`
CreatedAt int64 `json:"created_at" gorm:"not null;autoCreateTime:milli"`
UpdatedAt int64 `json:"updated_at" gorm:"not null;autoUpdateTime:milli"`
}
SupportSession保存一轮人工接待,结束确认和评价不随下一次咨询被覆盖。
func (SupportSession) TableName ¶ added in v0.1.3
func (SupportSession) TableName() string
type User ¶
type User struct {
Base
UniqueID string `json:"unique_id" gorm:"not null;size:32;uniqueIndex;comment:安装固定密钥生成的对外用户编号"`
Type string `json:"type" gorm:"not null;size:16;default:guest;index;comment:用户类型:guest访客 member普通用户 ai智能体"`
Username *string `json:"username" binding:"omitempty,min=3,max=80" gorm:"size:80;uniqueIndex;comment:本站登录用户名"`
PasswordHash string `json:"-" gorm:"not null;default:'';size:100;comment:密码哈希"`
Nickname string `json:"nickname" binding:"max=100" gorm:"not null;default:'';size:100;comment:用户昵称"`
Avatar string `json:"avatar" binding:"max=500" gorm:"not null;default:'';size:500;comment:头像地址"`
Email string `json:"email" binding:"omitempty,email,max=180" gorm:"not null;default:'';size:180;comment:联系邮箱"`
Mobile string `json:"mobile" binding:"max=40" gorm:"not null;default:'';size:40;comment:联系电话"`
Locale string `json:"locale" binding:"max=16" gorm:"not null;size:16;default:zh;comment:偏好语言"`
Status int `json:"status" binding:"oneof=1 2" gorm:"not null;default:1;comment:状态:1启用 2停用"`
TelegramID *int64 `json:"telegram_id" gorm:"uniqueIndex;comment:已绑定Telegram用户ID"`
TelegramUsername string `json:"telegram_username" gorm:"not null;default:'';size:80;comment:最近取得的Telegram用户名"`
}
User 是可由业务模型嵌入扩展的通用用户;后台权限属于AdminUser。
func (*User) BeforeCreate ¶ added in v0.1.3
BeforeCreate为批量INSERT保留不同的占位值,事务提交前由AfterCreate转换。
func (User) Profile ¶ added in v0.1.3
func (u User) Profile() UserProfile
type UserPost ¶
type UserPost struct {
UserID uint `gorm:"not null;primaryKey;comment:管理员ID"`
PostID uint `gorm:"not null;primaryKey;index;comment:岗位ID"`
}
UserPost 用户与岗位关联.
type UserProfile ¶ added in v0.1.3
type UserProfile struct {
UniqueID string `json:"unique_id"`
Type string `json:"type"`
Username *string `json:"username"`
Nickname string `json:"nickname"`
Avatar string `json:"avatar"`
Email string `json:"email"`
Mobile string `json:"mobile"`
Locale string `json:"locale"`
}
UserProfile是公开资料,不包含内部主键、权限和认证字段。
type UserRole ¶
type UserRole struct {
UserID uint `gorm:"not null;primaryKey;comment:管理员ID"`
RoleID uint `gorm:"not null;primaryKey;index;comment:角色ID"`
}
UserRole 用户与角色关联.
type UserTraits ¶ added in v0.1.3
type UserTraits struct {
AppID uint `json:"app_id" gorm:"primaryKey;uniqueIndex:idx_traits_identity,priority:1;comment:客服应用ID"`
UserID uint `json:"user_id" gorm:"primaryKey;comment:普通用户ID"`
IdentityProvider *string `json:"identity_provider" gorm:"size:100;uniqueIndex:idx_traits_identity,priority:2;comment:可信外部身份来源"`
ExternalUserID *string `json:"external_user_id" gorm:"size:180;uniqueIndex:idx_traits_identity,priority:3;comment:已验证外部用户编号"`
VerifiedAt int64 `json:"verified_at" gorm:"not null;default:0;comment:最近身份验证时间(Unix毫秒)"`
Attributes json.RawMessage `json:"attributes" gorm:"type:json;comment:接入方提交的扩展资料"`
Observed json.RawMessage `json:"observed" gorm:"type:json;comment:访问环境与近期浏览轨迹"`
Remark string `json:"remark" gorm:"not null;type:text;comment:应用内客服备注"`
FirstSeenAt int64 `json:"first_seen_at" gorm:"not null;autoCreateTime:milli;comment:首次访问时间(Unix毫秒)"`
LastSeenAt int64 `json:"last_seen_at" gorm:"not null;autoUpdateTime:milli;comment:最近访问时间(Unix毫秒)"`
}
func (UserTraits) TableName ¶ added in v0.1.3
func (UserTraits) TableName() string
Source Files
¶
- admin_user.go
- ai_run.go
- attachment.go
- base.go
- category.go
- chat_conversation.go
- chat_event.go
- chat_member.go
- chat_message.go
- department.go
- file.go
- knowledge_entry.go
- knowledge_source.go
- log.go
- menu.go
- post.go
- role.go
- role_permission.go
- setting.go
- support_app.go
- support_session.go
- user.go
- user_post.go
- user_role.go
- user_traits.go
Click to show internal directories.
Click to hide internal directories.