config.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxConfig struct {
  7. ConfigId int `json:"-" orm:"column(config_id);pk"`
  8. ConfigCode string `json:"-"`
  9. ConfigValue string
  10. Remark string `json:"-"`
  11. CreateTime time.Time `json:"-"`
  12. }
  13. type KeyWord struct {
  14. KeyWord string `description:"关键词"`
  15. }
  16. func GetConfigByCode(configCode string) (item *CygxConfig, err error) {
  17. sql := `SELECT * FROM cygx_config WHERE config_code=? `
  18. err = orm.NewOrm().Raw(sql, configCode).QueryRow(&item)
  19. return
  20. }
  21. type ConfigResp struct {
  22. Item *CygxConfig
  23. List []*KeyWord `description:"图表搜索推荐"`
  24. ListHot []*KeyWord `description:"热搜关键词"`
  25. }
  26. //获取是否展示限免标签
  27. func GetShowSustainable() (count int, err error) {
  28. o := orm.NewOrm()
  29. sqlCount := ` SELECT COUNT(1) FROM cygx_config WHERE config_code= 'is_show_sustainable' AND config_value = 1 `
  30. err = o.Raw(sqlCount).QueryRow(&count)
  31. return
  32. }
  33. // 通过报告精选来获取最新的推荐搜索词
  34. func GetHotSearch() (permission string, err error) {
  35. sql := `SELECT
  36. GROUP_CONCAT( DISTINCT rl.subject_name ORDER BY rl.article_sun_id ASC SEPARATOR ',' ) AS subject_name
  37. FROM
  38. cygx_report_selection_log AS rl
  39. WHERE
  40. rl.article_id = (
  41. SELECT
  42. MAX( article_id )
  43. FROM
  44. cygx_report_selection
  45. WHERE
  46. publish_status = 1)`
  47. o := orm.NewOrm()
  48. err = o.Raw(sql).QueryRow(&permission)
  49. return
  50. }