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

Method CategoryOfUserCollection

models/category.go:119–135  ·  view source on GitHub ↗

用户收藏了的书籍的分类

(uid int, forAPI ...bool)

Source from the content-addressed store, hash-verified

117
118// 用户收藏了的书籍的分类
119func (m *Category) CategoryOfUserCollection(uid int, forAPI ...bool) (cates []Category) {
120 order := " ORDER BY c.sort asc,c.title asc "
121 if len(forAPI) > 0 && forAPI[0] {
122 order = " ORDER BY c.title asc "
123 }
124 sql := `
125 SELECT c.id,c.pid,c.title
126 FROM md_book_category bc
127 LEFT JOIN md_star s ON s.bid = bc.book_id
128 LEFT JOIN md_category c ON c.id = bc.category_id
129 WHERE s.uid = ?
130 GROUP BY c.id ` + order
131 if _, err := orm.NewOrm().Raw(sql, uid).QueryRows(&cates); err != nil {
132 beego.Error(err.Error())
133 }
134 return
135}

Callers 2

StarMethod · 0.80
BookshelfMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected