config.go 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. package utils
  2. import (
  3. "fmt"
  4. beego "github.com/beego/beego/v2/adapter"
  5. "github.com/beego/beego/v2/server/web"
  6. "github.com/rdlucklib/rdluck_tools/cache"
  7. )
  8. var (
  9. RunMode string //运行模式
  10. MYSQL_URL string //数据库连接
  11. MYSQL_URL_RDDP string //数据库连接
  12. MYSQL_URL_EDB string
  13. MYSQL_URL_DATA string
  14. MYSQL_URL_GL string
  15. MYSQL_URL_WEEKLY_TRIAL string // ETA试用
  16. MYSQL_URL_ETA string
  17. REDIS_CACHE string //缓存地址
  18. Rc *cache.Cache //redis缓存
  19. Re error //redis错误
  20. )
  21. var (
  22. CompanyId int
  23. AdminId int
  24. RealName string
  25. )
  26. var (
  27. WxAppId string
  28. WxAppSecret string
  29. TemplateId string
  30. RemindTemplateId string
  31. AppointmentRemindTemplateId string //活动预约通知模板id
  32. YbCommonTemplateId string //研报小程序消息模板ID
  33. WxYbAppId string //微信研报小程序
  34. //内部员工公众号(弘则部门)
  35. AdminWxAppId string
  36. AdminWxAppSecret string
  37. TemplateIdByProduct string //产品运行报告通知-模板ID
  38. )
  39. // oss配置
  40. /*var (
  41. Bucketname string = "hongze"
  42. Endpoint string
  43. Imghost string = "https://hongze.oss-accelerate.aliyuncs.com/"
  44. Upload_dir string = "static/images/"
  45. Upload_Audio_Dir string = "static/audio/"
  46. AccessKeyId string = "LTAIFMZYQhS2BTvW"
  47. AccessKeySecret string = "12kk1ptCHoGWedhBnKRVW5hRJzq9Fq"
  48. )*/
  49. // 阿里云配置
  50. var (
  51. Bucketname string
  52. Endpoint string
  53. Imghost string
  54. UploadDir string
  55. Upload_Audio_Dir string
  56. AccessKeyId string
  57. AccessKeySecret string
  58. )
  59. // ES配置
  60. var (
  61. ES_URL string // ES服务器地址
  62. ES_USERNAME string // ES账号
  63. ES_PASSWORD string // ES密码
  64. )
  65. var (
  66. EsReportIndexName string //研报ES索引
  67. EsEnglishReportIndexName string //英文研报ES索引
  68. )
  69. var (
  70. THS_SendUrl string //同花顺地址url
  71. THS_SyncWxGroupUrl string //同花顺同步微信群url
  72. THS_List_Url string // 同花顺报告列表地址url
  73. THS_PubKey string //同花顺公钥
  74. )
  75. // 经济数据库
  76. var (
  77. EDB_LIB_URL string
  78. )
  79. // 进门财经账号信息
  80. var (
  81. COMEIN_URL string
  82. COMEIN_APPID string
  83. COMEIN_SECREKEY string
  84. )
  85. // 模板消息推送
  86. var (
  87. SendWxTemplateMsgUrl string
  88. )
  89. // 科大讯飞--语音合成
  90. var (
  91. XfHostUrl string
  92. )
  93. func init() {
  94. tmpRunMode, err := web.AppConfig.String("run_mode")
  95. if err != nil {
  96. panic("配置文件读取run_mode错误 " + err.Error())
  97. }
  98. RunMode = tmpRunMode
  99. if RunMode == "" {
  100. localIp, err := GetLocalIP()
  101. fmt.Println("localIp:", localIp)
  102. if localIp == "10.0.0.123" {
  103. RunMode = "debug"
  104. } else {
  105. RunMode = "release"
  106. }
  107. //RunMode = "release"
  108. configPath := `/home/code/config/hongze_task/conf/app.conf`
  109. err = web.LoadAppConfig("ini", configPath)
  110. if err != nil {
  111. fmt.Println("web.LoadAppConfig Err:" + err.Error())
  112. }
  113. }
  114. config, err := web.AppConfig.GetSection(RunMode)
  115. if err != nil {
  116. panic("配置文件读取错误 " + err.Error())
  117. }
  118. beego.Info(RunMode + " 模式")
  119. MYSQL_URL = config["mysql_url"]
  120. MYSQL_URL_RDDP = config["mysql_url_rddp"]
  121. MYSQL_URL_EDB = config["mysql_url_edb"]
  122. MYSQL_URL_DATA = config["mysql_url_data"]
  123. MYSQL_URL_GL = config["mysql_url_gl"]
  124. MYSQL_URL_WEEKLY_TRIAL = config["mysql_url_weekly_trial"]
  125. MYSQL_URL_ETA = config["mysql_url_eta"]
  126. REDIS_CACHE = config["beego_cache"]
  127. if len(REDIS_CACHE) <= 0 {
  128. panic("redis链接参数没有配置")
  129. }
  130. Rc, Re = cache.NewCache(REDIS_CACHE) //初始化缓存
  131. if Re != nil {
  132. fmt.Println(Re)
  133. panic(Re)
  134. }
  135. //同花顺公钥
  136. THS_PubKey = `-----BEGIN PUBLIC KEY-----
  137. MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqugglfCboOEfWtHlGBOW
  138. 40a4Y3xOs0MPBwjTOzHgcaWzx5XCc20VftGVXkWlpjs8u4dza/Bp1SV7SJ5Y7U95
  139. jgUOP8Js9Qgp6UVqBJDJf3i1KpjHzlk3ma8zxAYUAdieEUE+SKSxSY+BD9A6lpf5
  140. n+igXLmzR5GeVGFeLzoMhB1+pXgGhW30ao9wPwuRF7DBl+FKa/ACi7iXLiwXVgqT
  141. FFi29TKeerEENu3EpMXvPml7tNUiVmVW6d83hlascfbAlkShwuHLSGpLqK7brtg6
  142. jRS9hreKFKb0BUQ4TB26e7IDCstbMRvUp4+OGezexzic5NYPQ8uLo5OTaS7f7PrW
  143. ZwIDAQAB
  144. -----END PUBLIC KEY-----`
  145. WxYbAppId = "wxb059c872d79b9967" //弘则研报小程序
  146. //内部员工公众号(弘则部门)
  147. AdminWxAppId = "wx1392111da5426e9e"
  148. AdminWxAppSecret = "30eceb7cf29bf2f046031155ab55d7b4"
  149. if RunMode == "release" {
  150. CompanyId = 16
  151. RealName = "超级管理员"
  152. WxAppId = "wx4a844c734d8c8e56"
  153. WxAppSecret = "26c586e7ccb3c575433f0f37797b3eeb"
  154. TemplateId = "DGvLwidav-OZc07klLv5mxwxO63qHdWS5Cj-rTDvTQo"
  155. RemindTemplateId = "rCvkgRatnK_3N9pnQEErUyjFkyVpyAGuYtv3HwY82K4"
  156. AppointmentRemindTemplateId = `pdbn6Wr84Rr-Ek7zrYHcxh5RO5ROILHjbkj3em68954` //活动预约通知模板id
  157. //同花顺正式地址
  158. THS_SendUrl = `https://board.10jqka.com.cn/gateway/ps/syncNews`
  159. THS_SyncWxGroupUrl = `https://board.10jqka.com.cn/gateway/ps/syncWechatGroupInfo`
  160. THS_List_Url = `https://board.10jqka.com.cn/gateway/ps/syncNews/listPage`
  161. //同花顺,万得接口服务地址(阿里云windows服务器地址;内网地址)
  162. Hz_Server_Data_Url = "http://172.19.173.231:7000/"
  163. EDB_LIB_URL = "http://172.19.173.232:8300/edbapi/"
  164. //EDB_LIB_URL = "http://47.102.213.75:8300/edbapi/"
  165. SendWxTemplateMsgUrl = "http://127.0.0.1:8086/v1/wechat/send_template_msg"
  166. YbCommonTemplateId = "dYg6iHooRq74PyCXmw_Ns7qdJZmbtLoKS2p2FKeaXl0"
  167. } else {
  168. CompanyId = 16
  169. RealName = "超级管理员"
  170. AdminId = 11
  171. WxAppId = "wx9b5d7291e581233a"
  172. WxAppSecret = "f4d52e34021eee262dce9682b31f8861"
  173. TemplateId = "DGvLwidav-OZc07klLv5mxwxO63qHdWS5Cj-rTDvTQo"
  174. RemindTemplateId = "rCvkgRatnK_3N9pnQEErUyjFkyVpyAGuYtv3HwY82K4"
  175. AppointmentRemindTemplateId = `U3su--7d6xsCDcP6Tya0N0wWpKn_uI0zO1cutRK52cc` //活动预约通知模板id
  176. //同花顺测试地址
  177. THS_SendUrl = `https://mtest.10jqka.com.cn/gateway/ps/syncNews`
  178. THS_SyncWxGroupUrl = `https://mtest.10jqka.com.cn/gateway/ps/syncWechatGroupInfo`
  179. THS_List_Url = `https://mtest.10jqka.com.cn/gateway/ps/syncNews/listPage`
  180. //同花顺,万得接口服务地址(阿里云windows服务器地址;外网地址)
  181. Hz_Server_Data_Url = "http://139.196.136.213:7000/"
  182. EDB_LIB_URL = "http://8.136.199.33:8300/edbapi/"
  183. SendWxTemplateMsgUrl = "http://127.0.0.1:8086/v1/wechat/send_template_msg"
  184. YbCommonTemplateId = "CB7bOl7f3viMG4s1uhRo7WM0Jbx3WvodKuIZ8A_z8fM"
  185. }
  186. // 微信模版消息
  187. {
  188. TemplateIdByProduct = config["template_id_by_product"]
  189. }
  190. // oss
  191. {
  192. Endpoint = config["endpoint"]
  193. }
  194. // ES配置
  195. {
  196. ES_URL = config["es_url"]
  197. ES_USERNAME = config["es_username"]
  198. ES_PASSWORD = config["es_password"]
  199. }
  200. // ES 索引
  201. {
  202. EsReportIndexName = config["es_report_index_name"]
  203. EsEnglishReportIndexName = config["es_english_report_index_name"]
  204. }
  205. // 科大讯飞
  206. {
  207. XfHostUrl = config["xf_host_url"]
  208. }
  209. // OSS相关
  210. {
  211. Endpoint = config["endpoint"]
  212. Bucketname = config["bucket_name"]
  213. Imghost = config["img_host"]
  214. UploadDir = config["upload_dir"]
  215. Upload_Audio_Dir = config["upload_audio_dir"]
  216. AccessKeyId = config["access_key_id"]
  217. AccessKeySecret = config["access_key_secret"]
  218. }
  219. // 进门财经开放api配置
  220. ComeinOpenApiConfig()
  221. }
  222. // ComeinOpenApiConfig 进门开放api配置
  223. func ComeinOpenApiConfig() {
  224. if RunMode == "release" {
  225. COMEIN_URL = "https://server.comein.cn/comein/index.php"
  226. COMEIN_APPID = "39b48779-debd-446a-a303-900322d8e356"
  227. COMEIN_SECREKEY = "9102a767f20f11ecb5d6b8599f142ed4"
  228. } else {
  229. COMEIN_URL = "https://testserver.comein.cn/comein/index.php"
  230. COMEIN_APPID = "7b966708-4a8b-4d24-9066-fe29920e7eee"
  231. COMEIN_SECREKEY = "76e004876fae4b3c8721a3f4c2d115da"
  232. }
  233. }
  234. //http://entryapi.brilliantstart.cn
  235. //http://entryapi.brilliantstart.cn/swagger/