config.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. )
  11. // 公共api内部服务调用
  12. var (
  13. // EDB_LIB_URL 公共指标库
  14. EDB_LIB_URL string
  15. APP_EDB_LIB_NAME_EN string
  16. EDB_LIB_Md5_KEY string
  17. OpUserId int // 操作人id
  18. OpUserRealName string // 操作人真实名称
  19. )
  20. // 弘则
  21. const (
  22. APPID = "SJCrpOPvagscPxEv"
  23. SECRET = "gLLjT72uFHQZEFtaFCuoZegD1z2ezfyX"
  24. )
  25. // 日志配置
  26. var (
  27. LogPath string //调用过程中的日志存放地址
  28. LogFile string
  29. BinLogPath string //数据库相关的日志存放地址
  30. BinLogFile string
  31. LogMaxDays int //日志最大保留天数
  32. )
  33. // 涌益生猪
  34. var (
  35. YongyiFilePath string //excel文件地址
  36. YongyiOpen string //是否配置涌益生猪数据源,1已配置
  37. )
  38. // 汾渭煤炭
  39. var (
  40. FenweiFileDir string // excel文件目录
  41. FenweiOldFileDir string // 已读取过的excel文件目录
  42. FenweiOpen string // 是否配置汾渭数据源
  43. FenweiTerminalCode string // 汾渭终端号
  44. )
  45. var TerminalCode string
  46. func init() {
  47. tmpRunMode, err := web.AppConfig.String("run_mode")
  48. if err != nil {
  49. panic("配置文件读取run_mode错误 " + err.Error())
  50. }
  51. RunMode = tmpRunMode
  52. fmt.Println("RunMode:", RunMode)
  53. config, err := web.AppConfig.GetSection(RunMode)
  54. if err != nil {
  55. panic("配置文件读取错误 " + err.Error())
  56. }
  57. beeLogger.Log.Info(RunMode + " 模式")
  58. // 公共api内部服务调用
  59. {
  60. // 公共指标库相关
  61. EDB_LIB_URL = config["edb_lib_url"]
  62. APP_EDB_LIB_NAME_EN = config["app_edb_lib_name_en"]
  63. EDB_LIB_Md5_KEY = config["edb_lib_md5_key"]
  64. opUserIdStr := config["op_user_id"]
  65. if opUserIdStr != `` {
  66. OpUserId, err = strconv.Atoi(opUserIdStr)
  67. if err != nil {
  68. panic("配置文件中操作人配置错误 " + err.Error())
  69. }
  70. }
  71. OpUserRealName = config["op_user_real_name"]
  72. }
  73. //日志配置
  74. {
  75. LogPath = config["log_path"]
  76. LogFile = config["log_file"]
  77. BinLogPath = config["binlog_path"]
  78. BinLogFile = config["binlog_file"]
  79. logMaxDaysStr := config["log_max_day"]
  80. LogMaxDays, _ = strconv.Atoi(logMaxDaysStr)
  81. }
  82. //涌益咨询文件夹配置
  83. {
  84. YongyiFilePath = config["yongyi_file_path"]
  85. YongyiOpen = config["yongyi_open"]
  86. }
  87. // 汾渭配置
  88. {
  89. FenweiOpen = config["fenwei_open"]
  90. FenweiFileDir = config["fenwei_file_dir"]
  91. FenweiOldFileDir = config["fenwei_old_file_dir"]
  92. FenweiTerminalCode = config["fenwei_terminal_code"]
  93. }
  94. TerminalCode = config["terminal_code"]
  95. }
  96. //修改接口文档
  97. //http://8.136.199.33:8300/swagger/