config.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. package utils
  2. import (
  3. "fmt"
  4. "github.com/beego/beego/v2/server/web"
  5. "github.com/rdlucklib/rdluck_tools/cache"
  6. "strconv"
  7. )
  8. var (
  9. RunMode string //运行模式
  10. MYSQL_URL string //数据库连接
  11. MYSQL_URL_CYGX string // 查研观向
  12. REDIS_CACHE string //缓存地址
  13. Rc *cache.Cache //redis缓存
  14. Re error //redis错误
  15. )
  16. // 微信配置信息
  17. var (
  18. WxId string //微信原始ID
  19. WxAppId string //买方研选小程序
  20. WxAppSecret string //买方研选小程序
  21. WxPlatform = 12 // 注册平台:1-日度点评公众号; 2-管理后台; 3-PC端网站; 4-查研观向小程序; 6-研报小程序; 7-查研观向开发平台; 8-查研观向小助手公众号; 9-研报备用小程序,10:买方研选小程序(权益),11:买方研选网页版(权益)12买方研选公众号',
  22. WxPublicAppId string //买方研选公众号
  23. WxPublicAppSecret string //买方研选公众号
  24. HeadimgurlDefault string //默认头像
  25. )
  26. // 日志配置
  27. var (
  28. LogPath string //调用过程中的日志存放地址
  29. LogFile string
  30. LogDataPath string //调用过程中图表相关的日志存放地址
  31. LogDataFile string
  32. BinLogPath string //数据库相关的日志存放地址
  33. BinLogFile string
  34. ApiLogPath string //接口请求地址和接口返回值日志存放地址
  35. ApiLogFile string
  36. LogMaxDays int //日志最大保留天数
  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. if RunMode == "" {
  45. localIp, err := GetLocalIP()
  46. fmt.Println("localIp:", localIp)
  47. if localIp == "10.0.0.123" {
  48. RunMode = "debug"
  49. } else {
  50. RunMode = "release"
  51. }
  52. configPath := `/home/code/config/hongze_mfyx_gzh/conf/app.conf`
  53. err = web.LoadAppConfig("ini", configPath)
  54. if err != nil {
  55. fmt.Println("web.LoadAppConfig Err:" + err.Error())
  56. }
  57. }
  58. config, err := web.AppConfig.GetSection(RunMode)
  59. if err != nil {
  60. panic("配置文件读取错误 " + err.Error())
  61. }
  62. fmt.Println(RunMode + " 模式")
  63. MYSQL_URL = config["mysql_url"]
  64. MYSQL_URL_CYGX = config["mysql_url_cygx"]
  65. REDIS_CACHE = config["beego_cache"]
  66. if len(REDIS_CACHE) <= 0 {
  67. panic("redis链接参数没有配置")
  68. }
  69. Rc, Re = cache.NewCache(REDIS_CACHE) //初始化缓存
  70. if Re != nil {
  71. fmt.Println(Re)
  72. panic(Re)
  73. }
  74. if RunMode == "release" {
  75. WxPublicAppId = "wx2f85cdbe74585222" //买方研选
  76. WxPublicAppSecret = "98e4a09c9ba6a0b34e0df3192ba1aba3" //买方研选
  77. WxId = "gh_38912ddf5884" //买方研选公众号原始ID
  78. } else {
  79. WxPublicAppId = "wx9b5d7291e581233a" //弘则投研公众号 开发者ID(AppID)
  80. WxPublicAppSecret = "f4d52e34021eee262dce9682b31f8861" //弘则投研公众号秘钥
  81. WxId = "gh_5dc508325c6f" //弘则投研公众号原始ID
  82. }
  83. HeadimgurlDefault = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202202/20220225/XFBBOUmDC5AXkfxnHiuqKpPtoofH.png"
  84. //日志配置
  85. {
  86. LogPath = config["log_path"]
  87. LogFile = config["log_file"]
  88. LogDataPath = config["log_data_path"]
  89. LogDataFile = config["log_data_file"]
  90. BinLogPath = config["binlog_path"]
  91. BinLogFile = config["binlog_file"]
  92. ApiLogPath = config["apilog_path"]
  93. ApiLogFile = config["apilog_file"]
  94. logMaxDaysStr := config["log_max_day"]
  95. LogMaxDays, _ = strconv.Atoi(logMaxDaysStr)
  96. }
  97. }
  98. //http://webapi.brilliantstart.cn/api/
  99. //http://webapi.brilliantstart.cn/swagger/
  100. //http://139.196.122.219:8603/swagger/