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

Function GetDocList

models/Utils.go:421–501  ·  view source on GitHub ↗

获取文档列表,其中status不传时,表示获取全部状态的文档,否则获取指定状态的文档,status:-1已删除,0转码中,1已转码 排序order全部按倒叙排序,默认是按id倒叙排序,可选值:Id,Dcnt(下载),Vcnt(浏览),Ccnt(收藏)

(uid, chanelid, pid, cid, p, listRows int, order string, status ...int)

Source from the content-addressed store, hash-verified

419//获取文档列表,其中status不传时,表示获取全部状态的文档,否则获取指定状态的文档,status:-1已删除,0转码中,1已转码
420//排序order全部按倒叙排序,默认是按id倒叙排序,可选值:Id,Dcnt(下载),Vcnt(浏览),Ccnt(收藏)
421func GetDocList(uid, chanelid, pid, cid, p, listRows int, order string, status ...int) (data []orm.Params, rows int64, err error) {
422 var (
423 cond = make(map[string]interface{})
424 condQues []string
425 args []interface{}
426 condStr string
427 )
428
429 switch strings.ToLower(order) {
430 case "dcnt":
431 order = "di.Dcnt desc"
432 case "vcnt":
433 order = "di.Vcnt desc"
434 case "ccnt":
435 order = "di.Ccnt desc"
436 case "score":
437 order = "di.Score desc"
438 default:
439 order = "di.Id desc"
440 }
441
442 if uid > 0 {
443 cond["di.Uid"] = uid
444 }
445
446 if chanelid > 0 {
447 cond["di.ChanelId"] = chanelid
448 }
449
450 if pid > 0 {
451 cond["di.Pid"] = pid
452 }
453
454 if cid > 0 {
455 cond["di.Cid"] = cid
456 }
457
458 for k, v := range cond {
459 condQues = append(condQues, fmt.Sprintf("%v=?", k))
460 args = append(args, v)
461 }
462
463 if len(status) > 0 {
464 var statusArr []string
465 for _, item := range status {
466 statusArr = append(statusArr, fmt.Sprint(item))
467 }
468 condQues = append(condQues, fmt.Sprintf("di.Status in(%v)", strings.Join(statusArr, ",")))
469 }
470
471 condStr = "true"
472 if len(condQues) > 0 {
473 condStr = strings.Join(condQues, " and ")
474 }
475
476 fields := "di.Id,di.`Uid`, di.`Cid`, di.`TimeCreate`, di.`Dcnt`, di.`Vcnt`, di.`Ccnt`, di.`Score`, di.`Status`, di.`ChanelId`, di.`Pid`,c.Title Category,u.Username,d.Title,ds.`Md5`, ds.Id DsId,ds.`Ext`, ds.`ExtCate`, ds.`ExtNum`, ds.`Page`, ds.`Size`"
477
478 sqlFormat := `

Callers

nothing calls this directly

Calls 5

GetTableDocumentInfoFunction · 0.85
GetTableUserFunction · 0.85
GetTableDocumentFunction · 0.85
GetTableCategoryFunction · 0.85
GetTableDocumentStoreFunction · 0.85

Tested by

no test coverage detected