docContents

package
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(id uint64) int64

Delete 删除内容

func ExistsBySlugAndVersionId

func ExistsBySlugAndVersionId(slug string, versionId uint64) bool

ExistsBySlugAndVersionId 检查slug在版本内是否已存在

func ExistsBySlugAndVersionIdExcludeId

func ExistsBySlugAndVersionIdExcludeId(slug string, versionId uint64, excludeId uint64) bool

ExistsBySlugAndVersionIdExcludeId 检查slug在版本内是否被其他内容使用

func SaveOrCreateById

func SaveOrCreateById(entity *Entity) int64

func UpdatePublishStatus

func UpdatePublishStatus(id uint64, isPublished int8) int64

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 // 删除时间
}

func Get

func Get(id any) (entity Entity)

func GetByIdString

func GetByIdString(id string) (entity Entity)

GetByIdString 通过字符串ID获取内容

func GetBySlug

func GetBySlug(versionId uint64, slug string) (entity Entity)

func GetContentList

func GetContentList(page, pageSize int, versionId uint64, keyword string, status int) ([]*Entity, int64, error)

GetContentList 获取内容列表

func (*Entity) TableName

func (itself *Entity) TableName() string

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL