config.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. package utils
  2. import (
  3. "fmt"
  4. beeLogger "github.com/beego/bee/v2/logger"
  5. "github.com/beego/beego/v2/server/web"
  6. "strconv"
  7. )
  8. var (
  9. RunMode string //运行模式
  10. APP_NAME_CN string
  11. MYSQL_URL string //数据库连接
  12. MONGODB_URL string //mongodb连接
  13. MONGODB_COMMUNITY string //mongodb库名
  14. MONGODB_CREDENTIAL string
  15. )
  16. // 公共api内部服务调用
  17. var (
  18. // EDB_LIB_URL 公共指标库
  19. EDB_LIB_URL string
  20. APP_EDB_LIB_NAME_EN string
  21. EDB_LIB_Md5_KEY string
  22. OpUserId int // 操作人id
  23. OpUserRealName string // 操作人真实名称
  24. )
  25. // 弘则
  26. const (
  27. APPID = "SJCrpOPvagscPxEv"
  28. SECRET = "gLLjT72uFHQZEFtaFCuoZegD1z2ezfyX"
  29. )
  30. // 日志配置
  31. var (
  32. LogPath string //调用过程中的日志存放地址
  33. LogFile string
  34. LogDataPath string //调用过程中图表相关的日志存放地址
  35. LogDataFile string
  36. BinLogPath string //数据库相关的日志存放地址
  37. BinLogFile string
  38. ApiLogPath string //接口请求地址和接口返回值日志存放地址
  39. ApiLogFile string
  40. LogMaxDays int //日志最大保留天数
  41. )
  42. var (
  43. EtaBridgeUrl string // 桥接服务地址
  44. EtaBridgeAppNameEn string // 桥接服务英文名称-鉴权用
  45. EtaBridgeMd5Key string // 桥接服务Md5密钥-鉴权用
  46. EtaBridgeDesKey string // 桥接服务Des密钥-解密数据用
  47. SyncUserPath string // 桥接服务-用户同步服务地址
  48. SyncIndexPath string // 桥接服务-指标同步服务地址
  49. )
  50. // AlarmMsgUrl 报警服务地址
  51. var AlarmMsgUrl string
  52. func init() {
  53. tmpRunMode, err := web.AppConfig.String("run_mode")
  54. if err != nil {
  55. panic("配置文件读取run_mode错误 " + err.Error())
  56. }
  57. RunMode = tmpRunMode
  58. fmt.Println("RunMode:", RunMode)
  59. config, err := web.AppConfig.GetSection(RunMode)
  60. if err != nil {
  61. panic("配置文件读取错误 " + err.Error())
  62. }
  63. beeLogger.Log.Info(RunMode + " 模式")
  64. // 项目中文名称
  65. appNameCn, err := web.AppConfig.String("app_name_cn")
  66. if err != nil {
  67. panic(any("配置文件读取app_name_cn错误 " + err.Error()))
  68. }
  69. APP_NAME_CN = appNameCn
  70. MYSQL_URL = config["mysql_url"]
  71. MONGODB_URL = config["mongodb_url"]
  72. MONGODB_COMMUNITY = config["mongodb_community"]
  73. MONGODB_CREDENTIAL = config["mongodb_credential"]
  74. // 公共api内部服务调用
  75. {
  76. // 公共指标库相关
  77. EDB_LIB_URL = config["edb_lib_url"]
  78. APP_EDB_LIB_NAME_EN = config["app_edb_lib_name_en"]
  79. EDB_LIB_Md5_KEY = config["edb_lib_md5_key"]
  80. opUserIdStr := config["op_user_id"]
  81. if opUserIdStr != `` {
  82. OpUserId, err = strconv.Atoi(opUserIdStr)
  83. if err != nil {
  84. panic("配置文件中操作人配置错误 " + err.Error())
  85. }
  86. }
  87. OpUserRealName = config["op_user_real_name"]
  88. }
  89. //日志配置
  90. {
  91. LogPath = config["log_path"]
  92. LogFile = config["log_file"]
  93. LogDataPath = config["log_data_path"]
  94. LogDataFile = config["log_data_file"]
  95. BinLogPath = config["binlog_path"]
  96. BinLogFile = config["binlog_file"]
  97. ApiLogPath = config["apilog_path"]
  98. ApiLogFile = config["apilog_file"]
  99. logMaxDaysStr := config["log_max_day"]
  100. LogMaxDays, _ = strconv.Atoi(logMaxDaysStr)
  101. }
  102. {
  103. // 报警服务地址
  104. AlarmMsgUrl = config["alarm_msg_url"]
  105. }
  106. }
  107. //修改接口文档
  108. //http://8.136.199.33:8300/swagger/