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

Method SimpleList

models/DocumentModel.go:224–248  ·  view source on GitHub ↗

文档简易列表,用于首页或者其它查询简易字段,使用的时候,记得给条件加上表别名前缀。document_info别名前缀di,document_store别名前缀ds,document表名前缀d @param condition 查询条件 @param limit 查询记录限制 @param orderField 倒叙排序的字段。不需要表前缀。可用字段:Id,Ccnt,Dcnt,Vcnt,Score @return

(condition string, limit int, orderField ...string)

Source from the content-addressed store, hash-verified

222//@return rows 记录数
223//@return err 错误
224func (this *Document) SimpleList(condition string, limit int, orderField ...string) (params []orm.Params, rows int64, err error) {
225 condition = strings.Trim(condition, ",") + " and di.Status in(0,1)"
226 order := "Id"
227 if len(orderField) > 0 {
228 odr := strings.ToLower(orderField[0])
229 switch odr {
230 case "ccnt", "dcnt", "vcnt", "score":
231 order = helper.UpperFirst(odr)
232 default:
233 order = "Id"
234 }
235 }
236 fields := "d.Title,d.Id,ds.Ext,ds.ExtCate"
237 sqlFormat := `
238 select %v from %v d left join %v di on di.Id=d.Id
239 left join %v ds on ds.Id=di.DsId
240 where %v order by di.%v desc limit %v
241 `
242 sql := fmt.Sprintf(sqlFormat, fields, GetTableDocument(), GetTableDocumentInfo(), GetTableDocumentStore(), condition, order, limit)
243 if helper.Debug {
244 helper.Logger.Debug("get simple list sql: %v", sql)
245 }
246 rows, err = orm.NewOrm().Raw(sql).Values(&params)
247 return params, rows, err
248}
249
250//根据md5判断文档是否存在
251//@param md5str 文档的md5

Callers 4

TplSimpleListMethod · 0.95
GetMethod · 0.80
GetMethod · 0.80
GetMethod · 0.80

Calls 3

GetTableDocumentFunction · 0.85
GetTableDocumentInfoFunction · 0.85
GetTableDocumentStoreFunction · 0.85

Tested by

no test coverage detected