(id int)
| 24 | } |
| 25 | |
| 26 | func (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 | } |
nothing calls this directly
no test coverage detected