Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复只有第一次导入docx文件有效问题 #828

Merged
merged 1 commit into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions controllers/BookController.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (c *BookController) Setting() {

}

//保存项目信息
// 保存项目信息
func (c *BookController) SaveBook() {
bookResult, err := c.IsPermission()

Expand Down Expand Up @@ -216,7 +216,7 @@ func (c *BookController) SaveBook() {
c.JsonResult(0, "ok", bookResult)
}

//设置项目私有状态.
// 设置项目私有状态.
func (c *BookController) PrivatelyOwned() {

status := c.GetString("status")
Expand Down Expand Up @@ -296,7 +296,7 @@ func (c *BookController) Transfer() {
c.JsonResult(0, "ok")
}

//上传项目封面.
// 上传项目封面.
func (c *BookController) UploadCover() {

bookResult, err := c.IsPermission()
Expand Down Expand Up @@ -544,7 +544,7 @@ func (c *BookController) Create() {
c.JsonResult(6001, "error")
}

//复制项目
// 复制项目
func (c *BookController) Copy() {
if c.Ctx.Input.IsPost() {
//检查是否有复制项目的权限
Expand Down Expand Up @@ -622,6 +622,9 @@ func (c *BookController) Import() {
tempPath = filepath.Join(tempPath, moreFile.Filename)

err = c.SaveToFile("import-file", tempPath)
if err != nil {
c.JsonResult(6004, i18n.Tr(c.Lang, "message.upload_failed"))
}

book := models.NewBook()

Expand Down Expand Up @@ -724,7 +727,7 @@ func (c *BookController) Delete() {
c.JsonResult(0, "ok")
}

//发布项目.
// 发布项目.
func (c *BookController) Release() {
c.Prepare()

Expand Down Expand Up @@ -763,7 +766,7 @@ func (c *BookController) Release() {
c.JsonResult(0, i18n.Tr(c.Lang, "message.publish_to_queue"))
}

//文档排序.
// 文档排序.
func (c *BookController) SaveSort() {
c.Prepare()

Expand Down Expand Up @@ -924,7 +927,7 @@ func (c *BookController) TeamAdd() {
c.JsonResult(0, "OK", teamRel)
}

//删除项目的团队.
// 删除项目的团队.
func (c *BookController) TeamDelete() {
c.Prepare()

Expand Down Expand Up @@ -955,7 +958,7 @@ func (c *BookController) TeamDelete() {
c.JsonResult(0, "OK")
}

//团队搜索.
// 团队搜索.
func (c *BookController) TeamSearch() {
c.Prepare()

Expand All @@ -976,7 +979,7 @@ func (c *BookController) TeamSearch() {

}

//项目空间搜索.
// 项目空间搜索.
func (c *BookController) ItemsetsSearch() {
c.Prepare()

Expand Down
24 changes: 11 additions & 13 deletions models/BookModel.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func NewBook() *Book {
return &Book{}
}

//添加一个项目
// 添加一个项目
func (book *Book) Insert(lang string) error {
o := orm.NewOrm()
// o.Begin()
Expand Down Expand Up @@ -167,7 +167,7 @@ func (book *Book) Find(id int, cols ...string) (*Book, error) {
return book, err
}

//更新一个项目
// 更新一个项目
func (book *Book) Update(cols ...string) error {
o := orm.NewOrm()

Expand All @@ -188,7 +188,7 @@ func (book *Book) Update(cols ...string) error {
return err
}

//复制项目
// 复制项目
func (book *Book) Copy(identify string) error {
o := orm.NewOrm()

Expand Down Expand Up @@ -290,7 +290,7 @@ func (book *Book) Copy(identify string) error {
return nil
}

//递归的复制文档
// 递归的复制文档
func recursiveInsertDocument(docs []*Document, o orm.TxOrmer, bookId int, parentId int) error {
for _, doc := range docs {

Expand Down Expand Up @@ -333,7 +333,7 @@ func recursiveInsertDocument(docs []*Document, o orm.TxOrmer, bookId int, parent
return nil
}

//根据指定字段查询结果集.
// 根据指定字段查询结果集.
func (book *Book) FindByField(field string, value interface{}, cols ...string) ([]*Book, error) {
o := orm.NewOrm()

Expand All @@ -343,7 +343,7 @@ func (book *Book) FindByField(field string, value interface{}, cols ...string) (
return books, err
}

//根据指定字段查询一个结果.
// 根据指定字段查询一个结果.
func (book *Book) FindByFieldFirst(field string, value interface{}) (*Book, error) {
o := orm.NewOrm()

Expand All @@ -353,7 +353,7 @@ func (book *Book) FindByFieldFirst(field string, value interface{}) (*Book, erro

}

//根据项目标识查询项目
// 根据项目标识查询项目
func (book *Book) FindByIdentify(identify string, cols ...string) (*Book, error) {
o := orm.NewOrm()

Expand All @@ -362,7 +362,7 @@ func (book *Book) FindByIdentify(identify string, cols ...string) (*Book, error)
return book, err
}

//分页查询指定用户的项目
// 分页查询指定用户的项目
func (book *Book) FindToPager(pageIndex, pageSize, memberId int, lang string) (books []*BookResult, totalCount int, err error) {

o := orm.NewOrm()
Expand Down Expand Up @@ -521,7 +521,7 @@ func (book *Book) ThoroughDeleteBook(id int) error {

}

//分页查找系统首页数据.
// 分页查找系统首页数据.
func (book *Book) FindForHomeToPager(pageIndex, pageSize, memberId int) (books []*BookResult, totalCount int, err error) {
o := orm.NewOrm()

Expand Down Expand Up @@ -574,7 +574,7 @@ WHERE book.privately_owned = 0 or rel.role_id >=0 or team.role_id >=0 ORDER BY o
return
}

//分页全局搜索.
// 分页全局搜索.
func (book *Book) FindForLabelToPager(keyword string, pageIndex, pageSize, memberId int) (books []*BookResult, totalCount int, err error) {
o := orm.NewOrm()

Expand Down Expand Up @@ -665,7 +665,7 @@ func (book *Book) ReleaseContent(bookId int, lang string) {
})
}

//重置文档数量
// 重置文档数量
func (book *Book) ResetDocumentNumber(bookId int) {
o := orm.NewOrm()

Expand Down Expand Up @@ -1038,8 +1038,6 @@ func (book *Book) ImportWordBook(docxPath string, lang string) (err error) {

doc.DocumentName = strings.TrimSpace(docName)

doc.DocumentId = book.MemberId

if err := doc.InsertOrUpdate("document_name", "book_id", "markdown", "content"); err != nil {
logs.Error(doc.DocumentId, err)
}
Expand Down