重构一下数据库

This commit is contained in:
2026-01-18 20:35:21 +08:00
parent 485307e7de
commit ff4e069a7e
20 changed files with 477 additions and 131 deletions

View File

@@ -0,0 +1,28 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// ForumBoards is the golang structure of table forum_boards for DAO operations like Where/Data.
type ForumBoards struct {
g.Meta `orm:"table:forum_boards, do:true"`
Id any // 版块ID主键
SectionId any // 所属频道ID关联 forum_sections.id无外键可为空=不分区)
Name any // 版块名称
Description any // 版块简介
CoverImage any // 版块封面图URL
Status any // 状态normal=正常 hidden=隐藏 deleted=删除
DisplayOrder any // 排序值(越大越靠前)
PostCount any // 帖子总数(冗余)
TodayPostCount any // 今日发帖数(冗余,可选)
LastPostId any // 最后一篇帖子ID冗余可选
LastPostAt *gtime.Time // 最后发帖时间(冗余,可选)
CreatedAt *gtime.Time // 创建时间
UpdatedAt *gtime.Time // 更新时间
}

View File

@@ -11,16 +11,16 @@ import (
// ForumComments is the golang structure of table forum_comments for DAO operations like Where/Data.
type ForumComments struct {
g.Meta `orm:"table:forum_comments, do:true"`
Id any // 评论ID主键
UserId any // 评论发布者ID关联users.id无外键
PostId any // 所属帖子ID关联forum_posts.id无外键
ParentId any // 父评论IDNULL=评论非NULL=回复某条评论
Content any // 评论内容支持emoji
Status any // 评论状态normal=正常 deleted=软删除 audit=审核中 reject=审核驳回
LikeCount any // 点赞数
ReplyCount any // 回复数(冗余字段
CreatedAt *gtime.Time // 评论创建时间
UpdatedAt *gtime.Time // 评论更新时间
DeletedAt *gtime.Time // 软删除时间
g.Meta `orm:"table:forum_comments, do:true"`
Id any // 评论ID主键
PostId any // 所属帖子ID关联 forum_posts.id无外键
UserId any // 评论发布者ID关联 users.id无外键
ParentId any // 父评论IDNULL=一级评论非NULL=二级评论指向一级评论ID无外键
ReplyToUserId any // 回复的用户ID可选用于展示“回复@xxx”无外键
Content any // 评论内容支持emoji
Status any // 状态normal=正常 deleted=软删 audit=审核中 reject=驳回
LikeCount any // 点赞数(冗余)
CreatedAt *gtime.Time // 创建时间
UpdatedAt *gtime.Time // 更新时间
DeletedAt *gtime.Time // 软删除时间
}

View File

@@ -11,17 +11,23 @@ import (
// ForumPosts is the golang structure of table forum_posts for DAO operations like Where/Data.
type ForumPosts struct {
g.Meta `orm:"table:forum_posts, do:true"`
Id any // 帖子ID主键
UserId any // 发帖用户ID关联users.id无外键
Title any // 帖子标题
Content any // 帖子正文(支持富文本/emoji
CoverImage any // 帖子封面图URL
Status any // 帖子状态normal=正常 deleted=软删除 audit=审核中 reject=审核驳回
ViewCount any // 浏览量(冗余字段)
LikeCount any // 点赞数(冗余字段)
CommentCount any // 评论数(冗余字段)
CreatedAt *gtime.Time // 发帖时间
UpdatedAt *gtime.Time // 更新时间
DeletedAt *gtime.Time // 软删除时间
g.Meta `orm:"table:forum_posts, do:true"`
Id any // 帖子ID主键
BoardId any // 所属版块ID关联 forum_boards.id无外键
UserId any // 发帖用户ID关联 users.id无外键
Title any // 帖子标题
Content any // 帖子正文(支持富文本/emoji
CoverImage any // 帖子封面图URL
Status any // 状态normal=正常 deleted=软删 audit=审核中 reject=驳回
IsPinned any // 是否置顶0否 1是
IsEssence any // 是否精华0否 1是
ViewCount any // 浏览量(冗余)
LikeCount any // 点赞数(冗余)
CommentCount any // 评论数(冗余)
CollectCount any // 收藏数(冗余,可选)
LastCommentId any // 最后一条评论ID冗余可选
LastCommentAt *gtime.Time // 最后评论时间(冗余,可选)
CreatedAt *gtime.Time // 发帖时间
UpdatedAt *gtime.Time // 更新时间
DeletedAt *gtime.Time // 软删除时间
}

View File

@@ -0,0 +1,23 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// ForumSections is the golang structure of table forum_sections for DAO operations like Where/Data.
type ForumSections struct {
g.Meta `orm:"table:forum_sections, do:true"`
Id any // 频道/分区ID主键
Name any // 频道名称
Description any // 频道简介
Icon any // 频道图标URL
Status any // 状态normal=正常 hidden=隐藏 deleted=删除
DisplayOrder any // 排序值(越大越靠前)
CreatedAt *gtime.Time // 创建时间
UpdatedAt *gtime.Time // 更新时间
}

View File

@@ -18,16 +18,12 @@ type Users struct {
Nickname any // 昵称
Gender any // 性别0未知 1男 2女
BirthDate *gtime.Time // 生日
UserType any // 用户类型:normal普通用户vip为VIP用户
VipStartAt *gtime.Time // VIP开始时间
VipEndAt *gtime.Time // VIP结束时间
UserType any // 用户类型:1 user 2 admin
CreatedAt *gtime.Time // 创建时间
UpdatedAt *gtime.Time // 更新时间
RealityRole any // 现实身份/角色
AbnormalRole any // 异常身份/角色
JobTitle any // 职位
Commendation any //
Admonition any //
Email any //
RedTrace any // 红轨
YellowTrace any // 黄轨

View File

@@ -0,0 +1,26 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package entity
import (
"github.com/gogf/gf/v2/os/gtime"
)
// ForumBoards is the golang structure for table forum_boards.
type ForumBoards struct {
Id uint64 `json:"id" orm:"id" description:"版块ID主键"` // 版块ID主键
SectionId uint64 `json:"sectionId" orm:"section_id" description:"所属频道ID关联 forum_sections.id无外键可为空=不分区)"` // 所属频道ID关联 forum_sections.id无外键可为空=不分区)
Name string `json:"name" orm:"name" description:"版块名称"` // 版块名称
Description string `json:"description" orm:"description" description:"版块简介"` // 版块简介
CoverImage string `json:"coverImage" orm:"cover_image" description:"版块封面图URL"` // 版块封面图URL
Status string `json:"status" orm:"status" description:"状态normal=正常 hidden=隐藏 deleted=删除"` // 状态normal=正常 hidden=隐藏 deleted=删除
DisplayOrder int `json:"displayOrder" orm:"display_order" description:"排序值(越大越靠前)"` // 排序值(越大越靠前)
PostCount uint `json:"postCount" orm:"post_count" description:"帖子总数(冗余)"` // 帖子总数(冗余)
TodayPostCount uint `json:"todayPostCount" orm:"today_post_count" description:"今日发帖数(冗余,可选)"` // 今日发帖数(冗余,可选)
LastPostId uint64 `json:"lastPostId" orm:"last_post_id" description:"最后一篇帖子ID冗余可选"` // 最后一篇帖子ID冗余可选
LastPostAt *gtime.Time `json:"lastPostAt" orm:"last_post_at" description:"最后发帖时间(冗余,可选)"` // 最后发帖时间(冗余,可选)
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
}

View File

@@ -10,15 +10,15 @@ import (
// ForumComments is the golang structure for table forum_comments.
type ForumComments struct {
Id uint64 `json:"id" orm:"id" description:"评论ID主键"` // 评论ID主键
UserId uint64 `json:"userId" orm:"user_id" description:"评论发布者ID关联users.id无外键"` // 评论发布者ID关联users.id无外键
PostId uint64 `json:"postId" orm:"post_id" description:"所属帖子ID关联forum_posts.id无外键"` // 所属帖子ID关联forum_posts.id无外键
ParentId uint64 `json:"parentId" orm:"parent_id" description:"父评论IDNULL=评论非NULL=回复某条评论)"` // 父评论IDNULL=评论非NULL=回复某条评论
Content string `json:"content" orm:"content" description:"评论内容支持emoji"` // 评论内容支持emoji
Status string `json:"status" orm:"status" description:"评论状态normal=正常 deleted=软删除 audit=审核中 reject=审核驳回"` // 评论状态normal=正常 deleted=软删除 audit=审核中 reject=审核驳回
LikeCount uint `json:"likeCount" orm:"like_count" description:"点赞数"` // 点赞数
ReplyCount uint `json:"replyCount" orm:"reply_count" description:"回复数(冗余字段"` // 回复数(冗余字段
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"评论创建时间"` // 评论创建时间
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"评论更新时间"` // 评论更新时间
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间"` // 软删除时间
Id uint64 `json:"id" orm:"id" description:"评论ID主键"` // 评论ID主键
PostId uint64 `json:"postId" orm:"post_id" description:"所属帖子ID关联 forum_posts.id无外键"` // 所属帖子ID关联 forum_posts.id无外键
UserId uint64 `json:"userId" orm:"user_id" description:"评论发布者ID关联 users.id无外键"` // 评论发布者ID关联 users.id无外键
ParentId uint64 `json:"parentId" orm:"parent_id" description:"父评论IDNULL=一级评论非NULL=二级评论指向一级评论ID无外键"` // 父评论IDNULL=一级评论非NULL=二级评论指向一级评论ID无外键
ReplyToUserId uint64 `json:"replyToUserId" orm:"reply_to_user_id" description:"回复的用户ID可选用于展示“回复@xxx”无外键"` // 回复的用户ID可选用于展示“回复@xxx”无外键
Content string `json:"content" orm:"content" description:"评论内容支持emoji"` // 评论内容支持emoji
Status string `json:"status" orm:"status" description:"状态normal=正常 deleted=软删 audit=审核中 reject=驳回"` // 状态normal=正常 deleted=软删 audit=审核中 reject=驳回
LikeCount uint `json:"likeCount" orm:"like_count" description:"点赞数(冗余)"` // 点赞数(冗余)
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间"` // 软删除时间
}

View File

@@ -10,16 +10,22 @@ import (
// ForumPosts is the golang structure for table forum_posts.
type ForumPosts struct {
Id uint64 `json:"id" orm:"id" description:"帖子ID主键"` // 帖子ID主键
UserId uint64 `json:"userId" orm:"user_id" description:"发帖用户ID关联users.id无外键"` // 发帖用户ID关联users.id无外键
Title string `json:"title" orm:"title" description:"帖子标题"` // 帖子标题
Content string `json:"content" orm:"content" description:"帖子正文(支持富文本/emoji"` // 帖子正文(支持富文本/emoji
CoverImage string `json:"coverImage" orm:"cover_image" description:"帖子封面图URL"` // 帖子封面图URL
Status string `json:"status" orm:"status" description:"帖子状态normal=正常 deleted=软删除 audit=审核中 reject=审核驳回"` // 帖子状态normal=正常 deleted=软删除 audit=审核中 reject=审核驳回
ViewCount uint `json:"viewCount" orm:"view_count" description:"浏览量(冗余字段)"` // 浏览量(冗余字段)
LikeCount uint `json:"likeCount" orm:"like_count" description:"点赞数(冗余字段)"` // 点赞数(冗余字段)
CommentCount uint `json:"commentCount" orm:"comment_count" description:"评论数(冗余字段)"` // 评论数(冗余字段)
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"发帖时间"` // 发帖时间
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间"` // 软删除时间
Id uint64 `json:"id" orm:"id" description:"帖子ID主键"` // 帖子ID主键
BoardId uint64 `json:"boardId" orm:"board_id" description:"所属版块ID关联 forum_boards.id无外键"` // 所属版块ID关联 forum_boards.id无外键
UserId uint64 `json:"userId" orm:"user_id" description:"发帖用户ID关联 users.id无外键"` // 发帖用户ID关联 users.id无外键
Title string `json:"title" orm:"title" description:"帖子标题"` // 帖子标题
Content string `json:"content" orm:"content" description:"帖子正文(支持富文本/emoji"` // 帖子正文(支持富文本/emoji
CoverImage string `json:"coverImage" orm:"cover_image" description:"帖子封面图URL"` // 帖子封面图URL
Status string `json:"status" orm:"status" description:"状态normal=正常 deleted=软删 audit=审核中 reject=驳回"` // 状态normal=正常 deleted=软删 audit=审核中 reject=驳回
IsPinned int `json:"isPinned" orm:"is_pinned" description:"是否置顶0否 1是"` // 是否置顶0否 1是
IsEssence int `json:"isEssence" orm:"is_essence" description:"是否精华0否 1是"` // 是否精华0否 1是
ViewCount uint `json:"viewCount" orm:"view_count" description:"浏览量(冗余)"` // 浏览量(冗余)
LikeCount uint `json:"likeCount" orm:"like_count" description:"点赞数(冗余)"` // 点赞数(冗余)
CommentCount uint `json:"commentCount" orm:"comment_count" description:"评论数(冗余)"` // 评论数(冗余)
CollectCount uint `json:"collectCount" orm:"collect_count" description:"收藏数(冗余,可选)"` // 收藏数(冗余,可选)
LastCommentId uint64 `json:"lastCommentId" orm:"last_comment_id" description:"最后一条评论ID冗余可选"` // 最后一条评论ID冗余可选
LastCommentAt *gtime.Time `json:"lastCommentAt" orm:"last_comment_at" description:"最后评论时间(冗余,可选)"` // 最后评论时间(冗余,可选)
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"发帖时间"` // 发帖时间
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间"` // 软删除时间
}

View File

@@ -0,0 +1,21 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package entity
import (
"github.com/gogf/gf/v2/os/gtime"
)
// ForumSections is the golang structure for table forum_sections.
type ForumSections struct {
Id uint64 `json:"id" orm:"id" description:"频道/分区ID主键"` // 频道/分区ID主键
Name string `json:"name" orm:"name" description:"频道名称"` // 频道名称
Description string `json:"description" orm:"description" description:"频道简介"` // 频道简介
Icon string `json:"icon" orm:"icon" description:"频道图标URL"` // 频道图标URL
Status string `json:"status" orm:"status" description:"状态normal=正常 hidden=隐藏 deleted=删除"` // 状态normal=正常 hidden=隐藏 deleted=删除
DisplayOrder int `json:"displayOrder" orm:"display_order" description:"排序值(越大越靠前)"` // 排序值(越大越靠前)
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
}

View File

@@ -10,24 +10,20 @@ import (
// Users is the golang structure for table users.
type Users struct {
Id uint64 `json:"id" orm:"id" description:"用户ID"` // 用户ID
Account string `json:"account" orm:"account" description:"账号"` // 账号
Password string `json:"password" orm:"password" description:"密码哈希"` // 密码哈希
Nickname string `json:"nickname" orm:"nickname" description:"昵称"` // 昵称
Gender int `json:"gender" orm:"gender" description:"性别0未知 1男 2女"` // 性别0未知 1男 2女
BirthDate *gtime.Time `json:"birthDate" orm:"birth_date" description:"生日"` // 生日
UserType string `json:"userType" orm:"user_type" description:"用户类型:normal普通用户vip为VIP用户"` // 用户类型normal普通用户vip为VIP用户
VipStartAt *gtime.Time `json:"vipStartAt" orm:"vip_start_at" description:"VIP开始时间"` // VIP开始时间
VipEndAt *gtime.Time `json:"vipEndAt" orm:"vip_end_at" description:"VIP结束时间"` // VIP结束时间
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
RealityRole string `json:"realityRole" orm:"reality_role" description:"现实身份/角色"` // 现实身份/角色
AbnormalRole string `json:"abnormalRole" orm:"abnormal_role" description:"异常身份/角色"` // 异常身份/角色
JobTitle string `json:"jobTitle" orm:"job_title" description:"职位"` // 职位
Commendation int `json:"commendation" orm:"Commendation" description:""` //
Admonition int `json:"admonition" orm:"Admonition" description:""` //
Email string `json:"email" orm:"email" description:""` //
RedTrace int `json:"redTrace" orm:"red_trace" description:"红轨"` // 红轨
YellowTrace int `json:"yellowTrace" orm:"yellow_trace" description:"黄轨"` // 黄轨
BlueTrace int `json:"blueTrace" orm:"blue_trace" description:"蓝轨"` // 蓝轨
Id uint64 `json:"id" orm:"id" description:"用户ID"` // 用户ID
Account string `json:"account" orm:"account" description:"账号"` // 账号
Password string `json:"password" orm:"password" description:"密码哈希"` // 密码哈希
Nickname string `json:"nickname" orm:"nickname" description:"昵称"` // 昵称
Gender int `json:"gender" orm:"gender" description:"性别0未知 1男 2女"` // 性别0未知 1男 2女
BirthDate *gtime.Time `json:"birthDate" orm:"birth_date" description:"生日"` // 生日
UserType string `json:"userType" orm:"user_type" description:"用户类型:1 user 2 admin"` // 用户类型1 user 2 admin
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
RealityRole string `json:"realityRole" orm:"reality_role" description:"现实身份/角色"` // 现实身份/角色
AbnormalRole string `json:"abnormalRole" orm:"abnormal_role" description:"异常身份/角色"` // 异常身份/角色
JobTitle string `json:"jobTitle" orm:"job_title" description:"职位"` // 职位
Email string `json:"email" orm:"email" description:""` //
RedTrace int `json:"redTrace" orm:"red_trace" description:"红轨"` // 红轨
YellowTrace int `json:"yellowTrace" orm:"yellow_trace" description:"黄轨"` // 黄轨
BlueTrace int `json:"blueTrace" orm:"blue_trace" description:"蓝轨"` // 蓝轨
}