Setting 书籍设置 .
()
| 152 | |
| 153 | // Setting 书籍设置 . |
| 154 | func (this *BookController) Setting() { |
| 155 | |
| 156 | key := this.Ctx.Input.Param(":key") |
| 157 | |
| 158 | if key == "" { |
| 159 | this.Abort("404") |
| 160 | } |
| 161 | |
| 162 | book, err := models.NewBookResult().FindByIdentify(key, this.Member.MemberId) |
| 163 | if err != nil && err != orm.ErrNoRows { |
| 164 | beego.Error(err.Error()) |
| 165 | |
| 166 | if err == orm.ErrNoRows { |
| 167 | this.Abort("404") |
| 168 | } |
| 169 | |
| 170 | if err == models.ErrPermissionDenied { |
| 171 | this.Abort("404") |
| 172 | } |
| 173 | this.Abort("404") |
| 174 | } |
| 175 | |
| 176 | //如果不是创始人也不是管理员则不能操作 |
| 177 | if book.RoleId != conf.BookFounder && book.RoleId != conf.BookAdmin { |
| 178 | this.Abort("404") |
| 179 | } |
| 180 | |
| 181 | if book.PrivateToken != "" { |
| 182 | //book.PrivateToken = this.BaseUrl() + beego.URLFor("DocumentController.Index", ":key", book.Identify, "token", book.PrivateToken) |
| 183 | tipsFmt := "访问链接:%v 访问密码:%v" |
| 184 | book.PrivateToken = fmt.Sprintf(tipsFmt, this.BaseUrl()+beego.URLFor("DocumentController.Index", ":key", book.Identify), book.PrivateToken) |
| 185 | } |
| 186 | |
| 187 | //查询当前书籍的分类id |
| 188 | if selectedCates, rows, _ := new(models.BookCategory).GetByBookId(book.BookId); rows > 0 { |
| 189 | var maps = make(map[int]bool) |
| 190 | for _, cate := range selectedCates { |
| 191 | maps[cate.Id] = true |
| 192 | } |
| 193 | this.Data["Maps"] = maps |
| 194 | } |
| 195 | |
| 196 | ver := models.NewVersion() |
| 197 | this.Data["Versions"] = ver.All() |
| 198 | this.Data["VersionItem"] = ver.GetVersionItem(book.Identify) |
| 199 | |
| 200 | this.Data["Cates"], _ = new(models.Category).GetCates(-1, 1) |
| 201 | this.Data["Model"] = book |
| 202 | this.TplName = "book/setting.html" |
| 203 | installedDependencies := utils.GetInstalledDependencies() |
| 204 | for _, item := range installedDependencies { |
| 205 | this.Data[item.Name+"_is_installed"] = item.IsInstalled |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | // SaveBook 保存书籍信息 |
| 210 | func (this *BookController) SaveBook() { |
nothing calls this directly
no test coverage detected