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

Method PrivatelyOwned

controllers/ManagerController.go:698–744  ·  view source on GitHub ↗

设置书籍私有状态.

()

Source from the content-addressed store, hash-verified

696
697// 设置书籍私有状态.
698func (this *ManagerController) PrivatelyOwned() {
699 status := this.GetString("status")
700 identify := this.GetString("identify")
701
702 if status != "open" && status != "close" {
703 this.JsonResult(6003, "参数错误")
704 }
705
706 state := 0
707 if status == "open" {
708 state = 0
709 } else {
710 state = 1
711 }
712
713 if !this.Member.IsAdministrator() {
714 this.Abort("404")
715 }
716
717 book, err := models.NewBook().FindByFieldFirst("identify", identify)
718 if err != nil {
719 this.JsonResult(6001, err.Error())
720 }
721
722 book.PrivatelyOwned = state
723 beego.Info("", state, status)
724
725 err = book.Update()
726 if err != nil {
727 beego.Error("PrivatelyOwned => ", err)
728 this.JsonResult(6004, "保存失败")
729 }
730
731 go func() {
732 models.CountCategory()
733 public := true
734 if state == 1 {
735 public = false
736 }
737 client := models.NewElasticSearchClient()
738 if errSet := client.SetBookPublic(book.BookId, public); errSet != nil && client.On {
739 beego.Error(errSet.Error())
740 }
741 }()
742
743 this.JsonResult(0, "ok")
744}
745
746// 附件列表.
747func (this *ManagerController) AttachList() {

Callers

nothing calls this directly

Calls 8

SetBookPublicMethod · 0.95
NewBookFunction · 0.92
CountCategoryFunction · 0.92
NewElasticSearchClientFunction · 0.92
JsonResultMethod · 0.80
IsAdministratorMethod · 0.80
FindByFieldFirstMethod · 0.45
UpdateMethod · 0.45

Tested by

no test coverage detected