递归删除一个文档.
(docId int)
| 172 | |
| 173 | //递归删除一个文档. |
| 174 | func (m *Document) RecursiveDocument(docId int) error { |
| 175 | |
| 176 | o := orm.NewOrm() |
| 177 | modelStore := new(DocumentStore) |
| 178 | |
| 179 | if doc, err := m.Find(docId); err == nil { |
| 180 | o.Delete(doc) |
| 181 | modelStore.DeleteById(docId) |
| 182 | NewDocumentHistory().Clear(docId) |
| 183 | } |
| 184 | |
| 185 | var docs []*Document |
| 186 | |
| 187 | _, err := o.QueryTable(m.TableNameWithPrefix()).Filter("parent_id", docId).All(&docs) |
| 188 | if err != nil { |
| 189 | beego.Error("RecursiveDocument => ", err) |
| 190 | return err |
| 191 | } |
| 192 | |
| 193 | for _, item := range docs { |
| 194 | docId := item.DocumentId |
| 195 | o.QueryTable(m.TableNameWithPrefix()).Filter("document_id", docId).Delete() |
| 196 | //删除document_store表的文档 |
| 197 | modelStore.DeleteById(docId) |
| 198 | m.RecursiveDocument(docId) |
| 199 | } |
| 200 | return nil |
| 201 | } |
| 202 | |
| 203 | //发布文档内容为HTML |
| 204 | func (m *Document) ReleaseContent(bookId int, baseUrl string, force ...bool) { |
no test coverage detected