report_ppt_english_img.go 1.2 KB

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