This commit is contained in:
sjk
2026-01-06 19:36:42 +08:00
parent 15b579d64a
commit 19942144fb
261 changed files with 24034 additions and 5477 deletions

View File

@@ -6,8 +6,8 @@ import (
// Enterprise 企业表
type Enterprise struct {
ID int `gorm:"primaryKey;autoIncrement" json:"id"`
EnterpriseID string `gorm:"type:varchar(255);not null;default:''" json:"enterprise_id" comment:"企业ID"`
ID int `gorm:"primaryKey;column:id;autoIncrement" json:"id"`
EnterpriseID string `gorm:"column:enterprise_id;type:varchar(255);not null;default:''" json:"enterprise_id" comment:"企业ID"`
Name string `gorm:"type:varchar(200);not null;default:''" json:"name" comment:"企业名称"`
ShortName string `gorm:"type:varchar(100);not null;default:''" json:"short_name" comment:"企业简称"`
Icon string `gorm:"type:varchar(500);not null;default:''" json:"icon" comment:"企业图标URL"`
@@ -27,24 +27,22 @@ type Enterprise struct {
UpdatedAt time.Time `json:"updated_at" comment:"更新时间"`
}
// User 用户账号表原Employee对应ai_users
// User 用户账号表(原Employee,对应ai_users)
type User struct {
ID int `gorm:"primaryKey;autoIncrement" json:"id"`
EnterpriseID int `gorm:"not null;default:0;index:idx_enterprise_id" json:"enterprise_id" comment:"所属企业ID"`
Enterprise Enterprise `gorm:"foreignKey:EnterpriseID" json:"enterprise,omitempty"`
Enterprise Enterprise `gorm:"foreignKey:EnterpriseID;references:ID" json:"enterprise,omitempty"`
EnterpriseName string `gorm:"type:varchar(255);not null;default:''" json:"enterprise_name" comment:"企业名称"`
Username string `gorm:"type:varchar(50);not null;default:'';uniqueIndex:uk_username" json:"username" comment:"用户名"`
Password string `gorm:"type:varchar(255);not null;default:''" json:"-" comment:"密码"`
RealName string `gorm:"type:varchar(50)" json:"real_name" comment:"真实姓名"`
Nickname string `gorm:"type:varchar(256);not null;default:''" json:"nickname" comment:"用户昵称"`
Icon string `gorm:"type:varchar(512);not null;default:''" json:"icon" comment:"企业图标URL"`
Email string `gorm:"type:varchar(100)" json:"email" comment:"邮箱"`
Phone string `gorm:"type:varchar(20)" json:"phone" comment:"手机号"`
WechatOpenID *string `gorm:"column:wechat_openid;type:varchar(100);uniqueIndex:uk_wechat_openid" json:"wechat_openid,omitempty" comment:"微信OpenID"`
WechatUnionID *string `gorm:"column:wechat_unionid;type:varchar(100)" json:"wechat_unionid,omitempty" comment:"微信UnionID"`
XHSPhone string `gorm:"type:varchar(20);not null;default:''" json:"xhs_phone" comment:"小红书绑定手机号"`
XHSAccount string `gorm:"type:varchar(255);not null;default:''" json:"xhs_account" comment:"小红书账号名称"`
XHSCookie string `gorm:"type:text" json:"xhs_cookie" comment:"小红书Cookie"`
IsBoundXHS int `gorm:"type:tinyint(1);not null;default:0;index:idx_is_bound_xhs" json:"is_bound_xhs" comment:"是否绑定小红书0=未绑定1=已绑定"`
BoundAt *time.Time `json:"bound_at" comment:"绑定小红书的时间"`
Department string `gorm:"type:varchar(50)" json:"department" comment:"部门"`
Role string `gorm:"type:enum('admin','editor','reviewer','publisher','each_title_reviewer','enterprise');default:'editor'" json:"role" comment:"角色"`
Status string `gorm:"type:enum('active','inactive','deleted');default:'active';index:idx_status" json:"status" comment:"状态"`
@@ -72,37 +70,43 @@ type Product struct {
UpdatedAt time.Time `json:"updated_at" comment:"更新时间"`
}
// Article 文章表原Copy对应ai_articles
// Article 文章表(原Copy,对应ai_articles)
type Article struct {
ID int `gorm:"primaryKey;autoIncrement" json:"id"`
BatchID uint64 `gorm:"type:bigint unsigned;not null;default:0" json:"batch_id" comment:"批次ID"`
EnterpriseID int `gorm:"not null;default:0;index:idx_enterprise_id" json:"enterprise_id" comment:"所属企业ID"`
ProductID int `gorm:"not null;default:0;index:idx_product_id" json:"product_id" comment:"关联产品ID"`
TopicTypeID int `gorm:"type:int unsigned;not null;default:0" json:"topic_type_id" comment:"topic类型ID"`
PromptWorkflowID int `gorm:"type:int unsigned;not null;default:0" json:"prompt_workflow_id" comment:"提示词工作流ID"`
Topic string `gorm:"type:varchar(255);not null;default:''" json:"topic" comment:"topic主题"`
Title string `gorm:"type:varchar(200);not null;default:''" json:"title" comment:"标题"`
Content string `gorm:"type:text" json:"content" comment:"文章内容"`
Department string `gorm:"type:varchar(255);not null;default:''" json:"department" comment:"部门"`
DepartmentIDs string `gorm:"column:departmentids;type:varchar(255);not null;default:''" json:"department_ids" comment:"部门IDs"`
AuthorID *int `json:"author_id" comment:"作者ID"`
AuthorName string `gorm:"type:varchar(100)" json:"author_name" comment:"作者名称"`
DepartmentID *int `json:"department_id" comment:"部门ID"`
DepartmentName string `gorm:"type:varchar(255)" json:"department_name" comment:"部门名称"`
CreatedUserID int `gorm:"not null;default:0" json:"created_user_id" comment:"创建用户ID"`
ReviewUserID *int `json:"review_user_id" comment:"审核用户ID"`
PublishUserID *int `json:"publish_user_id" comment:"发布用户ID"`
Status string `gorm:"type:enum('topic','cover_image','generate','generate_failed','draft','pending_review','assign_authors','approved','rejected','published_review','published','failed');default:'draft';index:idx_status" json:"status" comment:"状态"`
Channel int `gorm:"type:tinyint(1);not null;default:1" json:"channel" comment:"渠道1=baidu|2=toutiao|3=weixin"`
ReviewComment string `gorm:"type:text" json:"review_comment" comment:"审核评论"`
PublishTime *time.Time `json:"publish_time" comment:"发布时间"`
BaijiahaoID string `gorm:"type:varchar(100)" json:"baijiahao_id" comment:"百家号ID"`
BaijiahaoStatus string `gorm:"type:varchar(50)" json:"baijiahao_status" comment:"百家号状态"`
WordCount int `gorm:"default:0" json:"word_count" comment:"字数统计"`
ImageCount int `gorm:"default:0" json:"image_count" comment:"图片数量"`
CozeTag string `gorm:"type:varchar(500)" json:"coze_tag" comment:"Coze生成的标签"`
CreatedAt time.Time `gorm:"index:idx_created_at" json:"created_at" comment:"创建时间"`
UpdatedAt time.Time `gorm:"index:idx_updated_at" json:"updated_at" comment:"更新时间"`
ID int `gorm:"primaryKey;autoIncrement" json:"id"`
BatchID uint64 `gorm:"type:bigint unsigned;not null;default:0" json:"batch_id" comment:"批次ID"`
EnterpriseID int `gorm:"not null;default:0;index:idx_enterprise_id" json:"enterprise_id" comment:"所属企业ID"`
ProductID int `gorm:"not null;default:0;index:idx_product_id" json:"product_id" comment:"关联产品ID"`
ProductName string `gorm:"type:varchar(256);not null;default:''" json:"product_name" comment:"产品名称"`
TopicTypeID int `gorm:"type:int unsigned;not null;default:0" json:"topic_type_id" comment:"topic类型ID"`
PromptWorkflowID int `gorm:"type:int unsigned;not null;default:0" json:"prompt_workflow_id" comment:"提示词工作流ID"`
PromptWorkflowName string `gorm:"type:varchar(100);not null;default:''" json:"prompt_workflow_name" comment:"提示词工作流名称"`
Topic string `gorm:"type:varchar(255);not null;default:''" json:"topic" comment:"topic主题"`
Title string `gorm:"type:varchar(200);not null;default:''" json:"title" comment:"标题"`
ContextSummary string `gorm:"type:varchar(1024);not null;default:''" json:"context_summary" comment:"上下文摘要"`
Content string `gorm:"type:text" json:"content" comment:"文章内容"`
Department string `gorm:"type:varchar(255);not null;default:''" json:"department" comment:"部门"`
DepartmentIDs string `gorm:"column:departmentids;type:varchar(255);not null;default:''" json:"department_ids" comment:"部门IDs"`
AuthorID *int `json:"author_id" comment:"作者ID"`
AuthorName string `gorm:"type:varchar(100)" json:"author_name" comment:"作者名称"`
DepartmentID *int `json:"department_id" comment:"部门ID"`
DepartmentName string `gorm:"type:varchar(255)" json:"department_name" comment:"部门名称"`
CreatedUserID int `gorm:"not null;default:0" json:"created_user_id" comment:"创建用户ID"`
ReviewUserID *int `json:"review_user_id" comment:"审核用户ID"`
PublishUserID *int `json:"publish_user_id" comment:"发布用户ID"`
Status string `gorm:"type:enum('topic','cover_image','generate','generate_failed','draft','pending_review','assign_authors','approved','rejected','published_review','published','failed');default:'draft';index:idx_status" json:"status" comment:"状态"`
Channel int `gorm:"type:tinyint(1);not null;default:1" json:"channel" comment:"渠道1=小红书|2=douyin|3=toutiao|4=weixin"`
ReviewComment string `gorm:"type:text" json:"review_comment" comment:"审核评论"`
PublishTime *time.Time `json:"publish_time" comment:"发布时间"`
BaijiahaoID string `gorm:"type:varchar(100)" json:"baijiahao_id" comment:"百家号ID"`
BaijiahaoStatus string `gorm:"type:varchar(50)" json:"baijiahao_status" comment:"百家号状态"`
WordCount int `gorm:"default:0" json:"word_count" comment:"字数统计"`
ImageCount int `gorm:"default:0" json:"image_count" comment:"图片数量"`
CozeTag string `gorm:"type:varchar(500)" json:"coze_tag" comment:"Coze生成的标签"`
CreatedAt time.Time `gorm:"index:idx_created_at" json:"created_at" comment:"创建时间"`
UpdatedAt time.Time `gorm:"index:idx_updated_at" json:"updated_at" comment:"更新时间"`
// 关联字段
Images []ArticleImage `gorm:"foreignKey:ArticleID" json:"images,omitempty" comment:"文章图片"`
}
// Copy 文案表别名,兼容旧代码
@@ -120,10 +124,10 @@ type PublishRecord struct {
ReviewUserID *int `json:"review_user_id" comment:"审核用户ID"`
PublishUserID *int `json:"publish_user_id" comment:"发布用户ID"`
Status string `gorm:"type:enum('topic','cover_image','generate','generate_failed','draft','pending_review','assign_authors','approved','rejected','published_review','published','failed');default:'draft';index:idx_status" json:"status" comment:"状态"`
Channel int `gorm:"type:tinyint(1);not null;default:1" json:"channel" comment:"渠道1=baidu|2=toutiao|3=weixin"`
Channel int `gorm:"type:tinyint(1);not null;default:1" json:"channel" comment:"渠道1=小红书|2=douyin|3=toutiao|4=weixin"`
ReviewComment string `gorm:"type:text" json:"review_comment" comment:"审核评论"`
PublishTime *time.Time `json:"publish_time" comment:"发布时间"`
PublishLink string `gorm:"type:varchar(128);not null;default:''" json:"publish_link" comment:"发布访问链接"`
PublishLink string `gorm:"type:varchar(255);not null;default:''" json:"publish_link" comment:"发布访问链接"`
WordCount int `gorm:"default:0" json:"word_count" comment:"字数统计"`
ImageCount int `gorm:"default:0" json:"image_count" comment:"图片数量"`
CreatedAt time.Time `gorm:"index:idx_created_at" json:"created_at" comment:"创建时间"`
@@ -243,29 +247,46 @@ type Log struct {
CreatedAt time.Time `gorm:"index:idx_created_at" json:"created_at" comment:"创建时间"`
}
// Author 作者表对应ai_authors
// Author 作者表(对应ai_authors)
type Author struct {
ID int `gorm:"primaryKey;autoIncrement" json:"id"`
EnterpriseID int `gorm:"not null;default:0" json:"enterprise_id" comment:"所属企业ID"`
CreatedUserID int `gorm:"not null;default:0" json:"created_user_id" comment:"创建用户ID"`
Phone string `gorm:"type:varchar(20)" json:"phone" comment:"手机号"`
AuthorName string `gorm:"type:varchar(100);not null;default:''" json:"author_name" comment:"作者名称"`
AppID string `gorm:"type:varchar(127);not null;default:''" json:"app_id" comment:"应用ID"`
AppToken string `gorm:"type:varchar(127);not null;default:''" json:"app_token" comment:"应用Token"`
DepartmentID int `gorm:"not null;default:0" json:"department_id" comment:"部门ID"`
DepartmentName string `gorm:"type:varchar(255);not null;default:''" json:"department_name" comment:"部门名称"`
Department string `gorm:"type:varchar(50);not null;default:''" json:"department" comment:"部门"`
Title string `gorm:"type:varchar(50)" json:"title" comment:"职称"`
Hospital string `gorm:"type:varchar(100)" json:"hospital" comment:"医院"`
Specialty string `gorm:"type:text" json:"specialty" comment:"专业"`
ToutiaoCookie string `gorm:"type:text" json:"toutiao_cookie" comment:"头条Cookie"`
ToutiaoImagesCookie string `gorm:"type:text" json:"toutiao_images_cookie" comment:"头条图片Cookie"`
Introduction string `gorm:"type:text" json:"introduction" comment:"介绍"`
AvatarURL string `gorm:"type:varchar(255)" json:"avatar_url" comment:"头像URL"`
Status string `gorm:"type:enum('active','inactive');default:'active';index:idx_status" json:"status" comment:"状态"`
Channel int `gorm:"type:tinyint(1);not null;default:1" json:"channel" comment:"渠道1=baidu|2=toutiao|3=weixin"`
CreatedAt time.Time `gorm:"index:idx_created_at" json:"created_at" comment:"创建时间"`
UpdatedAt time.Time `json:"updated_at" comment:"更新时间"`
ID int `gorm:"primaryKey;autoIncrement" json:"id"`
EnterpriseID int `gorm:"not null;default:0" json:"enterprise_id" comment:"所属企业ID"`
CreatedUserID int `gorm:"not null;default:0" json:"created_user_id" comment:"创建用户ID"`
Phone string `gorm:"type:varchar(20)" json:"phone" comment:"手机号"`
AuthorName string `gorm:"type:varchar(100);not null;default:''" json:"author_name" comment:"作者名称"`
XHSCookie string `gorm:"type:text" json:"xhs_cookie" comment:"小红书登录状态login_state JSON"`
XHSPhone string `gorm:"type:varchar(20);not null;default:''" json:"xhs_phone" comment:"小红书绑定手机号"`
XHSAccount string `gorm:"type:varchar(255);not null;default:''" json:"xhs_account" comment:"小红书账号名称"`
BoundAt *time.Time `json:"bound_at" comment:"绑定的时间"`
AppID string `gorm:"type:varchar(127);not null;default:''" json:"app_id" comment:"应用ID"`
AppToken string `gorm:"type:varchar(127);not null;default:''" json:"app_token" comment:"应用Token"`
DepartmentID int `gorm:"not null;default:0" json:"department_id" comment:"部门ID"`
DepartmentName string `gorm:"type:varchar(255);not null;default:''" json:"department_name" comment:"部门名称"`
Department string `gorm:"type:varchar(50);not null;default:''" json:"department" comment:"部门"`
Title string `gorm:"type:varchar(50)" json:"title" comment:"职称"`
Hospital string `gorm:"type:varchar(100)" json:"hospital" comment:"医院"`
Specialty string `gorm:"type:text" json:"specialty" comment:"专业"`
ToutiaoCookie string `gorm:"type:text" json:"toutiao_cookie" comment:"头条Cookie"`
ToutiaoImagesCookie string `gorm:"type:text" json:"toutiao_images_cookie" comment:"头条图片Cookie"`
Introduction string `gorm:"type:text" json:"introduction" comment:"介绍"`
AvatarURL string `gorm:"type:varchar(255)" json:"avatar_url" comment:"头像URL"`
Status string `gorm:"type:enum('active','inactive');default:'active';index:idx_status" json:"status" comment:"状态"`
Channel int `gorm:"type:tinyint(1);not null;default:1" json:"channel" comment:"渠道1=小红书|2=douyin|3=toutiao|4=weixin"`
CreatedAt time.Time `gorm:"index:idx_created_at" json:"created_at" comment:"创建时间"`
UpdatedAt time.Time `json:"updated_at" comment:"更新时间"`
}
// Feedback 用户反馈表
type Feedback struct {
ID int `gorm:"primaryKey;autoIncrement" json:"id"`
FeedbackType string `gorm:"type:enum('功能建议','Bug反馈','体验问题','其他');not null;index:idx_feedback_type" json:"feedback_type" comment:"反馈类型"`
Description string `gorm:"type:text;charset=utf8mb4;collate=utf8mb4_unicode_ci" json:"description" comment:"问题描述最多500字"`
ContactInfo string `gorm:"type:varchar(255)" json:"contact_info" comment:"联系方式(如邮箱),选填"`
Nickname string `gorm:"type:varchar(255);not null;default:''" json:"nickname" comment:"填写用户昵称"`
CreatedUserID int `gorm:"type:int unsigned;not null;index:idx_created_user_id" json:"created_user_id" comment:"创建该反馈的用户ID关联用户表"`
CreatedAt time.Time `gorm:"index:idx_created_at" json:"created_at" comment:"创建时间"`
UpdatedAt time.Time `json:"updated_at" comment:"更新时间"`
Status string `gorm:"type:enum('待处理','处理中','已解决','已关闭');default:'待处理'" json:"status" comment:"反馈状态"`
}
// TableName 指定表名带ai_前缀
@@ -320,3 +341,7 @@ func (Log) TableName() string {
func (Author) TableName() string {
return "ai_authors"
}
func (Feedback) TableName() string {
return "ai_feedback"
}