package models import ( "time" "github.com/beego/beego/v2/client/orm" ) type ReportPdf struct { ReportPdfId int `orm:"pk" description:"id"` PdfUrl string `description:"pdf文件URL"` PdfName string `description:"pdf文件名称"` Title string `description:"pdf文件标题"` Author string `description:"作者"` Abstract string `description:"摘要"` ClassifyIdFirst int `description:"一级分类id"` ClassifyNameFirst string `description:"一级分类名称"` ClassifyIdSecond int `description:"二级分类id"` ClassifyNameSecond string `description:"二级分类名称"` ClassifyIdThird int `description:"三级分类id"` ClassifyNameThird string `description:"三级分类名称"` Stage int `description:"期数"` PublishTime time.Time `description:"发布时间"` ModifyTime time.Time `description:"更新时间"` Pv int `description:"pv"` Uv int `description:"uv"` SysUserId int `description:"创建人id"` SysRealName string `description:"创建人姓名"` State int `description:"状态"` } func GetReportPdfClasssify() (items []*ReportPdf, err error) { o := orm.NewOrm() sql := `SELECT report_pdf_id,classify_id_first, classify_id_second, classify_id_third, classify_name_first, classify_name_second, classify_name_third FROM report_pdf ` _, err = o.Raw(sql).QueryRows(&items) return } // MultiUpdateReportPdfClassify修改pdf研报的分类 func MultiUpdateReportPdfClassify(items []*ReportPdf) (err error) { if len(items) == 0 { return } o := orm.NewOrm() sql := `UPDATE report_pdf SET classify_id_first=?, classify_id_second=?, classify_id_third=?, classify_name_first=?,classify_name_second=?,classify_name_third=? WHERE report_pdf_id=?` db, err := o.Raw(sql).Prepare() if err != nil { return } for _, v := range items { _, err = db.Exec(v.ClassifyIdFirst, v.ClassifyIdSecond, v.ClassifyIdThird, v.ClassifyNameFirst, v.ClassifyNameSecond, v.ClassifyNameThird, v.ReportPdfId) if err != nil { return } } return }