Region.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2024 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types=1);
  12. namespace app\api\controller;
  13. use app\api\model\Region as RegionModel;
  14. use think\response\Json;
  15. /**
  16. * 地区管理
  17. * Class Region
  18. * @package app\api\controller
  19. */
  20. class Region extends Controller
  21. {
  22. /**
  23. * 获取所有地区
  24. * @return Json
  25. * @throws \think\db\exception\DataNotFoundException
  26. * @throws \think\db\exception\DbException
  27. * @throws \think\db\exception\ModelNotFoundException
  28. */
  29. public function all(): Json
  30. {
  31. $list = RegionModel::getCacheAll();
  32. return $this->renderSuccess(compact('list'));
  33. }
  34. /**
  35. * 获取所有地区(树状)
  36. * @return Json
  37. * @throws \think\db\exception\DataNotFoundException
  38. * @throws \think\db\exception\DbException
  39. * @throws \think\db\exception\ModelNotFoundException
  40. */
  41. public function tree(): Json
  42. {
  43. $list = RegionModel::getCacheTree();
  44. return $this->renderSuccess(compact('list'));
  45. }
  46. }