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

Method GetDocsByIds

models/DocumentModel.go:348–378  ·  view source on GitHub ↗

根据文档id获取文档,并根据ids参数的id顺序返回搜索结果【主要用于搜索】 @param ids 文档id @param num 记录数量

(ids interface{}, num ...int)

Source from the content-addressed store, hash-verified

346//@param ids 文档id
347//@param num 记录数量
348func (this *Document) GetDocsByIds(ids interface{}, num ...int) (data []orm.Params) {
349 var values []orm.Params
350 tables := []string{GetTableDocumentInfo() + " i", GetTableDocument() + " d", GetTableDocumentStore() + " ds"}
351 on := []map[string]string{
352 {"i.Id": "d.Id"},
353 {"i.DsId": "ds.Id"},
354 }
355 fields := map[string][]string{
356 "i": {"Score", "TimeCreate", "Id", "Dcnt", "Vcnt", "Price"},
357 "d": {"Title", "Description"},
358 "ds": {"Page", "Size", "ExtCate", "Md5"},
359 }
360 listRows := 10
361 if len(num) > 0 {
362 listRows = num[0]
363 }
364 if sql, err := LeftJoinSqlBuild(tables, on, fields, 1, listRows, nil, nil, fmt.Sprintf("i.Status>=0 and i.Id in(%v)", ids)); err == nil {
365 orm.NewOrm().Raw(sql).Values(&values)
366 } else {
367 helper.Logger.Error(err.Error())
368 }
369 IdSlice := strings.Split(fmt.Sprintf("%v", ids), ",")
370 for _, id := range IdSlice {
371 for _, v := range values {
372 if id == fmt.Sprintf("%v", v["Id"]) {
373 data = append(data, v)
374 }
375 }
376 }
377 return
378}
379
380//文档简易列表
381func (this *Document) TplSimpleList(chinelid interface{}) []orm.Params {

Callers

nothing calls this directly

Calls 4

GetTableDocumentInfoFunction · 0.85
GetTableDocumentFunction · 0.85
GetTableDocumentStoreFunction · 0.85
LeftJoinSqlBuildFunction · 0.85

Tested by

no test coverage detected