|
@@ -185,7 +185,7 @@ func (m *BookResult) FindToPager(pageIndex, pageSize int) (books []*BookResult,
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//实体转换
|
|
|
+// 实体转换
|
|
|
func (m *BookResult) ToBookResult(book Book) *BookResult {
|
|
|
|
|
|
m.BookId = book.BookId
|
|
@@ -214,6 +214,7 @@ func (m *BookResult) ToBookResult(book Book) *BookResult {
|
|
|
m.IsDownload = book.IsDownload == 0
|
|
|
m.AutoSave = book.AutoSave == 1
|
|
|
m.ItemId = book.ItemId
|
|
|
+ m.RoleId = conf.BookRoleNoSpecific
|
|
|
|
|
|
if book.Theme == "" {
|
|
|
m.Theme = "default"
|
|
@@ -249,12 +250,13 @@ func (m *BookResult) ToBookResult(book Book) *BookResult {
|
|
|
} else if m.CommentStatus == "group_only" {
|
|
|
// todo
|
|
|
} else {
|
|
|
- m.IsDisplayComment = false;
|
|
|
+ m.IsDisplayComment = false
|
|
|
}
|
|
|
+
|
|
|
return m
|
|
|
}
|
|
|
|
|
|
-//后台转换
|
|
|
+// 后台转换
|
|
|
func BackgroundConvert(sessionId string, bookResult *BookResult) error {
|
|
|
|
|
|
if err := converter.CheckConvertCommand(); err != nil {
|
|
@@ -274,7 +276,7 @@ func BackgroundConvert(sessionId string, bookResult *BookResult) error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-//导出PDF、word等格式
|
|
|
+// 导出PDF、word等格式
|
|
|
func (m *BookResult) Converter(sessionId string) (ConvertBookResult, error) {
|
|
|
|
|
|
convertBookResult := ConvertBookResult{}
|
|
@@ -521,7 +523,7 @@ func (m *BookResult) Converter(sessionId string) (ConvertBookResult, error) {
|
|
|
return convertBookResult, nil
|
|
|
}
|
|
|
|
|
|
-//导出Markdown原始文件
|
|
|
+// 导出Markdown原始文件
|
|
|
func (m *BookResult) ExportMarkdown(sessionId string) (string, error) {
|
|
|
outputPath := filepath.Join(conf.WorkingDirectory, "uploads", "books", strconv.Itoa(m.BookId), "book.zip")
|
|
|
|
|
@@ -546,7 +548,7 @@ func (m *BookResult) ExportMarkdown(sessionId string) (string, error) {
|
|
|
return outputPath, nil
|
|
|
}
|
|
|
|
|
|
-//递归导出Markdown文档
|
|
|
+// 递归导出Markdown文档
|
|
|
func exportMarkdown(p string, parentId int, bookId int, baseDir string, bookUrl string) error {
|
|
|
o := orm.NewOrm()
|
|
|
|
|
@@ -709,7 +711,7 @@ func recursiveJoinDocumentIdentify(parentDocId int, identify string) string {
|
|
|
return identify
|
|
|
}
|
|
|
|
|
|
-//查询项目的第一篇文档
|
|
|
+// 查询项目的第一篇文档
|
|
|
func (m *BookResult) FindFirstDocumentByBookId(bookId int) (*Document, error) {
|
|
|
|
|
|
o := orm.NewOrm()
|