search_key_word.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package models
  2. import (
  3. "eta_gn/eta_api/global"
  4. "time"
  5. )
  6. // SearchKeyWord 搜索关键词
  7. type SearchKeyWord struct {
  8. SearchKeyWordId int `gorm:"column:search_key_word_id;primaryKey;type:int" orm:"column(search_key_word_id)" description:"主键ID"`
  9. KeyWord string `gorm:"column:key_word;type:varchar(255)" orm:"column(key_word)" description:"关键词"`
  10. From string `gorm:"column:from;type:varchar(255)" orm:"column(from)" description:"来源,在什么地方筛选"`
  11. CreatedTime time.Time `gorm:"column:created_time;type:datetime" orm:"column(created_time)" description:"创建时间"`
  12. LastUpdatedTime time.Time `gorm:"column:last_updated_time;type:datetime" orm:"column(last_updated_time)" description:"更新时间"`
  13. TeleconferenceImage string `gorm:"column:teleconference_image;type:varchar(255)" orm:"column(teleconference_image)" description:"电话会对应的类型图片"`
  14. BannerImage string `gorm:"column:banner_image;type:varchar(255)" orm:"column(banner_image)" description:"Banner图"`
  15. }
  16. // AddTrendTagKeyWord 新增趋势标签关键词
  17. func AddTrendTagKeyWord(trend string) (err error) {
  18. //o := orm.NewOrm()
  19. sql := " REPLACE INTO search_key_word (`key_word`,`from`) values (?,'trend') "
  20. //_, err = o.Raw(sql, trend).Exec()
  21. err = global.DEFAULT_DmSQL.Exec(sql, trend).Error
  22. return
  23. }
  24. // GetKeyWordListByFrom 根据来源获取搜索关键词列表
  25. func GetKeyWordListByFrom(from string) (list []*SearchKeyWord, err error) {
  26. //o := orm.NewOrm()
  27. sql := ` SELECT * FROM search_key_word WHERE "from" = ? ORDER BY created_time ASC `
  28. //_, err = o.Raw(sql, from).QueryRows(&list)
  29. err = global.DEFAULT_DmSQL.Raw(sql, from).Find(&list).Error
  30. return
  31. }