Area.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Niucloud-admin 企业快速开发的saas管理平台
  4. // +----------------------------------------------------------------------
  5. // | 官方网址:https://www.niucloud.com
  6. // +----------------------------------------------------------------------
  7. // | niucloud团队 版权所有 开源版本可自由商用
  8. // +----------------------------------------------------------------------
  9. // | Author: Niucloud Team
  10. // +----------------------------------------------------------------------
  11. namespace app\adminapi\controller\sys;
  12. use app\service\admin\sys\AreaService;
  13. use core\base\BaseAdminController;
  14. use think\Response;
  15. class Area extends BaseAdminController
  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. * @return Response
  37. */
  38. public function addressInfo()
  39. {
  40. $data = $this->request->params([
  41. ['address', ''],
  42. ]);
  43. return success((new AreaService())->getAddress($data['address']));
  44. }
  45. /**
  46. * @return Response
  47. */
  48. public function contraryAddress()
  49. {
  50. $data = $this->request->params([
  51. ['location', ''],
  52. ]);
  53. return success((new AreaService())->getAddressInfo($data['location']));
  54. }
  55. /**
  56. * @return Response
  57. */
  58. public function areaByAreaCode(string $code) {
  59. return success((new AreaService())->getAreaByAreaCode($code));
  60. }
  61. }