outside_report_attachment.go 1.1 KB

123456789101112131415161718192021222324252627282930
  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. }
  11. // 在 init 函数中注册模型
  12. func init() {
  13. orm.RegisterModel(new(OutsideReportAttachment))
  14. }
  15. // GetOutsideReportAttachmentListByReportId 根据报告id获取附件列表
  16. func GetOutsideReportAttachmentListByReportId(outsideReportId int) ([]*OutsideReportAttachment, error) {
  17. o := orm.NewOrmUsingDB("rddp")
  18. var attachmentList []*OutsideReportAttachment
  19. _, err := o.QueryTable("outside_report_attachment").
  20. Filter("outside_report_id", outsideReportId).
  21. All(&attachmentList)
  22. if err != nil {
  23. return nil, err
  24. }
  25. return attachmentList, nil
  26. }