MCPcopy Index your code
hub / github.com/TruthHun/BookStack / SitemapData

Function SitemapData

models/base.go:84–118  ·  view source on GitHub ↗

站点地图数据

(page, listRows int)

Source from the content-addressed store, hash-verified

82
83//站点地图数据
84func SitemapData(page, listRows int) (totalRows int64, sitemaps []SitemapDocs) {
85 //获取公开的书籍
86 var (
87 books []Book
88 docs []Document
89 maps = make(map[int]string)
90 booksId []interface{}
91 )
92
93 o := orm.NewOrm()
94 o.QueryTable("md_books").Filter("privately_owned", 0).Limit(100000).All(&books, "book_id", "identify")
95 if len(books) > 0 {
96 for _, book := range books {
97 booksId = append(booksId, book.BookId)
98 maps[book.BookId] = book.Identify
99 }
100 q := o.QueryTable("md_documents").Filter("BookId__in", booksId...)
101 totalRows, _ = q.Count()
102 q.Limit(listRows).Offset((page-1)*listRows).All(&docs, "document_id", "document_name", "book_id")
103 if len(docs) > 0 {
104 for _, doc := range docs {
105 sd := SitemapDocs{
106 DocumentId: doc.DocumentId,
107 DocumentName: doc.DocumentName,
108 BookId: doc.BookId,
109 }
110 if v, ok := maps[doc.BookId]; ok {
111 sd.Identify = v
112 }
113 sitemaps = append(sitemaps, sd)
114 }
115 }
116 }
117 return
118}
119
120func SitemapUpdate(domain string) {
121 var (

Callers 1

SitemapMethod · 0.92

Calls 3

appendFunction · 0.50
AllMethod · 0.45
CountMethod · 0.45

Tested by

no test coverage detected