首次提交:初始化项目代码
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
// Package model 常量定义,包含系统默认配置和全局常量
|
||||
package model
|
||||
|
||||
const (
|
||||
// DefaultPageSize 后台列表默认分页大小
|
||||
DefaultPageSize = 10
|
||||
// MaxPageSize 后台列表最大分页大小
|
||||
MaxPageSize = 100
|
||||
|
||||
// DefaultTemplate 默认简历模板名称
|
||||
DefaultTemplate = "modern"
|
||||
|
||||
// AdminTokenFile 管理员令牌持久化文件路径
|
||||
AdminTokenFile = "./data/admin_tokens.json"
|
||||
// SettingsFile 系统设置持久化文件路径(预留)
|
||||
SettingsFile = "./data/settings.json"
|
||||
|
||||
// DefaultWebsiteTitle 默认网站标题
|
||||
DefaultWebsiteTitle = "景笺 - 开源简历平台"
|
||||
// DefaultWebsiteDesc 默认网站简介
|
||||
DefaultWebsiteDesc = "现代化的开源简历平台,支持多人简历管理、自定义模板、实时预览"
|
||||
// DefaultWebsiteKeywords 默认网站关键词
|
||||
DefaultWebsiteKeywords = "简历平台,开源,个人主页,作品集,简历管理"
|
||||
// DefaultWebsiteDomain 默认网站域名
|
||||
DefaultWebsiteDomain = "http://localhost:8090"
|
||||
|
||||
// DefaultAdminUsername 默认管理员用户名
|
||||
DefaultAdminUsername = "admin"
|
||||
// DefaultAdminPassword 默认管理员密码
|
||||
DefaultAdminPassword = "admin123"
|
||||
)
|
||||
@@ -0,0 +1,95 @@
|
||||
package model
|
||||
|
||||
// Document 上传文档模型,记录文档元数据和原始内容
|
||||
type Document struct {
|
||||
ID string `json:"id"` // 文档唯一标识
|
||||
UserID string `json:"user_id"` // 关联的用户ID
|
||||
Name string `json:"name"` // 文档名称
|
||||
Type string `json:"type"` // 文件类型(扩展名)
|
||||
Size int64 `json:"size"` // 文件大小(字节)
|
||||
MIMEType string `json:"mime_type"` // MIME类型
|
||||
Content string `json:"content"` // 文档原始内容
|
||||
Status string `json:"status"` // 处理状态:uploading/processing/processed/failed
|
||||
ErrorMsg string `json:"error_msg,omitempty"` // 处理失败的错误信息
|
||||
CreatedAt string `json:"created_at"` // 创建时间
|
||||
UpdatedAt string `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// DocumentChunk 文档切片模型,用于向量检索的文本块
|
||||
type DocumentChunk struct {
|
||||
ID string `json:"id"` // 切片唯一标识
|
||||
DocumentID string `json:"document_id"` // 关联的文档ID
|
||||
ChunkIndex int `json:"chunk_index"` // 切片序号
|
||||
Content string `json:"content"` // 切片文本内容
|
||||
Embedding string `json:"embedding"` // 向量嵌入(JSON格式)
|
||||
Metadata string `json:"metadata"` // 元数据(JSON格式)
|
||||
CreatedAt string `json:"created_at"` // 创建时间
|
||||
}
|
||||
|
||||
// ChatHistory 聊天历史记录模型
|
||||
type ChatHistory struct {
|
||||
ID string `json:"id"` // 记录唯一标识
|
||||
UserID string `json:"user_id"` // 关联的用户ID
|
||||
Question string `json:"question"` // 用户问题
|
||||
Answer string `json:"answer"` // AI回答
|
||||
Context string `json:"context"` // 参考的文档上下文
|
||||
CreatedAt string `json:"created_at"` // 创建时间
|
||||
}
|
||||
|
||||
// Menu 后台菜单模型
|
||||
type Menu struct {
|
||||
ID string `json:"id"` // 菜单唯一标识
|
||||
Name string `json:"name"` // 菜单名称
|
||||
Icon string `json:"icon"` // 图标类名
|
||||
Path string `json:"path"` // 路由路径
|
||||
ParentID string `json:"parent_id"` // 父菜单ID
|
||||
SortOrder int `json:"sort_order"` // 排序权重
|
||||
IsFixed bool `json:"is_fixed"` // 是否固定菜单(不可删除)
|
||||
IsEnabled bool `json:"is_enabled"` // 是否启用
|
||||
CreatedAt string `json:"created_at"` // 创建时间
|
||||
UpdatedAt string `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// SystemConfig 系统配置模型,存储网站全局设置
|
||||
type SystemConfig struct {
|
||||
ID string `json:"id"` // 配置唯一标识
|
||||
WebsiteDomain string `json:"website_domain"` // 网站域名
|
||||
WebsiteLogo string `json:"website_logo"` // 网站Logo(Base64)
|
||||
LogoPath string `json:"logo_path"` // Logo文件路径
|
||||
WebsiteTitle string `json:"website_title"` // 网站标题
|
||||
WebsiteDesc string `json:"website_desc"` // 网站简介(短)
|
||||
WebsiteDescription string `json:"website_description"` // 网站描述(长)
|
||||
WebsiteKeywords string `json:"website_keywords"` // 网站关键词
|
||||
AdminEmail string `json:"admin_email"` // 管理员邮箱
|
||||
AdminName string `json:"admin_name"` // 管理员名称
|
||||
SEOKeywords string `json:"seo_keywords"` // SEO关键词
|
||||
SEODescription string `json:"seo_description"` // SEO描述
|
||||
DatabasePath string `json:"database_path"` // 数据库文件路径
|
||||
AdminPageSize int `json:"admin_page_size"` // 后台列表分页大小
|
||||
CreatedAt string `json:"created_at"` // 创建时间
|
||||
UpdatedAt string `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// LoginHistory 登录历史记录模型
|
||||
type LoginHistory struct {
|
||||
ID string `json:"id"` // 记录唯一标识
|
||||
UserID string `json:"user_id"` // 关联的用户ID
|
||||
UserName string `json:"user_name"` // 用户名
|
||||
IP string `json:"ip"` // 登录IP
|
||||
Location string `json:"location"` // 登录地点
|
||||
UserAgent string `json:"user_agent"` // 浏览器UA
|
||||
Success bool `json:"success"` // 是否登录成功
|
||||
Message string `json:"message"` // 结果消息
|
||||
CreatedAt string `json:"created_at"` // 创建时间
|
||||
}
|
||||
|
||||
// Notification 系统通知模型
|
||||
type Notification struct {
|
||||
ID string `json:"id"`
|
||||
Type string `json:"type"` // 通知类型:user/resume/portfolio/quiz/system
|
||||
Title string `json:"title"` // 通知标题
|
||||
Message string `json:"message"` // 通知内容
|
||||
URL string `json:"url"` // 点击跳转链接
|
||||
IsRead bool `json:"is_read"` // 是否已读
|
||||
CreatedAt string `json:"created_at"` // 创建时间
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package model
|
||||
|
||||
// Embedding 向量嵌入模型,用于知识库检索
|
||||
type Embedding struct {
|
||||
ID string `json:"id"` // 向量唯一标识
|
||||
ContentHash string `json:"content_hash"` // 内容哈希(去重)
|
||||
Embedding string `json:"embedding"` // 向量嵌入(JSON数组)
|
||||
SourceType string `json:"source_type"` // 来源类型(document/resume/text)
|
||||
SourceID string `json:"source_id"` // 来源ID
|
||||
SourceName string `json:"source_name"` // 来源名称
|
||||
UserID string `json:"user_id"` // 关联的用户ID
|
||||
CreatedAt string `json:"created_at"` // 创建时间
|
||||
}
|
||||
|
||||
// ChunkWithScore 带相似度评分的文档片段,用于向量检索排序
|
||||
type ChunkWithScore struct {
|
||||
Content string `json:"content"` // 片段内容
|
||||
Score float64 `json:"score"` // 相似度评分
|
||||
Metadata string `json:"metadata"` // 元数据(含向量JSON)
|
||||
SourceID string `json:"source_id"` // 来源ID
|
||||
SourceName string `json:"source_name"` // 来源名称
|
||||
SourceType string `json:"source_type"` // 来源类型
|
||||
}
|
||||
|
||||
// KnowledgeBaseStats 知识库统计信息
|
||||
type KnowledgeBaseStats struct {
|
||||
TotalDocuments int `json:"total_documents"` // 文档总数
|
||||
TotalChunks int `json:"total_chunks"` // 切片总数
|
||||
TotalEmbeddings int `json:"total_embeddings"` // 向量总数
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
// Package model 数据模型层,定义所有业务实体结构
|
||||
// 包含用户、简历、作品集、答题记录等核心数据模型
|
||||
package model
|
||||
|
||||
// User 用户模型,用于用户认证和权限管理
|
||||
type User struct {
|
||||
ID string `json:"id"` // 用户唯一标识
|
||||
Username string `json:"username"` // 用户名(唯一)
|
||||
PasswordHash string `json:"password_hash"` // 密码哈希值
|
||||
Email string `json:"email"` // 用户邮箱
|
||||
Name string `json:"name"` // 用户姓名
|
||||
Phone string `json:"phone"` // 用户手机号
|
||||
Role string `json:"role"` // 用户角色(admin/user)
|
||||
CreatedAt string `json:"created_at"` // 创建时间
|
||||
UpdatedAt string `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// Resume 简历模型,存储个人简历的完整信息
|
||||
type Resume struct {
|
||||
ID string `json:"id"` // 简历唯一标识
|
||||
UserID string `json:"user_id"` // 关联的用户ID
|
||||
Route string `json:"route"` // 访问路由(唯一,如 zhangsan)
|
||||
Password string `json:"password"` // 简历密码(用于访问保护)
|
||||
BasicInfo BasicInfo `json:"basic_info"` // 基本信息
|
||||
Experience []Experience `json:"experience"` // 工作经历列表
|
||||
Education []Education `json:"education"` // 教育背景列表
|
||||
Skills []Skill `json:"skills"` // 技能列表
|
||||
Projects []Project `json:"projects"` // 项目经验列表
|
||||
Template string `json:"template"` // 使用的模板名称(默认modern)
|
||||
ShowInHome bool `json:"show_in_home"` // 是否在首页展示
|
||||
CreatedAt string `json:"created_at"` // 创建时间
|
||||
UpdatedAt string `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// BasicInfo 基本信息,包含个人基本资料
|
||||
type BasicInfo struct {
|
||||
Name string `json:"name"` // 姓名
|
||||
Title string `json:"title"` // 职位/头衔
|
||||
Email string `json:"email"` // 邮箱地址
|
||||
Phone string `json:"phone"` // 手机号码
|
||||
Location string `json:"location"` // 所在地
|
||||
Website string `json:"website"` // 个人网站地址
|
||||
Summary string `json:"summary"` // 个人简介
|
||||
Avatar string `json:"avatar"` // 头像URL
|
||||
ExperienceYears string `json:"experience_years"` // 工作年限
|
||||
JobTarget string `json:"job_target"` // 求职目标
|
||||
Industry string `json:"industry"` // 所属行业
|
||||
CoreAdvantages []string `json:"core_advantages"` // 核心优势列表
|
||||
}
|
||||
|
||||
// Experience 工作经历,记录职业发展历程
|
||||
type Experience struct {
|
||||
ID uint `json:"id"` // 经历唯一标识
|
||||
ResumeID string `json:"resume_id"` // 关联的简历ID
|
||||
Company string `json:"company"` // 公司名称
|
||||
Position string `json:"position"` // 职位名称
|
||||
StartDate string `json:"start_date"` // 开始日期(格式:YYYY-MM)
|
||||
EndDate string `json:"end_date"` // 结束日期(格式:YYYY-MM,"至今"表示当前)
|
||||
Description string `json:"description"` // 工作描述
|
||||
Highlights []string `json:"highlights"` // 工作亮点列表
|
||||
Platforms []string `json:"platforms"` // 线上平台列表
|
||||
}
|
||||
|
||||
// Education 教育背景,记录学习经历
|
||||
type Education struct {
|
||||
ID uint `json:"id"` // 教育背景唯一标识
|
||||
ResumeID string `json:"resume_id"` // 关联的简历ID
|
||||
School string `json:"school"` // 学校名称
|
||||
Degree string `json:"degree"` // 学位(本科/硕士/博士等)
|
||||
Major string `json:"major"` // 专业名称
|
||||
StartDate string `json:"start_date"` // 入学日期(格式:YYYY-MM)
|
||||
EndDate string `json:"end_date"` // 毕业日期(格式:YYYY-MM)
|
||||
GPA string `json:"gpa"` // GPA成绩
|
||||
}
|
||||
|
||||
// Skill 技能,记录个人技能和熟练程度
|
||||
type Skill struct {
|
||||
ID uint `json:"id"` // 技能唯一标识
|
||||
ResumeID string `json:"resume_id"` // 关联的简历ID
|
||||
Name string `json:"name"` // 技能名称
|
||||
Level string `json:"level"` // 熟练程度(beginner/intermediate/advanced/expert)
|
||||
Category string `json:"category"` // 技能分类(后端/前端/数据库/运维等)
|
||||
}
|
||||
|
||||
// Project 项目经验,记录参与的项目
|
||||
type Project struct {
|
||||
ID uint `json:"id"` // 项目唯一标识
|
||||
ResumeID string `json:"resume_id"` // 关联的简历ID
|
||||
Name string `json:"name"` // 项目名称
|
||||
Description string `json:"description"` // 项目描述
|
||||
TechStack []string `json:"tech_stack"` // 技术栈列表
|
||||
URL string `json:"url"` // 项目链接
|
||||
Highlights []string `json:"highlights"` // 项目亮点列表
|
||||
Achievements []string `json:"achievements"` // 项目成果列表
|
||||
StartDate string `json:"start_date"` // 开始日期(格式:YYYY-MM)
|
||||
EndDate string `json:"end_date"` // 结束日期(格式:YYYY-MM)
|
||||
ShowInResume bool `json:"show_in_resume"` // 是否在简历中显示
|
||||
}
|
||||
|
||||
// PortfolioItem 作品集项目,用于展示详细的项目文档
|
||||
type PortfolioItem struct {
|
||||
ID uint `json:"id"` // 作品集项目唯一标识
|
||||
UserID string `json:"user_id"` // 关联的用户ID
|
||||
Name string `json:"name"` // 项目名称
|
||||
Description string `json:"description"` // 项目描述
|
||||
TechStack []string `json:"tech_stack"` // 技术栈列表
|
||||
URL string `json:"url"` // 项目链接
|
||||
StartDate string `json:"start_date"` // 开始日期(格式:YYYY-MM)
|
||||
EndDate string `json:"end_date"` // 结束日期(格式:YYYY-MM)
|
||||
Doc string `json:"doc"` // 项目文档(Markdown格式)
|
||||
ShowInResume bool `json:"show_in_resume"` // 是否在简历中显示
|
||||
ResumeID string `json:"resume_id"` // 关联的简历ID
|
||||
ProjectID uint `json:"project_id"` // 关联的简历项目ID
|
||||
Password string `json:"password"` // 访问密码
|
||||
Hidden bool `json:"hidden"` // 是否隐藏
|
||||
}
|
||||
|
||||
// ResumeUpdate 简历更新请求模型,用于部分更新简历内容
|
||||
type ResumeUpdate struct {
|
||||
BasicInfo *BasicInfo `json:"basic_info"` // 基本信息(可选)
|
||||
Experience *[]Experience `json:"experience"` // 工作经历列表(可选)
|
||||
Education *[]Education `json:"education"` // 教育背景列表(可选)
|
||||
Skills *[]Skill `json:"skills"` // 技能列表(可选)
|
||||
Projects *[]Project `json:"projects"` // 项目经验列表(可选)
|
||||
Template *string `json:"template"` // 模板名称(可选)
|
||||
ShowInHome *bool `json:"show_in_home"` // 是否在首页展示(可选)
|
||||
Route *string `json:"route"` // 访问路由(可选)
|
||||
Password *string `json:"password"` // 简历密码(可选)
|
||||
}
|
||||
|
||||
// QuizQuestion 面试题题目模型
|
||||
type QuizQuestion struct {
|
||||
Type string `json:"type"` // 题目类型:mcq(选择题)、fill(填空题)、sa(简答题)、algo(算法设计题)
|
||||
Text string `json:"text"` // 题目内容
|
||||
Options []string `json:"options"` // 选项(选择题)
|
||||
Answer string `json:"answer"` // 参考答案
|
||||
Analysis string `json:"analysis"` // 答案解析(详细拓展)
|
||||
Score int `json:"score"` // 分值
|
||||
Keywords []string `json:"keywords"` // 关联关键词
|
||||
Difficulty string `json:"difficulty"` // 难度级别:入门、初级、中级、进阶、高级
|
||||
Category string `json:"category"` // 题目分类
|
||||
}
|
||||
|
||||
// QuizRecord 面试题历史记录模型
|
||||
type QuizRecord struct {
|
||||
ID string `json:"id"` // 记录唯一标识
|
||||
UserID string `json:"user_id"` // 关联的用户ID
|
||||
ResumeID string `json:"resume_id"` // 关联的简历ID
|
||||
ResumeRoute string `json:"resume_route"` // 关联的简历路由
|
||||
Title string `json:"title"` // 答题记录标题
|
||||
Questions []QuizQuestion `json:"questions"` // 题目列表
|
||||
UserAnswers map[string]string `json:"user_answers"` // 用户答案
|
||||
Score float64 `json:"score"` // 得分
|
||||
CorrectCount int `json:"correct_count"` // 正确题数
|
||||
TotalCount int `json:"total_count"` // 总题数
|
||||
CreatedAt string `json:"created_at"` // 创建时间
|
||||
}
|
||||
|
||||
// FavoriteQuestion 收藏/错题本模型
|
||||
type FavoriteQuestion struct {
|
||||
ID string `json:"id"` // 记录唯一标识
|
||||
UserID string `json:"user_id"` // 关联的用户ID
|
||||
ResumeID string `json:"resume_id"` // 关联的简历ID
|
||||
ResumeRoute string `json:"resume_route"` // 关联的简历路由
|
||||
Question QuizQuestion `json:"question"` // 题目内容
|
||||
UserAnswer string `json:"user_answer"` // 用户答案
|
||||
IsCorrect bool `json:"is_correct"` // 是否正确
|
||||
IsFavorite bool `json:"is_favorite"` // 是否收藏
|
||||
CreatedAt string `json:"created_at"` // 添加时间
|
||||
}
|
||||
Reference in New Issue
Block a user