config.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. HomeNewListAudioNumKey = "home_new_list_audio_num"
  10. MicroRoadshowDefaultImgKey = "micro_roadshow_default_img"
  11. )
  12. type CygxConfig struct {
  13. ConfigId int `json:"-" orm:"column(config_id);pk"`
  14. ConfigCode string `json:"-"`
  15. ConfigValue string
  16. Remark string `json:"-"`
  17. CreateTime time.Time `json:"-"`
  18. }
  19. type KeyWord struct {
  20. KeyWord string `description:"关键词"`
  21. }
  22. func GetConfigByCode(configCode string) (item *CygxConfig, err error) {
  23. sql := `SELECT * FROM cygx_config WHERE config_code=? `
  24. err = orm.NewOrm().Raw(sql, configCode).QueryRow(&item)
  25. return
  26. }
  27. // 更改配置信息
  28. func UpdateConfigByCode(configValue, countryCode string) (err error) {
  29. o := orm.NewOrm()
  30. sql := `UPDATE cygx_config SET config_value= ? WHERE config_code=? `
  31. _, err = o.Raw(sql, configValue, countryCode).Exec()
  32. return
  33. }
  34. type ConfigResp struct {
  35. ListRecommend []*KeyWord `description:"图表搜索推荐"`
  36. ListHot []*KeyWord `description:"热搜关键词"`
  37. ListHistory []*KeyWord `description:"关键词搜索记录"`
  38. }
  39. // 获取是否展示限免标签
  40. func GetShowSustainable() (count int, err error) {
  41. o := orm.NewOrm()
  42. sqlCount := ` SELECT COUNT(1) FROM cygx_config WHERE config_code= 'is_show_sustainable' AND config_value = 1 `
  43. err = o.Raw(sqlCount).QueryRow(&count)
  44. return
  45. }
  46. // 通过报告精选来获取最新的推荐搜索词
  47. func GetHotSearch() (permission string, err error) {
  48. sql := `SELECT
  49. GROUP_CONCAT( DISTINCT rl.subject_name ORDER BY rl.article_sun_id ASC SEPARATOR ',' ) AS subject_name
  50. FROM
  51. cygx_report_selection_log AS rl
  52. WHERE
  53. rl.article_id = (
  54. SELECT
  55. MAX( article_id )
  56. FROM
  57. cygx_report_selection
  58. WHERE
  59. publish_status = 1)`
  60. o := orm.NewOrm()
  61. err = o.Raw(sql).QueryRow(&permission)
  62. return
  63. }
  64. // MicroRoadShowDefaultImgList 微路演行业默认背景图列表
  65. type MicroRoadShowDefaultImgList struct {
  66. Audio []*MicroRoadShowDefaultImg `description:"音频"`
  67. Video []*MicroRoadShowDefaultImg `description:"视频"`
  68. }
  69. // MicroRoadShowDefaultImg 微路演行业默认背景图
  70. type MicroRoadShowDefaultImg struct {
  71. ChartPermissionId int `description:"行业ID"`
  72. ChartPermissionName string `description:"行业名称"`
  73. ImgUrl string `description:"背景图"`
  74. ShareImg string `description:"分享图"`
  75. }
  76. type IsShow struct {
  77. IsBelongRai bool `description:"是否属于权益内部人员"`
  78. IsShowResearchPoints bool `description:"是否展示研选扣点搜索"`
  79. }
  80. // 关于我们
  81. type AboutUs struct {
  82. Title string `description:"标题"`
  83. Url string `description:"链接"`
  84. }
  85. type ConfigImgListResp struct {
  86. List []*ConfigImgResp
  87. }
  88. type ConfigImgResp struct {
  89. Img string `description:"图片"`
  90. Height string `description:"高度"`
  91. }
  92. type ConfigImgHbResp struct {
  93. HbImg string `description:"海报"`
  94. ButtonImg string `description:"按钮图片"`
  95. }