docVersions

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearDefaultByProjectId

func ClearDefaultByProjectId(projectId uint64) int64

ClearDefaultByProjectId 清除项目下的默认版本标记

func Create

func Create(entity *Entity) int64

Create 公开的创建方法

func ExistsBySlugAndProjectId

func ExistsBySlugAndProjectId(slug string, projectId uint64) bool

ExistsBySlugAndProjectId 检查项目下slug是否存在

func ExistsBySlugAndProjectIdExcludeId

func ExistsBySlugAndProjectIdExcludeId(slug string, projectId uint64, excludeId uint64) bool

ExistsBySlugAndProjectIdExcludeId 检查项目下slug是否存在(排除指定ID)

func HasDocuments

func HasDocuments(versionId uint64) bool

HasDocuments 检查版本下是否有文档

func Save

func Save(entity *Entity) int64

Save 公开的保存方法

func SaveOrCreateById

func SaveOrCreateById(entity *Entity) int64

func SoftDelete

func SoftDelete(entity *Entity) int64

SoftDelete 软删除版本

Types

type DirectoryItem

type DirectoryItem struct {
	Id          uint64          `json:"id"`
	Title       string          `json:"title"`
	Slug        string          `json:"slug"`
	Description string          `json:"description,omitempty"`
	Children    []DirectoryItem `json:"children,omitempty"`
}

DirectoryItem 目录项结构

func BuildSafeDescription

func BuildSafeDescription(tree []DirectoryItem, contentList []DirectoryItem) []DirectoryItem

type Entity

type Entity struct {
	Id          uint64          `gorm:"primaryKey;column:id;autoIncrement;not null;" json:"id"`                  // 版本ID
	ProjectId   uint64          `gorm:"column:project_id;type:bigint;not null;" json:"projectId"`                // 项目ID
	Name        string          `gorm:"column:name;type:varchar(50);not null;default:'';" json:"name"`           // 版本名称
	Slug        string          `gorm:"column:slug;type:varchar(50);not null;default:'';" json:"slug"`           // 版本标识符
	Description string          `gorm:"column:description;type:text;" json:"description"`                        // 版本描述
	Status      int8            `gorm:"column:status;type:tinyint;not null;default:1;" json:"status"`            // 状态(1:活跃 2:维护 3:废弃)
	IsDefault   int8            `gorm:"column:is_default;type:tinyint;not null;default:0;" json:"isDefault"`     // 是否默认版本(0:否 1:是)
	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"`         // 排序权重
	Directory   []DirectoryItem `gorm:"column:directory;type:text;serializer:json" json:"directory"`

	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 GetVersionByProject

func GetVersionByProject(projectId uint64) (entities []*Entity)

func GetVersionList

func GetVersionList(page, pageSize int, projectId uint64, keyword string, status int) (entities []Entity, total int64, err error)

GetVersionList 获取版本列表

func (*Entity) TableName

func (itself *Entity) TableName() string

Jump to

Keyboard shortcuts

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