Area.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Niucloud-admin 企业快速开发的多应用管理平台
  4. // +----------------------------------------------------------------------
  5. // | 官方网址:https://www.niucloud.com
  6. // +----------------------------------------------------------------------
  7. // | niucloud团队 版权所有 开源版本可自由商用
  8. // +----------------------------------------------------------------------
  9. // | Author: Niucloud Team
  10. // +----------------------------------------------------------------------
  11. namespace app\api\controller\sys;
  12. use app\service\api\sys\AreaService;
  13. use core\base\BaseApiController;
  14. use think\Response;
  15. class Area extends BaseApiController
  16. {
  17. /**
  18. * 拖过pid获取子项列表
  19. * @param int $pid
  20. * @return Response
  21. */
  22. public function listByPid(int $pid)
  23. {
  24. return success((new AreaService())->getListByPid($pid));
  25. }
  26. /**
  27. * 获取层级列表
  28. * @param int $level
  29. * @return Response
  30. */
  31. public function tree(int $level)
  32. {
  33. return success((new AreaService())->getAreaTree($level));
  34. }
  35. /**
  36. *
  37. * @return void
  38. */
  39. /**
  40. * 通过编码查询地址信息
  41. */
  42. public function areaByAreaCode(string $code) {
  43. return success((new AreaService())->getAreaByAreaCode($code));
  44. }
  45. /**
  46. * 通过经纬度查询地址
  47. * @param int $level
  48. * @return Response
  49. */
  50. public function getAddressByLatlng()
  51. {
  52. $data = $this->request->params([
  53. ['latlng', '']
  54. ]);
  55. return success((new AreaService())->getAddressByLatlng($data));
  56. }
  57. }