resource_data.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package cygx
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxResourceData struct {
  7. Id int `orm:"column(id);pk"`
  8. SourceId int `description:"资源ID"`
  9. Source string `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
  10. Title string `description:"标题"`
  11. Annotation string `description:"核心观点"`
  12. CreateTime time.Time `description:"创建时间"`
  13. PublishDate string `description:"发布时间"`
  14. Abstract string `description:"摘要"`
  15. SearchTag string `description:"搜索标签"`
  16. }
  17. // 添加
  18. func AddCygxResourceData(item *CygxResourceData) (lastId int64, err error) {
  19. o := orm.NewOrm()
  20. lastId, err = o.Insert(item)
  21. return
  22. }
  23. // 删除数据
  24. func DeleteResourceData(sourceId int, source string) (err error) {
  25. o := orm.NewOrm()
  26. sql := ` DELETE FROM cygx_resource_data WHERE source_id = ? AND source =? `
  27. _, err = o.Raw(sql, sourceId, source).Exec()
  28. return
  29. }
  30. // 修改数据
  31. func UpdateResourceData(sourceId int, source, publishDate string) (err error) {
  32. o := orm.NewOrm()
  33. sql := `UPDATE cygx_resource_data SET publish_date=? WHERE source_id=? AND source =? `
  34. _, err = o.Raw(sql, publishDate, sourceId, source).Exec()
  35. return
  36. }
  37. // 获取数量
  38. func GetCygxReportSelectionBySourceAndId(sourceId int, source string) (count int, err error) {
  39. o := orm.NewOrm()
  40. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_resource_data WHERE source_id = ? AND source =? `
  41. err = o.Raw(sqlCount, sourceId, source).QueryRow(&count)
  42. return
  43. }