resource_data.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. }
  16. //添加
  17. func AddCygxResourceData(item *CygxResourceData) (lastId int64, err error) {
  18. o := orm.NewOrm()
  19. lastId, err = o.Insert(item)
  20. return
  21. }
  22. //删除数据
  23. func DeleteResourceData(sourceId int, source string) (err error) {
  24. o := orm.NewOrm()
  25. sql := ` DELETE FROM cygx_resource_data WHERE source_id = ? AND source =? `
  26. _, err = o.Raw(sql, sourceId, source).Exec()
  27. return
  28. }
  29. //修改数据
  30. func UpdateResourceData(sourceId int, source, publishDate string) (err error) {
  31. o := orm.NewOrm()
  32. sql := `UPDATE cygx_resource_data SET publish_date=? WHERE source_id=? AND source =? `
  33. _, err = o.Raw(sql, publishDate, sourceId, source).Exec()
  34. return
  35. }