config.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. package utils
  2. import (
  3. "fmt"
  4. "github.com/beego/beego/v2/core/logs"
  5. "github.com/beego/beego/v2/server/web"
  6. "rdluck_tools/cache"
  7. )
  8. var (
  9. RunMode string //运行模式
  10. MYSQL_URL string //数据库连接
  11. MYSQL_URL_RDDP string //数据库连接
  12. MYSQL_URL_EDB string
  13. REDIS_CACHE string //缓存地址
  14. Rc *cache.Cache //redis缓存
  15. Re error //redis错误
  16. )
  17. var (
  18. STATIC_DIR string
  19. )
  20. //微信配置信息
  21. var (
  22. WxId string //微信原始ID
  23. WxAppId string
  24. WxAppSecret string
  25. TemplateIdByProduct string //产品运行报告通知-模板ID
  26. TemplateRedirectUrl string //模板消息跳转地址
  27. WxPlatform int //用户来源,需要入库,用来保存该用户来自哪个平台,默认是:1
  28. )
  29. //pc端微信配置信息
  30. var (
  31. PcWxId string //微信原始ID
  32. PcWxAppId string
  33. PcWxAppSecret string
  34. PcTemplateIdByProduct string //产品运行报告通知-模板ID
  35. PcTemplateRedirectUrl string //模板消息跳转地址
  36. WxPcPlatform int //用户来源,需要入库,用来保存该用户来自哪个平台,默认是:3
  37. )
  38. func init() {
  39. tmpRunMode, err := web.AppConfig.String("run_mode")
  40. if err != nil {
  41. panic("配置文件读取run_mode错误 " + err.Error())
  42. }
  43. RunMode = tmpRunMode
  44. config, err := web.AppConfig.GetSection(RunMode)
  45. if err != nil {
  46. panic("配置文件读取错误 " + err.Error())
  47. }
  48. logs.Info(RunMode + " 模式")
  49. MYSQL_URL = config["mysql_url"]
  50. MYSQL_URL_RDDP = config["mysql_url_rddp"]
  51. MYSQL_URL_EDB = config["mysql_url_edb"]
  52. REDIS_CACHE = config["beego_cache"]
  53. if len(REDIS_CACHE) <= 0 {
  54. panic("redis链接参数没有配置")
  55. }
  56. Rc, Re = cache.NewCache(REDIS_CACHE) //初始化缓存
  57. if Re != nil {
  58. fmt.Println(Re)
  59. panic(Re)
  60. }
  61. if RunMode == "release" {
  62. WxAppId = "wx4a844c734d8c8e56"
  63. WxAppSecret = "26c586e7ccb3c575433f0f37797b3eeb"
  64. WxId = "gh_b67e0049fb8c"
  65. TemplateIdByProduct = "Cp2wF8gvBtxyWV4DeYuI172oqwyYXVRSm3AyJO42d84"
  66. TemplateRedirectUrl = "https://ficc.hzinsights.com/reportdtl?id="
  67. WxPlatform = 1
  68. WxPcPlatform = 3
  69. PcWxAppId = "wx615472d6874eeb7f"
  70. PcWxAppSecret = "97fe374fb0cc90ef58c4b49d431366f1"
  71. STATIC_DIR = "/home/static/imgs/"
  72. } else {
  73. WxAppId = "wx9b5d7291e581233a"
  74. WxAppSecret = "f4d52e34021eee262dce9682b31f8861"
  75. WxId = "gh_5dc508325c6f"
  76. TemplateIdByProduct = "-YjuPOB7Fqd-S3ilabYa6wvjDY9aXmeEfPN6DCiy-EY"
  77. TemplateRedirectUrl = "http://rddpweb.brilliantstart.cn/reportdtl?id="
  78. WxPlatform = 1
  79. WxPcPlatform = 3
  80. PcWxAppId = "wx7c8084f6e5b1d85a"
  81. PcWxAppSecret = "9e4210cd5a363aa1f316b7c4b8898418"
  82. STATIC_DIR = "/home/static/imgs/"
  83. }
  84. }
  85. //http://webapi.brilliantstart.cn/api/
  86. //http://webapi.brilliantstart.cn/swagger/
  87. //http://139.196.122.219:8603/swagger/