district.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package base
  2. import (
  3. "context"
  4. "dashoo.cn/common_definition/comm_def"
  5. "github.com/gogf/gf/frame/g"
  6. server "dashoo.cn/micro/app/service/base"
  7. )
  8. type DistrictHandler struct{}
  9. //GetList 所属区域列表
  10. func (d *DistrictHandler) GetList(ctx context.Context, req *comm_def.IdReq, rsp *comm_def.CommonMsg) error {
  11. districtServer, err := server.NewDistrictService(ctx)
  12. if err != nil {
  13. g.Log().Error(err)
  14. return err
  15. }
  16. //list := districtServer.ListToRegions()
  17. list := districtServer.ListToTree(req.Id)
  18. g.Log().Info("ID", req.Id)
  19. rsp.Data = g.Map{"list": list}
  20. return nil
  21. }
  22. //区域下所有的省份
  23. func (d *DistrictHandler) GetRegionList(ctx context.Context, req *comm_def.IdReq, rsp *comm_def.CommonMsg) error {
  24. districtServer, err := server.NewDistrictService(ctx)
  25. if err != nil {
  26. g.Log().Error(err)
  27. return err
  28. }
  29. list := districtServer.ListToRegions()
  30. //list := districtServer.ListToTree(req.Id)
  31. g.Log().Info("ID", req.Id)
  32. rsp.Data = g.Map{"list": list}
  33. return nil
  34. }
  35. //返回所有省份的
  36. func (d *DistrictHandler) GetProvinceInfo(ctx context.Context, null, rsp *comm_def.CommonMsg) error {
  37. districtServer, err := server.NewDistrictService(ctx)
  38. if err != nil {
  39. g.Log().Error(err)
  40. return err
  41. }
  42. list := districtServer.GetProvinceInfo()
  43. rsp.Data = g.Map{"list": list}
  44. return nil
  45. }