package models import ( "github.com/beego/beego/v2/client/orm" "time" ) // ReportPptImg Ppt转报告的图片记录表 type ReportPptImg struct { ReportPptImgId int `orm:"column(report_ppt_img_id);pk;auto" description:"自增id"` PptId int `description:"ppt的id"` ReportId int `description:"关联的报告ID"` ReportChapterId int `description:"关联的报告章节ID"` ImgUrl string `description:"ppt图片地址"` CreateTime time.Time `description:"创建时间"` } // AddAndEditMultiReportPptImg 批量添加Ppt转报告的图片记录 func AddAndEditMultiReportPptImg(pptId int, reportPptImgList []*ReportPptImg) (err error) { if len(reportPptImgList) < 0 { return } o := orm.NewOrmUsingDB("rddp") to, err := o.Begin() if err != nil { return } defer func() { if err != nil { _ = to.Rollback() } else { _ = to.Commit() } }() sql := ` DELETE FROM report_ppt_img WHERE ppt_id = ?` _, err = to.Raw(sql, pptId).Exec() if err != nil { return } _, err = to.InsertMulti(len(reportPptImgList), reportPptImgList) return }