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

Method GetById

models/DocumentModel.go:186–210  ·  view source on GitHub ↗

根据文档id获取一篇文档的全部信息 @param id 文档id @return params 文档信息 @return rows 记录数 @return err 错误

(id interface{})

Source from the content-addressed store, hash-verified

184//@return rows 记录数
185//@return err 错误
186func (this *Document) GetById(id interface{}) (doc fullDocument, err error) {
187 var sql string
188 tables := []string{GetTableDocumentInfo() + " info", GetTableDocument() + " doc", GetTableDocumentStore() + " ds", GetTableUser() + " u"}
189 fields := map[string][]string{
190 "ds": helper.DeleteSlice(GetFields(NewDocumentStore()), "Id"),
191 "info": GetFields(NewDocumentInfo()),
192 "u": {"Username", "Id Uid"},
193 "doc": GetFields(NewDocument()),
194 }
195 on := []map[string]string{
196 {"ds.Id": "info.DsId"},
197 {"doc.Id": "info.Id"},
198 {"u.Id": "info.Uid"},
199 }
200 helper.Logger.Debug("查询字段:%+v", fields)
201
202 sql, err = LeftJoinSqlBuild(tables, on, fields, 1, 1, nil, nil, "info.Id=?")
203 if err != nil {
204 helper.Logger.Error(err.Error())
205 err = errors.New("内部错误:数据查询失败")
206 return
207 }
208 err = orm.NewOrm().Raw(sql, id).QueryRow(&doc)
209 return
210}
211
212func (this *Document) GetDocument(id int, fields ...string) (doc Document) {
213 orm.NewOrm().QueryTable(this).Filter("Id", id).One(&doc, fields...)

Callers

nothing calls this directly

Calls 9

GetTableDocumentInfoFunction · 0.85
GetTableDocumentFunction · 0.85
GetTableDocumentStoreFunction · 0.85
GetTableUserFunction · 0.85
GetFieldsFunction · 0.85
NewDocumentStoreFunction · 0.85
NewDocumentInfoFunction · 0.85
NewDocumentFunction · 0.85
LeftJoinSqlBuildFunction · 0.85

Tested by

no test coverage detected