Documentation
¶
Index ¶
- func Delete(id uint64) int64
- func ExistsBySlugAndVersionId(slug string, versionId uint64) bool
- func ExistsBySlugAndVersionIdExcludeId(slug string, versionId uint64, excludeId uint64) bool
- func SaveOrCreateById(entity *Entity) int64
- func UpdatePublishStatus(id uint64, isPublished int8) int64
- type Entity
- type SimpleEntity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExistsBySlugAndVersionId ¶
ExistsBySlugAndVersionId 检查slug在版本内是否已存在
func ExistsBySlugAndVersionIdExcludeId ¶
ExistsBySlugAndVersionIdExcludeId 检查slug在版本内是否被其他内容使用
func SaveOrCreateById ¶
func UpdatePublishStatus ¶
UpdatePublishStatus 更新发布状态
Types ¶
type Entity ¶
type Entity struct {
Id uint64 `gorm:"primaryKey;column:id;autoIncrement;not null;" json:"id"` // 内容ID
VersionId uint64 `gorm:"column:version_id;not null;default:0;uniqueIndex:version_id,slug:1" json:"versionId"` // 版本
Title string `gorm:"column:title;type:varchar(200);not null;default:'';" json:"title"` // 文档标题
Slug string `gorm:"column:slug;type:varchar(200);not null;default:'';uniqueIndex:version_id,slug:2" json:"slug"` // 文档标识符
OriginContent string `gorm:"column:origin_content;type:text;" json:"OriginContent"` // 文档内容(Markdown)
Content string `gorm:"column:content;type:text;" json:"content"` // 文档内容(Markdown)
ContentHtml string `gorm:"column:content_html;type:text;" json:"contentHtml"` // 渲染后的HTML内容
ContentHtmlVersion uint32 `gorm:"column:content_html_version;type:bigint unsigned;not null;default:0;" json:"contentHtmlVersion"` //md 的渲染器版本
Toc string `gorm:"column:toc;type:json;" json:"toc"` // 目录结构(JSON)
IsPublished int8 `gorm:"column:is_published;type:tinyint;not null;default:0;" json:"isPublished"` // 是否发布(0:草稿 1:已发布)
SortOrder int `gorm:"column:sort_order;type:int;not null;default:0;" json:"sortOrder"` // 排序权重
LikeCount uint64 `gorm:"column:like_count;type:bigint unsigned;not null;default:0;" json:"likeCount"` // 喜欢数量
ViewCount uint64 `gorm:"column:view_count;index;type:bigint unsigned;not null;default:0;" json:"viewCount"` // 访问数量
CreatedAt time.Time `gorm:"column:created_at;index;autoCreateTime;<-:create;" json:"createdAt"` // 创建时间
UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime;" json:"updatedAt"` // 更新时间
DeletedAt gorm.DeletedAt // 删除时间
}
type SimpleEntity ¶
type SimpleEntity struct {
Id uint64 `gorm:"primaryKey;column:id;autoIncrement;not null;" json:"id"` // 内容ID
VersionId uint64 `gorm:"column:version_id;not null;default:0;uniqueIndex:version_id,slug:1" json:"versionId"` // 版本
Title string `gorm:"column:title;type:varchar(200);not null;default:'';" json:"title"` // 文档标题
Slug string `gorm:"column:slug;type:varchar(200);not null;default:'';uniqueIndex:version_id,slug:2" json:"slug"` // 文档标识符
CreatedAt time.Time `gorm:"column:created_at;index;autoCreateTime;<-:create;" json:"createdAt"` // 创建时间
UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime;" json:"updatedAt"` // 更新时间
DeletedAt gorm.DeletedAt // 删除时间
}
func GetByVersionId ¶
func GetByVersionId(versionId uint64) (entity []*SimpleEntity)
func GetByVersionIds ¶
func GetByVersionIds(versionId []uint64) (entity []*SimpleEntity)
func (*SimpleEntity) TableName ¶
func (itself *SimpleEntity) TableName() string
Click to show internal directories.
Click to hide internal directories.