service.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package member
  2. import (
  3. "context"
  4. "net"
  5. "go-common/app/interface/main/account/conf"
  6. "go-common/app/interface/main/account/dao/account"
  7. "go-common/app/interface/main/account/dao/passport"
  8. "go-common/app/interface/main/account/dao/reply"
  9. artRPC "go-common/app/interface/openplatform/article/rpc/client"
  10. accrpc "go-common/app/service/main/account/rpc/client"
  11. arcRPC "go-common/app/service/main/archive/api/gorpc"
  12. coinrpc "go-common/app/service/main/coin/api/gorpc"
  13. filterrpc "go-common/app/service/main/filter/rpc/client"
  14. locrpc "go-common/app/service/main/location/rpc/client"
  15. memrpc "go-common/app/service/main/member/api/gorpc"
  16. passRPC "go-common/app/service/main/passport/rpc/client"
  17. securerpc "go-common/app/service/main/secure/rpc/client"
  18. upRPC "go-common/app/service/main/up/api/gorpc"
  19. usrpc "go-common/app/service/main/usersuit/rpc/client"
  20. "go-common/library/queue/databus"
  21. "github.com/pkg/errors"
  22. )
  23. // Service struct of service.
  24. type Service struct {
  25. // conf
  26. c *conf.Config
  27. accRPC *accrpc.Service3
  28. memRPC *memrpc.Service
  29. usRPC *usrpc.Service2
  30. arcRPC *arcRPC.Service2
  31. upRPC *upRPC.Service
  32. artRPC *artRPC.Service
  33. passRPC *passRPC.Client2
  34. coinRPC *coinrpc.Service
  35. locRPC *locrpc.Service
  36. secureRPC *securerpc.Service
  37. filterRPC *filterrpc.Service
  38. accDao *account.Dao
  39. replyDao *reply.Dao
  40. passDao *passport.Dao
  41. nickFreeAppKeys map[string]string
  42. accountNotify *databus.Databus
  43. removeLoginLogCIDR []*net.IPNet
  44. }
  45. // New create service instance and return.
  46. func New(c *conf.Config) (s *Service) {
  47. s = &Service{
  48. c: c,
  49. memRPC: memrpc.New(c.RPCClient2.Member),
  50. accRPC: accrpc.New3(c.RPCClient2.Account),
  51. usRPC: usrpc.New(c.RPCClient2.Usersuit),
  52. arcRPC: arcRPC.New2(c.RPCClient2.Archive),
  53. upRPC: upRPC.New(c.RPCClient2.UP),
  54. artRPC: artRPC.New(c.RPCClient2.Article),
  55. passRPC: passRPC.New(c.RPCClient2.PassPort),
  56. coinRPC: coinrpc.New(c.RPCClient2.Coin),
  57. locRPC: locrpc.New(c.RPCClient2.Location),
  58. secureRPC: securerpc.New(c.RPCClient2.Secure),
  59. filterRPC: filterrpc.New(c.RPCClient2.Filter),
  60. accDao: account.New(c),
  61. passDao: passport.New(c),
  62. replyDao: reply.New(c),
  63. nickFreeAppKeys: c.NickFreeAppKeys,
  64. accountNotify: databus.New(c.AccountNotify),
  65. }
  66. cidrs := make([]*net.IPNet, 0, len(c.Account.RemoveLoginLogCIDR))
  67. for _, raw := range c.Account.RemoveLoginLogCIDR {
  68. _, inet, err := net.ParseCIDR(raw)
  69. if err != nil {
  70. panic(errors.Wrapf(err, "Invalid CIDR: %s", raw))
  71. }
  72. cidrs = append(cidrs, inet)
  73. }
  74. s.removeLoginLogCIDR = cidrs
  75. return
  76. }
  77. // Ping check server ok.
  78. func (s *Service) Ping(c context.Context) (err error) {
  79. return
  80. }
  81. // Close dao.
  82. func (s *Service) Close() {}