config.go 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. package utils
  2. import (
  3. "fmt"
  4. beego "github.com/beego/beego/v2/adapter"
  5. "github.com/beego/beego/v2/server/web"
  6. )
  7. var (
  8. RunMode string //运行模式
  9. MYSQL_URL string //数据库连接
  10. MYSQL_URL_RDDP string //数据库连接
  11. MYSQL_URL_EDB string
  12. MYSQL_URL_DATA string
  13. MYSQL_URL_GL string
  14. MYSQL_URL_ETA string
  15. )
  16. var (
  17. LogPath string
  18. LogFile string
  19. BinLogPath string
  20. BinLogFile string
  21. )
  22. var SystemType string // 系统类型; hz:弘则;trial:试用平台;custom:客户
  23. var (
  24. APPNAME string //项目中文名称
  25. EmailSendToUsers string // 邮件提醒人员
  26. RefreshEdbInfoEmailSendToUsers string // 刷新完成通知邮件人员
  27. // AlarmMsgUrl 报警服务地址
  28. AlarmMsgUrl string
  29. )
  30. // 经济数据库
  31. var (
  32. EDB_LIB_URL string
  33. APP_EDB_LIB_NAME_EN string
  34. EDB_LIB_Md5_KEY string
  35. )
  36. // 公共数据服务接口参数
  37. var (
  38. APPID string
  39. SECRET string
  40. )
  41. var (
  42. WxAppId string
  43. WxAppSecret string
  44. TemplateId string
  45. RemindTemplateId string
  46. AppointmentRemindTemplateId string //活动预约通知模板id
  47. YbCommonTemplateId string //研报小程序消息模板ID
  48. SendWxTemplateEnable string //是否开启模版消息,1是发送,其他不发送
  49. WxYbAppId string //微信研报小程序
  50. //内部员工公众号(弘则部门)
  51. AdminWxAppId string
  52. AdminWxAppSecret string
  53. )
  54. // 模板消息推送
  55. var (
  56. SendWxTemplateMsgUrl string
  57. )
  58. // BusinessCode 商家编码
  59. var (
  60. BusinessCode string //商户号
  61. WindServerUrl string //wind api 接口服务器地址
  62. LtServerUrl string //路透 api 接口服务器地址
  63. PbServerUrl string //彭博 api 接口服务器地址
  64. )
  65. // ES配置
  66. var (
  67. ES_URL string // ES服务器地址
  68. ES_USERNAME string // ES账号
  69. ES_PASSWORD string // ES密码
  70. )
  71. var (
  72. EsReportIndexName string //研报ES索引
  73. EsEnglishReportIndexName string //英文研报ES索引
  74. )
  75. // 科大讯飞--语音合成
  76. var (
  77. XfHostUrl string
  78. )
  79. var (
  80. TemplateIdByProduct string //产品运行报告通知-模板ID
  81. )
  82. // 阿里云配置
  83. var (
  84. Bucketname string
  85. Endpoint string
  86. Imghost string
  87. UploadDir string
  88. Upload_Audio_Dir string
  89. AccessKeyId string
  90. AccessKeySecret string
  91. )
  92. func init() {
  93. tmpRunMode, err := web.AppConfig.String("run_mode")
  94. if err != nil {
  95. panic("配置文件读取run_mode错误 " + err.Error())
  96. }
  97. RunMode = tmpRunMode
  98. if RunMode == "" {
  99. localIp, err := GetLocalIP()
  100. fmt.Println("localIp:", localIp)
  101. if localIp == "10.0.0.123" {
  102. RunMode = "debug"
  103. } else {
  104. RunMode = "release"
  105. }
  106. //RunMode = "release"
  107. configPath := `/home/code/config/eta_task/conf/app.conf`
  108. err = web.LoadAppConfig("ini", configPath)
  109. if err != nil {
  110. fmt.Println("web.LoadAppConfig Err:" + err.Error())
  111. }
  112. }
  113. config, err := web.AppConfig.GetSection(RunMode)
  114. if err != nil {
  115. panic("配置文件读取错误 " + err.Error())
  116. }
  117. beego.Info(RunMode + " 模式")
  118. MYSQL_URL = config["mysql_url"]
  119. MYSQL_URL_RDDP = config["mysql_url_rddp"]
  120. MYSQL_URL_EDB = config["mysql_url_edb"]
  121. MYSQL_URL_DATA = config["mysql_url_data"]
  122. MYSQL_URL_GL = config["mysql_url_gl"]
  123. MYSQL_URL_ETA = config["mysql_url_eta"]
  124. // 系统类型
  125. systemType, err := web.AppConfig.String("system_type")
  126. if err != nil {
  127. panic(any("配置文件读取system_type错误 " + err.Error()))
  128. }
  129. SystemType = systemType
  130. // 项目中文名称
  131. appNameCn, err := web.AppConfig.String("app_name_cn")
  132. if err != nil {
  133. panic(any("配置文件读取app_name_cn错误 " + err.Error()))
  134. }
  135. APPNAME = appNameCn
  136. {
  137. LogPath = config["log_path"]
  138. LogFile = config["log_file"]
  139. BinLogPath = config["binlog_path"]
  140. BinLogFile = config["binlog_file"]
  141. }
  142. // 邮件提醒人员
  143. EmailSendToUsers = config["email_send_to_users"]
  144. // 刷新完成通知邮件人员
  145. RefreshEdbInfoEmailSendToUsers = config["refresh_edb_info_email_send_to_users"]
  146. // 报警服务地址
  147. AlarmMsgUrl = config["alarm_msg_url"]
  148. // 公共指标库相关
  149. {
  150. EDB_LIB_URL = config["edb_lib_url"]
  151. APP_EDB_LIB_NAME_EN = config["app_edb_lib_name_en"]
  152. EDB_LIB_Md5_KEY = config["edb_lib_md5_key"]
  153. }
  154. APPID = config["appid"]
  155. SECRET = config["secret"]
  156. // 商家编码
  157. BusinessCode = config["business_code"]
  158. //服务检测
  159. WindServerUrl = config["wind_server_url"]
  160. LtServerUrl = config["lt_server_url"]
  161. PbServerUrl = config["pb_server_url"]
  162. // ES配置
  163. {
  164. ES_URL = config["es_url"]
  165. ES_USERNAME = config["es_username"]
  166. ES_PASSWORD = config["es_password"]
  167. }
  168. // ES 索引
  169. {
  170. EsReportIndexName = config["es_report_index_name"]
  171. EsEnglishReportIndexName = config["es_english_report_index_name"]
  172. }
  173. // 科大讯飞
  174. {
  175. XfHostUrl = config["xf_host_url"]
  176. }
  177. // OSS相关
  178. {
  179. Endpoint = config["endpoint"]
  180. Bucketname = config["bucket_name"]
  181. Imghost = config["img_host"]
  182. UploadDir = config["upload_dir"]
  183. Upload_Audio_Dir = config["upload_audio_dir"]
  184. AccessKeyId = config["access_key_id"]
  185. AccessKeySecret = config["access_key_secret"]
  186. }
  187. // 微信模版消息
  188. {
  189. SendWxTemplateEnable = config["send_wx_template_enable"]
  190. }
  191. }