api.go 905 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package dao
  2. import (
  3. banned_api "go-common/app/service/live/banned_service/api/liverpc"
  4. fans_medal "go-common/app/service/live/fans_medal/api/liverpc"
  5. room_api "go-common/app/service/live/room/api/liverpc"
  6. "go-common/app/service/live/xuser/conf"
  7. "go-common/library/net/rpc/liverpc"
  8. )
  9. // Dao dao
  10. type Dao struct {
  11. c *conf.Config
  12. }
  13. // New init mysql db
  14. func New(c *conf.Config) (dao *Dao) {
  15. dao = &Dao{
  16. c: c,
  17. }
  18. return
  19. }
  20. // RoomAPI .
  21. var RoomAPI *room_api.Client
  22. // FansMedalAPI .
  23. var FansMedalAPI *fans_medal.Client
  24. // BannedAPI .
  25. var BannedAPI *banned_api.Client
  26. // InitAPI init all service APIs
  27. func InitAPI() {
  28. RoomAPI = room_api.New(getConf("room"))
  29. FansMedalAPI = fans_medal.New(getConf("fans_medal"))
  30. BannedAPI = banned_api.New(getConf("banned"))
  31. }
  32. func getConf(appName string) *liverpc.ClientConfig {
  33. c := conf.Conf.LiveRPC
  34. if c != nil {
  35. return c[appName]
  36. }
  37. return nil
  38. }