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

Method Users

controllers/BookController.go:537–577  ·  view source on GitHub ↗

Users 用户列表.

()

Source from the content-addressed store, hash-verified

535
536// Users 用户列表.
537func (this *BookController) Users() {
538
539 pageIndex, _ := this.GetInt("page", 1)
540
541 key := this.Ctx.Input.Param(":key")
542 if key == "" {
543 this.Abort("404")
544 }
545
546 book, err := models.NewBookResult().FindByIdentify(key, this.Member.MemberId)
547 if err != nil {
548 if err == models.ErrPermissionDenied {
549 this.Abort("404")
550 }
551 this.Abort("404")
552 }
553
554 this.Data["Model"] = *book
555 pageSize := 10
556 members, totalCount, _ := models.NewMemberRelationshipResult().FindForUsersByBookId(book.BookId, pageIndex, pageSize)
557
558 for idx, member := range members {
559 member.Avatar = utils.ShowImg(member.Avatar, "avatar")
560 members[idx] = member
561 }
562
563 if totalCount > 0 {
564 html := utils.GetPagerHtml(this.Ctx.Request.RequestURI, pageIndex, pageSize, totalCount)
565 this.Data["PageHtml"] = html
566 } else {
567 this.Data["PageHtml"] = ""
568 }
569
570 b, err := json.Marshal(members)
571 if err != nil {
572 this.Data["Result"] = template.JS("[]")
573 } else {
574 this.Data["Result"] = template.JS(string(b))
575 }
576 this.TplName = "book/users.html"
577}
578
579// Create 创建书籍.
580func (this *BookController) Create() {

Callers

nothing calls this directly

Calls 7

NewBookResultFunction · 0.92
ShowImgFunction · 0.92
GetPagerHtmlFunction · 0.92
stringFunction · 0.85
FindForUsersByBookIdMethod · 0.80
FindByIdentifyMethod · 0.45

Tested by

no test coverage detected