Users 用户列表.
()
| 535 | |
| 536 | // Users 用户列表. |
| 537 | func (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 创建书籍. |
| 580 | func (this *BookController) Create() { |
nothing calls this directly
no test coverage detected