config.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. }
  60. type SysConfig struct {
  61. WxJianyu struct {
  62. Appid string `json:"appid"`
  63. Appsecret string `json:"appsecret"`
  64. } `json:"wxJianyu"`
  65. Weixinrpc string `json:"weixinrpc"`
  66. PcSessionFlag bool `json:"pcSessionFlag"`
  67. SessionTimeout int64 `json:"sessionTimeout"`
  68. }
  69. //var Config *config
  70. func init() {
  71. //推送配置文件
  72. common.ReadConfig("./etc/push.json", &PushConfig)
  73. //系统配置文件
  74. //common.ReadConfig(&Config)
  75. g.Cfg().GetAdapter().(*gcfg.AdapterFile).SetFileName("./etc/config.yaml")
  76. var sysConfig SysConfig
  77. if err := gcfg.Instance().MustGet(gctx.New(), "wx").Scan(&sysConfig); err == nil {
  78. Wx = &SysConfig{
  79. WxJianyu: sysConfig.WxJianyu,
  80. Weixinrpc: sysConfig.Weixinrpc,
  81. PcSessionFlag: sysConfig.PcSessionFlag,
  82. SessionTimeout: sysConfig.SessionTimeout,
  83. }
  84. }
  85. }