设置书籍私有状态.
()
| 696 | |
| 697 | // 设置书籍私有状态. |
| 698 | func (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 | // 附件列表. |
| 747 | func (this *ManagerController) AttachList() { |
nothing calls this directly
no test coverage detected