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

Method Delete

controllers/BookController.go:763–798  ·  view source on GitHub ↗

Delete 删除书籍.

()

Source from the content-addressed store, hash-verified

761
762// Delete 删除书籍.
763func (this *BookController) Delete() {
764
765 bookResult, err := this.IsPermission()
766 if err != nil {
767 this.JsonResult(6001, err.Error())
768 }
769
770 if bookResult.RoleId != conf.BookFounder {
771 this.JsonResult(6002, "只有创始人才能删除书籍")
772 }
773
774 //用户密码
775 pwd := this.GetString("password")
776 if m, err := models.NewMember().Login(this.Member.Account, pwd); err != nil || m.MemberId == 0 {
777 this.JsonResult(1, "书籍删除失败,您的登录密码不正确")
778 }
779
780 err = models.NewBook().ThoroughDeleteBook(bookResult.BookId)
781 if err == orm.ErrNoRows {
782 this.JsonResult(6002, "书籍不存在")
783 }
784
785 if err != nil {
786 logs.Error("删除书籍 => ", err)
787 this.JsonResult(6003, "删除失败")
788 }
789
790 go func() {
791 client := models.NewElasticSearchClient()
792 if errDel := client.DeleteIndex(bookResult.BookId, true); errDel != nil && client.On {
793 beego.Error(errDel.Error())
794 }
795 }()
796 go models.CountCategory()
797 this.JsonResult(0, "ok")
798}
799
800// 发布书籍.
801func (this *BookController) Release() {

Callers 7

DelTagsMethod · 0.45
DeleteMemberMethod · 0.45
AttachDeleteMethod · 0.45
DelAdsMethod · 0.45
DeleteBannerMethod · 0.45
DeleteSubmitBookMethod · 0.45
DeleteVersionMethod · 0.45

Calls 9

IsPermissionMethod · 0.95
DeleteIndexMethod · 0.95
NewMemberFunction · 0.92
NewBookFunction · 0.92
NewElasticSearchClientFunction · 0.92
CountCategoryFunction · 0.92
JsonResultMethod · 0.80
ThoroughDeleteBookMethod · 0.80
LoginMethod · 0.45

Tested by

no test coverage detected