config.go 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. package utils
  2. import (
  3. "fmt"
  4. "github.com/beego/beego/v2/core/logs"
  5. "github.com/beego/beego/v2/server/web"
  6. "github.com/rdlucklib/rdluck_tools/log"
  7. )
  8. var (
  9. RunMode string //运行模式
  10. MYSQL_URL string //数据库连接
  11. MYSQL_URL_RDDP string //数据库连接
  12. )
  13. //微信配置信息
  14. var (
  15. WxId string //微信原始ID
  16. WxAppId string
  17. WxAppSecret string
  18. TemplateIdByProduct string //产品运行报告通知-模板ID
  19. TemplateRedirectUrl string //模板消息跳转地址
  20. WxPlatform int //用户来源,需要入库,用来保存该用户来自哪个平台,默认是:1
  21. TemplateIdByCompanyApply string //客户申请单审批通知-模板ID
  22. TemplateCompanyApplyRedirectUrl string //审批单模板消息跳转地址
  23. //微信小程序appid
  24. WxId2 string //微信原始ID
  25. WxAppId2 string
  26. WxAppSecret2 string
  27. WxPlatform2 int //用户来源,需要入库,用来保存该用户来自哪个平台,默认是:1
  28. )
  29. var (
  30. STATIC_DIR string
  31. )
  32. var ApiLog *log.Log
  33. // LibreOfficePath LibreOfficePath的地址
  34. var LibreOfficePath string
  35. var (
  36. Bucketname string = "hongze"
  37. Endpoint string
  38. Imghost string = "https://hongze.oss-accelerate.aliyuncs.com/"
  39. Upload_dir string = "static/images/"
  40. Upload_Audio_Dir string = "static/audio/"
  41. AccessKeyId string = "LTAIFMZYQhS2BTvW"
  42. AccessKeySecret string = "12kk1ptCHoGWedhBnKRVW5hRJzq9Fq"
  43. )
  44. func init() {
  45. tmpRunMode, err := web.AppConfig.String("run_mode")
  46. if err != nil {
  47. panic("配置文件读取run_mode错误 " + err.Error())
  48. }
  49. RunMode = tmpRunMode
  50. if RunMode == "" {
  51. localIp, tempErr := GetLocalIP()
  52. if tempErr != nil {
  53. fmt.Println("init GetLocalIP Err:" + tempErr.Error())
  54. }
  55. fmt.Println("localIp:", localIp)
  56. if localIp == "10.0.0.123" {
  57. RunMode = "debug"
  58. } else {
  59. RunMode = "release"
  60. }
  61. fmt.Println("RunMode:", RunMode)
  62. configPath := `/home/code/config/hongze_mobile_admin/conf/app.conf`
  63. tempErr = web.LoadAppConfig("ini", configPath)
  64. if tempErr != nil {
  65. fmt.Println("web.LoadAppConfig Err:" + tempErr.Error())
  66. }
  67. }
  68. fmt.Println(RunMode, "模式")
  69. config, err := web.AppConfig.GetSection(RunMode)
  70. if err != nil {
  71. panic("配置文件读取错误 " + err.Error())
  72. }
  73. logs.Info(RunMode + " 模式")
  74. MYSQL_URL = config["mysql_url"]
  75. MYSQL_URL_RDDP = config["mysql_url_rddp"]
  76. //小程序appid配置
  77. WxAppId2 = `wx67b68e39913e511e`
  78. WxId2 = `wx67b68e39913e511e`
  79. WxAppSecret2 = `660b0375f701a19220bb8a662b41c77c`
  80. WxPlatform2 = 5
  81. if RunMode == "release" {
  82. WxAppId = "wx4a844c734d8c8e56"
  83. WxAppSecret = "26c586e7ccb3c575433f0f37797b3eeb"
  84. WxId = "gh_b67e0049fb8c"
  85. TemplateIdByProduct = "Cp2wF8gvBtxyWV4DeYuI172oqwyYXVRSm3AyJO42d84"
  86. TemplateRedirectUrl = "https://ficc.hzinsights.com/reportdtl?id="
  87. WxPlatform = 1
  88. TemplateIdByCompanyApply = "ZKcOfNIWBpwHJxpptufHIK1mp2nIwkT3cxub-35cFqI"
  89. TemplateCompanyApplyRedirectUrl = "https://ficc.hzinsights.com/approval/approval/list"
  90. //oss
  91. STATIC_DIR = "/home/static/imgs/"
  92. Endpoint = "oss-cn-shanghai-internal.aliyuncs.com"
  93. } else {
  94. WxAppId = "wx9b5d7291e581233a"
  95. WxAppSecret = "f4d52e34021eee262dce9682b31f8861"
  96. WxId = "gh_5dc508325c6f"
  97. TemplateIdByProduct = "-YjuPOB7Fqd-S3ilabYa6wvjDY9aXmeEfPN6DCiy-EY"
  98. TemplateRedirectUrl = "http://rddpweb.brilliantstart.cn/reportdtl?id="
  99. WxPlatform = 1
  100. TemplateIdByCompanyApply = "eTalI1LbiT_B0mTaBeDTlfSMITenK8dQIgEB5yqjjvA"
  101. TemplateCompanyApplyRedirectUrl = "http://advisoryadmin.brilliantstart.cn/approval/approval/list"
  102. //oss配置
  103. STATIC_DIR = "static/imgs/"
  104. Endpoint = "oss-cn-shanghai.aliyuncs.com"
  105. }
  106. tmpLibreOfficePath, err := web.AppConfig.String("libreOfficePath")
  107. if err != nil {
  108. panic("配置文件读取libreOfficePath错误 " + err.Error())
  109. }
  110. LibreOfficePath = tmpLibreOfficePath
  111. //日志类
  112. if RunMode == "release" {
  113. logDir := `/data/rdlucklog/hongze_mobile_admin`
  114. ApiLog = log.Init("20060102.api", logDir)
  115. } else {
  116. ApiLog = log.Init("20060102.api")
  117. }
  118. }
  119. //http://webapi.brilliantstart.cn/api/
  120. //http://webapi.brilliantstart.cn/swagger/
  121. //http://139.196.122.219:8603/swagger/