outside_report_attachment.go 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. // @Author gmy 2024/9/19 15:13:00
  2. package models
  3. import "github.com/beego/beego/v2/client/orm"
  4. type OutsideReportAttachment struct {
  5. OutsideReportAttachmentId int `orm:"column(outside_report_attachment_id);pk" description:"外部报告附件ID"`
  6. OutsideReportId int `orm:"column(outside_report_id)" description:"报告id"`
  7. Title string `orm:"column(title)" description:"附件名称"`
  8. Url string `orm:"column(url)" description:"附件地址"`
  9. CreateTime string `orm:"column(create_time)" description:"附件新增时间"`
  10. FileSize int64 `orm:"column(file_size)" description:"附件大小"`
  11. }
  12. // 在 init 函数中注册模型
  13. func init() {
  14. orm.RegisterModel(new(OutsideReportAttachment))
  15. }
  16. // GetOutsideReportAttachmentListByReportId 根据报告id获取附件列表
  17. func GetOutsideReportAttachmentListByReportId(outsideReportId int) (attachmentList []*OutsideReportAttachment, err error) {
  18. o := orm.NewOrm()
  19. // 改写成通过ql查询
  20. sql := `select * from outside_report_attachment where outside_report_id = ?`
  21. _, err = o.Raw(sql, outsideReportId).QueryRows(&attachmentList)
  22. if err != nil {
  23. return nil, err
  24. }
  25. return attachmentList, nil
  26. }