report_ppt_img.go 1.4 KB

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