config.go 8.3 KB

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