service

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetArchive

func GetArchive() (map[string]map[string][]*ShowArchive, []string, map[string][]string, error)

GetArchive get archive list and list sort

func GetPageIDBySlug

func GetPageIDBySlug(slug string) uint64

GetPageIDBySlug get page ID by slug

func GetSubjectArticleList

func GetSubjectArticleList(subjectID uint64) ([]*map[string]interface{}, error)

GetSubjectArticleList get article list connected to subject

func NewServiceEngine added in v0.4.1

func NewServiceEngine() error

NewServiceEngine return a new Service engine for frontend web this method will only be called once at the beginning for initialization

Types

type ChildrenSubjectsResult added in v0.4.0

type ChildrenSubjectsResult struct {
	ID            uint64
	ParentID      uint64
	Name          string
	Slug          string
	Description   string
	CoverImageURL string
	Count         uint64
	LastUpdated   sql.NullTime
}

ChildrenSubjectsResult use for scan

type Engine added in v0.4.0

type Engine struct {
	Cache *cache.Cache
	JSON  jsoniter.API
	// contains filtered or unexported fields
}

Engine service engine

var SrvEngine *Engine

SrvEngine service engine instance

func (*Engine) GetCache added in v0.4.0

func (svc *Engine) GetCache(key string) ([]byte, bool)

GetCache get cache by key during service engine

func (*Engine) GetKnowledgeBySlug added in v0.4.1

func (svc *Engine) GetKnowledgeBySlug(kType, kSlug string) (*ShowKnowledgeInfo, error)

GetKnowledgeBySlug get knowledge by slug

func (*Engine) GetKnowledgeItemContentBySymbol added in v0.4.1

func (svc *Engine) GetKnowledgeItemContentBySymbol(kiSymbol string) (*ShowKnowledgeItemContent, error)

GetKnowledgeItemContentBySymbol get knowledge item content by knowledge item symbol

func (*Engine) GetKnowledgeItemList added in v0.4.1

func (svc *Engine) GetKnowledgeItemList(kType, kSlug string, kID uint64) ([]*ShowKnowledgeItemTreeNode, error)

GetKnowledgeItemList get knowledge item list in tree

func (*Engine) GetKnowledgeList added in v0.4.1

func (svc *Engine) GetKnowledgeList() (map[string]map[uint64]*ShowKnowledgeList, error)

GetKnowledgeList get knowledge list, include note and doc

func (*Engine) JSONUnmarshal added in v0.4.0

func (svc *Engine) JSONUnmarshal(data []byte, v interface{})

JSONUnmarshal json unmarshal

func (*Engine) MarshalAndSetCache added in v0.4.0

func (svc *Engine) MarshalAndSetCache(key string, v interface{})

MarshalAndSetCache json marshal and set cache

func (*Engine) SetCache added in v0.4.0

func (svc *Engine) SetCache(key string, value []byte) error

SetCache set cache by key during service engine

type KnowledgeList added in v0.4.0

type KnowledgeList struct {
	Lock    *sync.Mutex
	DocMap  map[uint64]*ShowKnowledgeList
	NoteMap map[uint64]*ShowKnowledgeList
}

KnowledgeList knowledge list

type List

type List struct {
	Lock  *sync.Mutex
	IDMap map[uint64]*ShowArticle
}

List post list

type ShowArchive

type ShowArchive struct {
	ID           uint64
	Title        string
	GUID         string
	CommentCount uint64
	ViewCount    uint64
	PostedTime   string
	PostedDay    string
}

ShowArchive archive item

type ShowArticle

type ShowArticle struct {
	ID           uint64
	Title        string
	IfTop        bool
	Abstract     string
	GUID         string
	CoverPicture string
	CommentCount uint64
	ViewCount    uint64
	PostedTime   string
	Tags         []*ShowTag
	Categories   []*ShowCategory
}

ShowArticle output article model for list

func GetArticleList

func GetArticleList(currentPage int, keyword string) (articleResult []*ShowArticle, pagination *utils.Pagination, err error)

GetArticleList get articles list

func GetArticleListByTaxonomy

func GetArticleListByTaxonomy(currentPage int, taxonomyType, taxonomySlug, keyword string) (termName string, articleResult []*ShowArticle, pagination *utils.Pagination, err error)

GetArticleListByTaxonomy get articles list

type ShowArticleDetail

type ShowArticleDetail struct {
	ID            uint64
	Title         string
	ContentHTML   template.HTML
	CommentStatus uint64
	GUID          string
	CommentCount  uint64
	ViewCount     uint64
	PostedTime    string
	MetaData      map[string]interface{}
	Tags          []*ShowTag
	Categories    []*ShowCategory
}

ShowArticleDetail article detail output model

func GetArticleDetailByID

func GetArticleDetailByID(articleID uint64) (*ShowArticleDetail, error)

GetArticleDetailByID get article detail by article id

type ShowCategory

type ShowCategory struct {
	Title string
	URL   string
}

ShowCategory output category model

type ShowKnowledgeInfo added in v0.4.0

type ShowKnowledgeInfo struct {
	ID          uint64
	Name        string
	LastUpdated string
}

ShowKnowledgeInfo knowledge info output model

type ShowKnowledgeItemContent added in v0.4.0

type ShowKnowledgeItemContent struct {
	Symbol  uint64
	Title   string
	Content template.HTML
}

ShowKnowledgeItemContent knowledge item content

type ShowKnowledgeItemTreeNode added in v0.4.0

type ShowKnowledgeItemTreeNode struct {
	ID       uint64
	Symbol   uint64
	Title    string
	URL      string
	Level    uint64
	Index    int64
	Children []*ShowKnowledgeItemTreeNode
}

ShowWidgetCategoryTreeNode category tree node for widget

type ShowKnowledgeList added in v0.4.0

type ShowKnowledgeList struct {
	ID            uint64
	URL           string
	Name          string
	Slug          string
	Description   string
	CoverImageURL string
	UpdatedTime   string
}

ShowKnowledgeList show knowledge list output model

type ShowLastOrNextArticle

type ShowLastOrNextArticle struct {
	Title string
	URL   string
}

ShowLastOrNextArticle last or next article url model

func GetLastArticle

func GetLastArticle(currentArticleID uint64) *ShowLastOrNextArticle

GetLastArticle get last article title and url

func GetNextArticle

func GetNextArticle(currentArticleID uint64) *ShowLastOrNextArticle

GetNextArticle get next article title and url

type ShowPageDetail

type ShowPageDetail struct {
	ID            uint64
	Title         string
	ContentHTML   template.HTML
	CommentStatus uint64
	GUID          string
	CommentCount  uint64
	ViewCount     uint64
	PostedTime    string
	MetaData      map[string]interface{}
}

ShowPageDetail page detail output model

func GetPageDetailByID

func GetPageDetailByID(pageID uint64) (*ShowPageDetail, error)

GetPageDetailByID get page detail info by page id

type ShowSubjectInfo

type ShowSubjectInfo struct {
	ID            uint64
	ParentURL     string
	Name          string
	Slug          string
	Description   string
	CoverImageURL string
	Count         string
}

ShowSubjectInfo show subjects info output model

func GetSubjectInfoBySlug

func GetSubjectInfoBySlug(subjectSlug string) (*ShowSubjectInfo, error)

GetSubjectInfoBySlug get subject info by the unique slug

type ShowSubjectList

type ShowSubjectList struct {
	ID                uint64
	URL               string
	Name              string
	Slug              string
	Description       string
	CoverImageURL     string
	Count             uint64
	LastUpdated       string
	SubLastUpdatedDay string
}

ShowSubjectList show subjects list output model

func GetChildrenSubjects added in v0.4.0

func GetChildrenSubjects(parentID uint64) (subjectResult []*ShowSubjectList, err error)

GetChildrenSubjects get subject's all children If the parentID is 0, get all top subjects

type ShowTag

type ShowTag struct {
	Title string
	URL   string
}

ShowTag output tag model

type ShowWidgetCategoryTreeNode

type ShowWidgetCategoryTreeNode struct {
	TermID   uint64
	Name     string
	Slug     string
	Count    uint64
	URL      string
	Children []*ShowWidgetCategoryTreeNode
}

ShowWidgetCategoryTreeNode category tree node for widget

func GetcategoryList

func GetcategoryList() (taxonomyTree []*ShowWidgetCategoryTreeNode, err error)

GetcategoryList get category tree for widget

type ShowWidgetLatestArticles

type ShowWidgetLatestArticles struct {
	ID           string
	Title        string
	GUID         string
	CommentCount string
	ViewCount    string
	PostedTime   sql.NullTime
}

ShowWidgetLatestArticles latest article list for widget Use {{ formatNullTime .PostedTime "2006-01-02 15:04" }} to decode the time

func GetLatestArticlesList

func GetLatestArticlesList(getNums int) ([]*ShowWidgetLatestArticles, error)

GetLatestArticlesList get latest article list for widget

type SubjectInfoResult added in v0.4.0

type SubjectInfoResult struct {
	ID            uint64
	ParentID      uint64
	Name          string
	Slug          string
	Description   string
	CoverImageURL string
	Count         string
}

SubjectInfoResult use for scan subject info

type SubjectList

type SubjectList struct {
	Lock  *sync.Mutex
	IDMap map[uint64]*ShowSubjectList
}

SubjectList subject list

Jump to

Keyboard shortcuts

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