MCPcopy Index your code
hub / github.com/TruthHun/BookStack / Find

Method Find

models/attachment_result.go:26–64  ·  view source on GitHub ↗
(id int)

Source from the content-addressed store, hash-verified

24}
25
26func (m *AttachmentResult) Find(id int) (*AttachmentResult, error) {
27 o := orm.NewOrm()
28
29 attach := NewAttachment()
30
31 err := o.QueryTable(m.TableNameWithPrefix()).Filter("attachment_id", id).One(attach)
32
33 if err != nil {
34 return m, err
35 }
36
37 m.Attachment = *attach
38
39 book := NewBook()
40
41 if e := o.QueryTable(book.TableNameWithPrefix()).Filter("book_id", attach.BookId).One(book, "book_name"); e == nil {
42 m.BookName = book.BookName
43 } else {
44 m.BookName = "[不存在]"
45 }
46 doc := NewDocument()
47
48 if e := o.QueryTable(doc.TableNameWithPrefix()).Filter("document_id", attach.DocumentId).One(doc, "document_name"); e == nil {
49 m.DocumentName = doc.DocumentName
50 } else {
51 m.DocumentName = "[不存在]"
52 }
53
54 if attach.CreateAt > 0 {
55 member := NewMember()
56 if e := o.QueryTable(member.TableNameWithPrefix()).Filter("member_id", attach.CreateAt).One(member, "account"); e == nil {
57 m.Account = member.Account
58 }
59 }
60 m.FileShortSize = utils.FormatBytes(int64(attach.FileSize))
61 m.LocalHttpPath = strings.Replace(m.FilePath, "\\", "/", -1)
62
63 return m, nil
64}

Callers

nothing calls this directly

Calls 9

TableNameWithPrefixMethod · 0.95
TableNameWithPrefixMethod · 0.95
TableNameWithPrefixMethod · 0.95
FormatBytesFunction · 0.92
NewAttachmentFunction · 0.85
NewBookFunction · 0.85
NewDocumentFunction · 0.85
NewMemberFunction · 0.85
ReplaceMethod · 0.45

Tested by

no test coverage detected