config.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. CoalMineFilePath string //excel文件地址
  41. CoalMineOpen string //是否配置中国煤炭网数据源,1已配置
  42. CoalMailAttachmentScriptPath string // 获取邮件附件的脚本目录
  43. CoalMailAttachmentOpen string // 获取邮件附件功能,1已配置
  44. CoalMailAttachmentTime string // 获取邮件附件功能时间
  45. CoalMailAttachmentPythonVersion string // 获取邮件附件功能python版本
  46. )
  47. )
  48. // 汾渭煤炭
  49. var (
  50. FenweiFileDir string // excel文件目录
  51. FenweiOldFileDir string // 已读取过的excel文件目录
  52. FenweiOpen string // 是否配置汾渭数据源
  53. )
  54. // 煤炭江湖
  55. var (
  56. MtjhFilePath string //excel文件地址
  57. MtjhOpen string //是否配置煤炭江湖数据源,1已配置
  58. )
  59. var TerminalCode string
  60. func init() {
  61. tmpRunMode, err := web.AppConfig.String("run_mode")
  62. if err != nil {
  63. panic("配置文件读取run_mode错误 " + err.Error())
  64. }
  65. RunMode = tmpRunMode
  66. fmt.Println("RunMode:", RunMode)
  67. config, err := web.AppConfig.GetSection(RunMode)
  68. if err != nil {
  69. panic("配置文件读取错误 " + err.Error())
  70. }
  71. beeLogger.Log.Info(RunMode + " 模式")
  72. // 公共api内部服务调用
  73. {
  74. // 公共指标库相关
  75. EDB_LIB_URL = config["edb_lib_url"]
  76. APP_EDB_LIB_NAME_EN = config["app_edb_lib_name_en"]
  77. EDB_LIB_Md5_KEY = config["edb_lib_md5_key"]
  78. opUserIdStr := config["op_user_id"]
  79. if opUserIdStr != `` {
  80. OpUserId, err = strconv.Atoi(opUserIdStr)
  81. if err != nil {
  82. panic("配置文件中操作人配置错误 " + err.Error())
  83. }
  84. }
  85. OpUserRealName = config["op_user_real_name"]
  86. }
  87. //日志配置
  88. {
  89. LogPath = config["log_path"]
  90. LogFile = config["log_file"]
  91. BinLogPath = config["binlog_path"]
  92. BinLogFile = config["binlog_file"]
  93. logMaxDaysStr := config["log_max_day"]
  94. LogMaxDays, _ = strconv.Atoi(logMaxDaysStr)
  95. }
  96. //涌益咨询文件夹配置
  97. {
  98. YongyiFilePath = config["yongyi_file_path"]
  99. YongyiOpen = config["yongyi_open"]
  100. }
  101. //中国煤炭网文件夹配置
  102. {
  103. CoalMineFilePath = config["coal_mine_file_path"]
  104. CoalMineOpen = config["coal_mine_open"]
  105. CoalMailAttachmentScriptPath = config["coal_mail_attachment_script_path"]
  106. CoalMailAttachmentOpen = config["coal_mail_attachment_open"]
  107. CoalMailAttachmentTime = config["coal_mail_attachment_time"]
  108. CoalMailAttachmentPythonVersion = config["coal_mail_attachment_python_version"]
  109. }
  110. // 汾渭配置
  111. {
  112. FenweiOpen = config["fenwei_open"]
  113. FenweiFileDir = config["fenwei_file_dir"]
  114. FenweiOldFileDir = config["fenwei_old_file_dir"]
  115. }
  116. //煤炭江湖文件夹配置
  117. {
  118. MtjhFilePath = config["mtjh_file_path"]
  119. MtjhOpen = config["mtjh_open"]
  120. }
  121. TerminalCode = config["terminal_code"]
  122. }
  123. //修改接口文档
  124. //http://8.136.199.33:8300/swagger/