config.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. Item *CygxConfig
  36. List []*KeyWord `description:"图表搜索推荐"`
  37. ListHot []*KeyWord `description:"热搜关键词"`
  38. }
  39. type ConfigImgListResp struct {
  40. List []*ConfigImgResp
  41. }
  42. type ConfigImgResp struct {
  43. Img string `description:"图片"`
  44. Height string `description:"高度"`
  45. }
  46. type ConfigImgHbResp struct {
  47. HbImg string `description:"海报"`
  48. ButtonImg string `description:"按钮图片"`
  49. }
  50. // 获取是否展示限免标签
  51. func GetShowSustainable() (count int, err error) {
  52. o := orm.NewOrm()
  53. sqlCount := ` SELECT COUNT(1) FROM cygx_config WHERE config_code= 'is_show_sustainable' AND config_value = 1 `
  54. err = o.Raw(sqlCount).QueryRow(&count)
  55. return
  56. }
  57. // 通过报告精选来获取最新的推荐搜索词
  58. func GetHotSearch() (permission string, err error) {
  59. sql := `SELECT
  60. GROUP_CONCAT( DISTINCT rl.subject_name ORDER BY rl.article_sun_id ASC SEPARATOR ',' ) AS subject_name
  61. FROM
  62. cygx_report_selection_log AS rl
  63. WHERE
  64. rl.article_id = (
  65. SELECT
  66. MAX( article_id )
  67. FROM
  68. cygx_report_selection
  69. WHERE
  70. publish_status = 1)`
  71. o := orm.NewOrm()
  72. err = o.Raw(sql).QueryRow(&permission)
  73. return
  74. }
  75. // HomeHeaderTabList 首页头部导航列表
  76. type HomeHeaderTabList struct {
  77. Home []*HomeHeaderTab `description:"首页"`
  78. SearchPage []*HomeHeaderTab `description:"搜索页"`
  79. }
  80. // HomeHeaderTab 首页头部导航
  81. type HomeHeaderTab struct {
  82. Id int `description:"导航ID"`
  83. Name string `description:"导航名称"`
  84. IsShow bool `description:"是否展示"`
  85. }
  86. // MicroRoadShowDefaultImgList 微路演行业默认背景图列表
  87. type MicroRoadShowDefaultImgList struct {
  88. Audio []*MicroRoadShowDefaultImg `description:"音频"`
  89. Video []*MicroRoadShowDefaultImg `description:"视频"`
  90. }
  91. // MicroRoadShowDefaultImg 微路演行业默认背景图
  92. type MicroRoadShowDefaultImg struct {
  93. ChartPermissionId int `description:"行业ID"`
  94. ChartPermissionName string `description:"行业名称"`
  95. ImgUrl string `description:"背景图"`
  96. ShareImg string `description:"分享图"`
  97. }
  98. // CheckOcrBusinessCard OCR 名片校验
  99. type CheckOcrBusinessCard struct {
  100. CheckMobile bool `description:"是否校验手机号"`
  101. CheckCompany bool `description:"是否校验公司名称"`
  102. }
  103. type AliyunOcrLog struct {
  104. Id int `orm:"column(id);pk"`
  105. ImgUrl string `description:"图片地址"`
  106. Result string `description:"返回内容"`
  107. CreateTime time.Time `description:"创建时间"`
  108. }
  109. func AddAliyunOcrLog(item *AliyunOcrLog) (err error) {
  110. o := orm.NewOrm()
  111. _, err = o.Insert(item)
  112. return
  113. }