fix issue 534

fix #534
pull/866/head
zhaogaolong 2023-04-14 10:43:55 +08:00 committed by GitHub
parent a9e6826ff9
commit bc4cfdbbe6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 7 deletions

View File

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