feat: implement new structure
This commit is contained in:
@@ -8,8 +8,6 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"quyun/v2/pkg/consts"
|
||||
|
||||
"go.ipao.vip/gen"
|
||||
"go.ipao.vip/gen/types"
|
||||
"gorm.io/gorm"
|
||||
@@ -19,21 +17,25 @@ const TableNameContent = "contents"
|
||||
|
||||
// Content mapped from table <contents>
|
||||
type Content struct {
|
||||
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true;comment:主键ID:自增;用于内容引用" json:"id"` // 主键ID:自增;用于内容引用
|
||||
TenantID int64 `gorm:"column:tenant_id;type:bigint;not null;comment:租户ID:多租户隔离关键字段;所有查询/写入必须限定 tenant_id" json:"tenant_id"` // 租户ID:多租户隔离关键字段;所有查询/写入必须限定 tenant_id
|
||||
UserID int64 `gorm:"column:user_id;type:bigint;not null;comment:用户ID:内容创建者/发布者;用于权限与审计(例如私有内容仅作者可见)" json:"user_id"` // 用户ID:内容创建者/发布者;用于权限与审计(例如私有内容仅作者可见)
|
||||
Title string `gorm:"column:title;type:character varying(255);not null;comment:标题:用于列表展示与搜索;建议限制长度(由业务校验)" json:"title"` // 标题:用于列表展示与搜索;建议限制长度(由业务校验)
|
||||
Description string `gorm:"column:description;type:text;not null;comment:描述:用于详情页展示;可为空字符串" json:"description"` // 描述:用于详情页展示;可为空字符串
|
||||
Status consts.ContentStatus `gorm:"column:status;type:character varying(32);not null;default:draft;comment:状态:draft/reviewing/published/unpublished/blocked;published 才对外展示" json:"status"` // 状态:draft/reviewing/published/unpublished/blocked;published 才对外展示
|
||||
Visibility consts.ContentVisibility `gorm:"column:visibility;type:character varying(32);not null;default:tenant_only;comment:可见性:public/tenant_only/private;仅控制详情可见,正片资源仍需按价格/权益校验" json:"visibility"` // 可见性:public/tenant_only/private;仅控制详情可见,正片资源仍需按价格/权益校验
|
||||
PreviewSeconds int32 `gorm:"column:preview_seconds;type:integer;not null;default:60;comment:试看秒数:默认 60;只对 preview 资源生效;必须为正整数" json:"preview_seconds"` // 试看秒数:默认 60;只对 preview 资源生效;必须为正整数
|
||||
PreviewDownloadable bool `gorm:"column:preview_downloadable;type:boolean;not null;comment:试看是否允许下载:默认 false;当前策略固定为不允许下载(仅 streaming)" json:"preview_downloadable"` // 试看是否允许下载:默认 false;当前策略固定为不允许下载(仅 streaming)
|
||||
PublishedAt time.Time `gorm:"column:published_at;type:timestamp with time zone;comment:发布时间:首次发布时写入;用于时间窗与排序" json:"published_at"` // 发布时间:首次发布时写入;用于时间窗与排序
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp with time zone;comment:软删除时间:非空表示已删除;对外接口需过滤" json:"deleted_at"` // 软删除时间:非空表示已删除;对外接口需过滤
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:timestamp with time zone;not null;default:now();comment:创建时间:默认 now();用于审计与排序" json:"created_at"` // 创建时间:默认 now();用于审计与排序
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp with time zone;not null;default:now();comment:更新时间:默认 now();编辑内容时写入" json:"updated_at"` // 更新时间:默认 now();编辑内容时写入
|
||||
Summary string `gorm:"column:summary;type:character varying(256);not null;comment:简介:用于列表/卡片展示的短文本;建议 <= 256 字符(由业务校验)" json:"summary"` // 简介:用于列表/卡片展示的短文本;建议 <= 256 字符(由业务校验)
|
||||
Tags types.JSON `gorm:"column:tags;type:jsonb;not null;default:[];comment:标签:JSON 数组(字符串列表);用于分类/检索与聚合展示" json:"tags"` // 标签:JSON 数组(字符串列表);用于分类/检索与聚合展示
|
||||
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
|
||||
TenantID int64 `gorm:"column:tenant_id;type:bigint;not null" json:"tenant_id"`
|
||||
UserID int64 `gorm:"column:user_id;type:bigint;not null" json:"user_id"`
|
||||
Title string `gorm:"column:title;type:character varying(255);not null" json:"title"`
|
||||
Description string `gorm:"column:description;type:text;not null" json:"description"`
|
||||
Status string `gorm:"column:status;type:character varying(32);default:draft" json:"status"`
|
||||
Visibility string `gorm:"column:visibility;type:character varying(32);default:tenant_only" json:"visibility"`
|
||||
PreviewSeconds int32 `gorm:"column:preview_seconds;type:integer;default:60" json:"preview_seconds"`
|
||||
PreviewDownloadable bool `gorm:"column:preview_downloadable;type:boolean" json:"preview_downloadable"`
|
||||
PublishedAt time.Time `gorm:"column:published_at;type:timestamp with time zone" json:"published_at"`
|
||||
Summary string `gorm:"column:summary;type:character varying(256)" json:"summary"`
|
||||
Tags types.JSON `gorm:"column:tags;type:jsonb;default:[]" json:"tags"`
|
||||
Body string `gorm:"column:body;type:text" json:"body"`
|
||||
Genre string `gorm:"column:genre;type:character varying(64)" json:"genre"`
|
||||
Views int32 `gorm:"column:views;type:integer" json:"views"`
|
||||
Likes int32 `gorm:"column:likes;type:integer" json:"likes"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:timestamp with time zone;default:now()" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp with time zone;default:now()" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp with time zone" json:"deleted_at"`
|
||||
}
|
||||
|
||||
// Quick operations without importing query package
|
||||
|
||||
Reference in New Issue
Block a user