MCPcopy Index your code
hub / github.com/TruthHun/DocHub / DeepDel

Method DeepDel

models/RecycleModel.go:237–294  ·  view source on GitHub ↗

彻底删除文档,包括删除文档记录(被收藏的记录、用户的发布记录、扣除用户获得的积分(如果此刻文档的状态不是待删除)),删除文档文件

(ids ...interface{})

Source from the content-addressed store, hash-verified

235
236// 彻底删除文档,包括删除文档记录(被收藏的记录、用户的发布记录、扣除用户获得的积分(如果此刻文档的状态不是待删除)),删除文档文件
237func (this *DocumentRecycle) DeepDel(ids ...interface{}) (err error) {
238 // 文档id找到文档的dsId,再根据dsId查找到全部的文档id
239 // 根据文档id,将文档全部移入回收站
240 // 删除文档记录
241 //
242 var (
243 dsId []interface{}
244 info []DocumentInfo
245 store []DocumentStore
246 o = orm.NewOrm()
247 )
248
249 info, _, err = NewDocument().GetDocInfoById(ids...)
250 if err != nil && err != orm.ErrNoRows {
251 return
252 }
253
254 if len(info) == 0 {
255 return
256 }
257
258 for _, item := range info {
259 dsId = append(dsId, item.DsId)
260 }
261
262 info, _, _ = NewDocument().GetDocInfoByDsId(dsId)
263 if len(info) > 0 {
264 ids = []interface{}{}
265 for _, item := range info {
266 ids = append(ids, item.Id)
267 }
268 }
269
270 err = this.RemoveToRecycle(0, false, ids...)
271 if err != nil {
272 return
273 }
274
275 if err = this.DelRows(ids...); err != nil && err != orm.ErrNoRows {
276 return
277 }
278
279 if store, _, err = NewDocument().GetDocStoreByDsId(dsId...); err != orm.ErrNoRows && err != nil {
280 return
281 }
282
283 if _, err = o.QueryTable(GetTableDocumentStore()).Filter("Id__in", dsId).Delete(); err != orm.ErrNoRows && err != nil {
284 return
285 }
286
287 go func() {
288 for _, item := range store {
289 this.DelFile(item.Md5, item.Ext, item.PreviewExt, item.PreviewPage)
290 }
291 }()
292
293 return
294}

Callers 1

ActionMethod · 0.95

Calls 9

RemoveToRecycleMethod · 0.95
DelRowsMethod · 0.95
DelFileMethod · 0.95
NewDocumentFunction · 0.85
GetTableDocumentStoreFunction · 0.85
GetDocInfoByIdMethod · 0.80
GetDocInfoByDsIdMethod · 0.80
GetDocStoreByDsIdMethod · 0.80
DeleteMethod · 0.80

Tested by

no test coverage detected