service.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package service
  2. import (
  3. "context"
  4. "go-common/app/admin/main/esports/conf"
  5. "go-common/app/admin/main/esports/dao"
  6. accclient "go-common/app/service/main/account/api"
  7. accwarden "go-common/app/service/main/account/api"
  8. arcclient "go-common/app/service/main/archive/api"
  9. )
  10. // Service biz service def.
  11. type Service struct {
  12. c *conf.Config
  13. dao *dao.Dao
  14. arcClient arcclient.ArchiveClient
  15. accClient accwarden.AccountClient
  16. }
  17. const (
  18. _notDeleted = 0
  19. _deleted = 1
  20. _online = 1
  21. _downLine = 0
  22. _statusOn = 0
  23. _statusAll = -1
  24. )
  25. // New new a Service and return.
  26. func New(c *conf.Config) (s *Service) {
  27. s = &Service{
  28. c: c,
  29. dao: dao.New(c),
  30. }
  31. var err error
  32. if s.arcClient, err = arcclient.NewClient(c.ArcClient); err != nil {
  33. panic(err)
  34. }
  35. if s.accClient, err = accclient.NewClient(c.AccClient); err != nil {
  36. panic(err)
  37. }
  38. return s
  39. }
  40. // Ping .
  41. func (s *Service) Ping(c context.Context) (err error) {
  42. return s.dao.Ping(c)
  43. }
  44. func unique(ids []int64) (outs []int64) {
  45. idMap := make(map[int64]int64, len(ids))
  46. for _, v := range ids {
  47. if _, ok := idMap[v]; ok {
  48. continue
  49. } else {
  50. idMap[v] = v
  51. }
  52. outs = append(outs, v)
  53. }
  54. return
  55. }