ExportMarkdown 将书籍导出为markdown 注意:系统管理员和书籍参与者有权限导出
()
| 1359 | // ExportMarkdown 将书籍导出为markdown |
| 1360 | // 注意:系统管理员和书籍参与者有权限导出 |
| 1361 | func (this *BookController) Export2Markdown() { |
| 1362 | identify := this.GetString("identify") |
| 1363 | if this.Member.MemberId == 0 { |
| 1364 | this.JsonResult(1, "请先登录") |
| 1365 | } |
| 1366 | if !this.Member.IsAdministrator() { |
| 1367 | if _, err := models.NewBookResult().FindByIdentify(identify, this.Member.MemberId); err != nil { |
| 1368 | this.JsonResult(1, "无操作权限") |
| 1369 | } |
| 1370 | } |
| 1371 | path, err := models.NewBook().Export2Markdown(identify) |
| 1372 | if err != nil { |
| 1373 | this.JsonResult(1, err.Error()) |
| 1374 | } |
| 1375 | defer func() { |
| 1376 | os.Remove(path) |
| 1377 | }() |
| 1378 | attchmentName := filepath.Base(path) |
| 1379 | if book, _ := models.NewBook().FindByIdentify(identify, "book_name", "book_id"); book != nil && book.BookId > 0 { |
| 1380 | attchmentName = book.BookName + ".zip" |
| 1381 | } |
| 1382 | this.Ctx.Output.Download(strings.TrimLeft(path, "./"), attchmentName) |
| 1383 | } |
nothing calls this directly
no test coverage detected