report_ppt_img.go 1.3 KB

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