config.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. var (
  7. HomeHeaderTabConfigKey = "home_header_tab"
  8. MicroRoadShowListDataRatioConfigKey = "micro_roadshow_list_data_ratio"
  9. )
  10. type CygxConfig struct {
  11. ConfigId int `json:"-" orm:"column(config_id);pk"`
  12. ConfigCode string `json:"-"`
  13. ConfigValue string
  14. Remark string `json:"-"`
  15. CreateTime time.Time `json:"-"`
  16. }
  17. type KeyWord struct {
  18. KeyWord string `description:"关键词"`
  19. }
  20. func GetConfigByCode(configCode string) (item *CygxConfig, err error) {
  21. sql := `SELECT * FROM cygx_config WHERE config_code=? `
  22. err = orm.NewOrm().Raw(sql, configCode).QueryRow(&item)
  23. return
  24. }
  25. //更改配置信息
  26. func UpdateConfigByCode(configValue, countryCode string) (err error) {
  27. o := orm.NewOrm()
  28. sql := `UPDATE cygx_config SET config_value= ? WHERE config_code=? `
  29. _, err = o.Raw(sql, configValue, countryCode).Exec()
  30. return
  31. }
  32. type ConfigResp struct {
  33. Item *CygxConfig
  34. List []*KeyWord `description:"图表搜索推荐"`
  35. ListHot []*KeyWord `description:"热搜关键词"`
  36. }
  37. //获取是否展示限免标签
  38. func GetShowSustainable() (count int, err error) {
  39. o := orm.NewOrm()
  40. sqlCount := ` SELECT COUNT(1) FROM cygx_config WHERE config_code= 'is_show_sustainable' AND config_value = 1 `
  41. err = o.Raw(sqlCount).QueryRow(&count)
  42. return
  43. }
  44. // 通过报告精选来获取最新的推荐搜索词
  45. func GetHotSearch() (permission string, err error) {
  46. sql := `SELECT
  47. GROUP_CONCAT( DISTINCT rl.subject_name ORDER BY rl.article_sun_id ASC SEPARATOR ',' ) AS subject_name
  48. FROM
  49. cygx_report_selection_log AS rl
  50. WHERE
  51. rl.article_id = (
  52. SELECT
  53. MAX( article_id )
  54. FROM
  55. cygx_report_selection
  56. WHERE
  57. publish_status = 1)`
  58. o := orm.NewOrm()
  59. err = o.Raw(sql).QueryRow(&permission)
  60. return
  61. }
  62. type HomeHeaderTabList struct {
  63. Home []*HomeHeaderTab `description:"首页"`
  64. SearchPage []*HomeHeaderTab `description:"搜索页"`
  65. }
  66. type HomeHeaderTab struct {
  67. Id int `description:"导航ID"`
  68. Name string `description:"导航名称"`
  69. IsShow bool `description:"是否展示"`
  70. }