dao.go 634 B

1234567891011121314151617181920212223242526272829303132
  1. package location
  2. import (
  3. "context"
  4. "go-common/app/interface/main/app-interface/conf"
  5. locmdl "go-common/app/service/main/location/model"
  6. locrpc "go-common/app/service/main/location/rpc/client"
  7. "go-common/library/log"
  8. )
  9. // Dao is location dao.
  10. type Dao struct {
  11. // rpc
  12. locRPC *locrpc.Service
  13. }
  14. // New new a location dao.
  15. func New(c *conf.Config) (d *Dao) {
  16. d = &Dao{
  17. // rpc
  18. locRPC: locrpc.New(c.LocationRPC),
  19. }
  20. return
  21. }
  22. func (d *Dao) Info(c context.Context, ipaddr string) (info *locmdl.Info, err error) {
  23. if info, err = d.locRPC.Info(c, &locmdl.ArgIP{IP: ipaddr}); err != nil {
  24. log.Error("%v", err)
  25. }
  26. return
  27. }