dao.go 622 B

12345678910111213141516171819202122232425262728293031323334
  1. package ai
  2. import (
  3. "context"
  4. "go-common/app/interface/main/app-view/conf"
  5. bm "go-common/library/net/http/blademaster"
  6. "go-common/library/net/metadata"
  7. )
  8. const (
  9. _av2GameURL = "/avid2gameid"
  10. )
  11. type Dao struct {
  12. client *bm.Client
  13. av2GameURL string
  14. }
  15. func New(c *conf.Config) (d *Dao) {
  16. d = &Dao{
  17. client: bm.NewClient(c.HTTPGameAsync),
  18. av2GameURL: c.Host.AI + _av2GameURL,
  19. }
  20. return
  21. }
  22. func (d *Dao) Av2Game(c context.Context) (res map[int64]int64, err error) {
  23. ip := metadata.String(c, metadata.RemoteIP)
  24. if err = d.client.Get(c, d.av2GameURL, ip, nil, &res); err != nil {
  25. return
  26. }
  27. return
  28. }