config.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. package config
  2. import (
  3. "app.yhyue.com/moapp/jybase/common"
  4. qrpc "app.yhyue.com/moapp/message/model"
  5. "github.com/gogf/gf/v2/frame/g"
  6. "github.com/gogf/gf/v2/os/gcfg"
  7. "github.com/gogf/gf/v2/os/gctx"
  8. )
  9. type config struct {
  10. Nsq struct {
  11. Address string
  12. }
  13. Redis struct {
  14. Address string
  15. }
  16. Mongodb struct {
  17. Address string
  18. Size int
  19. DbName string
  20. ReplSet string
  21. UserName string
  22. Password string
  23. }
  24. Etcd struct {
  25. Hosts []string
  26. Key string
  27. }
  28. DocPoints struct {
  29. AppId string
  30. Open struct {
  31. Max int64
  32. Jyweb_article_open int64
  33. Jydocs_doc_open int64
  34. }
  35. Jywx_subscribe_new int64
  36. Jywx_subscribe_invite int64
  37. Jywx_subscribe_invited int64
  38. }
  39. }
  40. var (
  41. PushConfig *pushConfig
  42. Wx *SysConfig
  43. )
  44. type pushConfig struct {
  45. Webdomain string `json:"webdomain"`
  46. Weixinrpc string `json:"weixinrpc"`
  47. PushPoolSize int `json:"pushPoolSize"`
  48. WxMsg struct {
  49. Id string
  50. First *qrpc.TmplItem
  51. Keyword1 *qrpc.TmplItem
  52. Keyword2 *qrpc.TmplItem
  53. Keyword3 *qrpc.TmplItem
  54. Keyword4 *qrpc.TmplItem
  55. Remark *qrpc.TmplItem
  56. } `json:"wxTplMsg"`
  57. TestId string `json:"testId"`
  58. DelayedTime int `json:"delayedTime"`
  59. Subvip string `json:"subvip"`
  60. Points string `json:"points"`
  61. }
  62. type SysConfig struct {
  63. WxJianyu struct {
  64. Appid string `json:"appid"`
  65. Appsecret string `json:"appsecret"`
  66. } `json:"wxJianyu"`
  67. Weixinrpc string `json:"weixinrpc"`
  68. PcSessionFlag bool `json:"pcSessionFlag"`
  69. SessionTimeout int64 `json:"sessionTimeout"`
  70. }
  71. //var Config *config
  72. func init() {
  73. //推送配置文件
  74. common.ReadConfig("./etc/push.json", &PushConfig)
  75. //系统配置文件
  76. //common.ReadConfig(&Config)
  77. g.Cfg().GetAdapter().(*gcfg.AdapterFile).SetFileName("./etc/config.yaml")
  78. var sysConfig SysConfig
  79. if err := gcfg.Instance().MustGet(gctx.New(), "wx").Scan(&sysConfig); err == nil {
  80. Wx = &SysConfig{
  81. WxJianyu: sysConfig.WxJianyu,
  82. Weixinrpc: sysConfig.Weixinrpc,
  83. PcSessionFlag: sysConfig.PcSessionFlag,
  84. SessionTimeout: sysConfig.SessionTimeout,
  85. }
  86. }
  87. }