service

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSegmenter

func NewSegmenter() *jiebago.Segmenter

func NewYuQue

func NewYuQue(config *config.Toml) sdk.IYuQue

Types

type Article

type Article struct {
	Slug          string // 文章ID
	Title         string // 标题
	Content       string // 文章内容
	Desc          string // 文章简介
	Toc           []H    // 目录
	CommentsCount int    // 评论数
	Hits          int    // 阅读数
	Author        string
	CreatedAt     time.Time
	UpdatedAt     time.Time
}

type GetDetailRequest

type GetDetailRequest struct {
	Slug string
}

type GetDetailResponse

type GetDetailResponse struct {
	Data Article
}

type GetListRequest

type GetListRequest struct {
	Page     int
	PageSize int
}

type GetListResponse

type GetListResponse struct {
	Data []Article
}

type H

type H struct {
	ID    string
	Title string
	Level int
}

H Toc 目录

type IArticle

type IArticle interface {
	// GetList 文章列表
	GetList(ctx context.Context, request *GetListRequest) (*GetListResponse, error)
	// GetDetail 文章详情
	GetDetail(ctx context.Context, request *GetDetailRequest) (*GetDetailResponse, error)
	// GetTotal 文章总数
	GetTotal(ctx context.Context) (int, error)
	// PutIndex 新增索引
	PutIndex(ctx context.Context, article *Article) error
	// GetIndex 获取索引
	GetIndex(ctx context.Context) map[string]mapset.Set[string]
	// Cut 分词
	Cut(ctx context.Context, text string) (words []string, err error)
	// BuildAllIndex 构建所有文章索引
	BuildAllIndex(ctx context.Context) error
	// GetToc 获取目录列表
	GetToc(ctx context.Context, content string) []H
}

IArticle 文章接口

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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