report_pdf.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package models
  2. import (
  3. "time"
  4. "github.com/beego/beego/v2/client/orm"
  5. )
  6. type ReportPdf struct {
  7. ReportPdfId int `orm:"pk" description:"id"`
  8. PdfUrl string `description:"pdf文件URL"`
  9. PdfName string `description:"pdf文件名称"`
  10. Title string `description:"pdf文件标题"`
  11. Author string `description:"作者"`
  12. Abstract string `description:"摘要"`
  13. ClassifyIdFirst int `description:"一级分类id"`
  14. ClassifyNameFirst string `description:"一级分类名称"`
  15. ClassifyIdSecond int `description:"二级分类id"`
  16. ClassifyNameSecond string `description:"二级分类名称"`
  17. ClassifyIdThird int `description:"三级分类id"`
  18. ClassifyNameThird string `description:"三级分类名称"`
  19. Stage int `description:"期数"`
  20. PublishTime time.Time `description:"发布时间"`
  21. ModifyTime time.Time `description:"更新时间"`
  22. Pv int `description:"pv"`
  23. Uv int `description:"uv"`
  24. SysUserId int `description:"创建人id"`
  25. SysRealName string `description:"创建人姓名"`
  26. State int `description:"状态"`
  27. }
  28. func GetReportPdfClasssify() (items []*ReportPdf, err error) {
  29. o := orm.NewOrm()
  30. 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 `
  31. _, err = o.Raw(sql).QueryRows(&items)
  32. return
  33. }
  34. // MultiUpdateReportPdfClassify修改pdf研报的分类
  35. func MultiUpdateReportPdfClassify(items []*ReportPdf) (err error) {
  36. if len(items) == 0 {
  37. return
  38. }
  39. o := orm.NewOrm()
  40. 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=?`
  41. db, err := o.Raw(sql).Prepare()
  42. if err != nil {
  43. return
  44. }
  45. for _, v := range items {
  46. _, err = db.Exec(v.ClassifyIdFirst, v.ClassifyIdSecond, v.ClassifyIdThird, v.ClassifyNameFirst, v.ClassifyNameSecond, v.ClassifyNameThird, v.ReportPdfId)
  47. if err != nil {
  48. return
  49. }
  50. }
  51. return
  52. }