outside_report_attachment.go 1.1 KB

12345678910111213141516171819202122232425262728293031
  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) (attachmentList []*OutsideReportAttachment, err error) {
  17. o := orm.NewOrm()
  18. // 改写成通过ql查询
  19. sql := `select * from outside_report_attachment where outside_report_id = ?`
  20. _, err = o.Raw(sql, outsideReportId).QueryRows(&attachmentList)
  21. if err != nil {
  22. return nil, err
  23. }
  24. return attachmentList, nil
  25. }