config.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package utils
  2. import (
  3. "fmt"
  4. "github.com/astaxie/beego"
  5. "rdluck_tools/cache"
  6. )
  7. var (
  8. RunMode string //运行模式
  9. MYSQL_URL string //数据库连接
  10. MYSQL_URL_INDUSTRY string //数据库连接
  11. REDIS_CACHE string //缓存地址
  12. Rc *cache.Cache //redis缓存
  13. Re error //redis错误
  14. )
  15. //微信配置信息
  16. var (
  17. WxId string //微信原始ID
  18. WxAppId string
  19. WxAppSecret string
  20. RemindTemplateId string
  21. )
  22. func init() {
  23. RunMode = beego.AppConfig.String("run_mode")
  24. config, err := beego.AppConfig.GetSection(RunMode)
  25. if err != nil {
  26. panic("配置文件读取错误 " + err.Error())
  27. }
  28. beego.Info(RunMode + " 模式")
  29. MYSQL_URL = config["mysql_url"]
  30. MYSQL_URL_INDUSTRY = config["mysql_url_industry"]
  31. REDIS_CACHE = config["beego_cache"]
  32. if len(REDIS_CACHE) <= 0 {
  33. panic("redis链接参数没有配置")
  34. }
  35. Rc, Re = cache.NewCache(REDIS_CACHE) //初始化缓存
  36. if Re != nil {
  37. fmt.Println(Re)
  38. panic(Re)
  39. }
  40. if RunMode == "release" {
  41. WxAppId = "wx783118ccac2e9fd3"
  42. WxAppSecret = "INbwN7p8ywpToc1iHpRunDjUJSqA4OTa5jcZYaQC0gE"
  43. WxId = "gh_b67e0049fb8c"
  44. } else {
  45. WxAppId = "wx9b5d7291e581233a"
  46. WxAppSecret = "f4d52e34021eee262dce9682b31f8861"
  47. WxId = "gh_5dc508325c6f"
  48. RemindTemplateId="pDk4o924gSZWj80ZdNnHodnLMIXjPSlKZU0ciQMOhec"
  49. }
  50. }
  51. //http://adminapi.brilliantstart.cn/admin/
  52. //http://adminapi.brilliantstart.cn/swagger/
  53. //http://139.196.122.219:8602/swagger/