report_ppt_img.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // ReportPptImg Ppt转报告的图片记录表
  7. type ReportPptImg struct {
  8. ReportPptImgId int `orm:"column(report_ppt_img_id);pk;auto" description:"自增id"`
  9. PptId int `description:"ppt的id"`
  10. ReportId int `description:"关联的报告ID"`
  11. ReportChapterId int `description:"关联的报告章节ID"`
  12. ImgUrl string `description:"ppt图片地址"`
  13. CreateTime time.Time `description:"创建时间"`
  14. }
  15. // AddAndEditMultiReportPptImg 批量添加Ppt转报告的图片记录
  16. func AddAndEditMultiReportPptImg(pptId int, reportPptImgList []*ReportPptImg) (err error) {
  17. if len(reportPptImgList) < 0 {
  18. return
  19. }
  20. o := orm.NewOrmUsingDB("rddp")
  21. to, err := o.Begin()
  22. if err != nil {
  23. return
  24. }
  25. defer func() {
  26. if err != nil {
  27. _ = to.Rollback()
  28. } else {
  29. _ = to.Commit()
  30. }
  31. }()
  32. sql := ` DELETE FROM report_ppt_img WHERE ppt_id = ?`
  33. _, err = to.Raw(sql, pptId).Exec()
  34. if err != nil {
  35. return
  36. }
  37. _, err = to.InsertMulti(len(reportPptImgList), reportPptImgList)
  38. return
  39. }