Region.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 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\store\controller;
  13. use app\store\model\Region as RegionModel;
  14. /**
  15. * 地区管理
  16. * Class Region
  17. * @package app\store\controller
  18. */
  19. class Region extends Controller
  20. {
  21. /**
  22. * 获取所有地区
  23. * @return array
  24. * @throws \think\db\exception\DataNotFoundException
  25. * @throws \think\db\exception\DbException
  26. * @throws \think\db\exception\ModelNotFoundException
  27. */
  28. public function all()
  29. {
  30. $list = RegionModel::getCacheAll();
  31. return $this->renderSuccess(compact('list'));
  32. }
  33. /**
  34. * 获取所有地区(树状)
  35. * @return array
  36. * @throws \think\db\exception\DataNotFoundException
  37. * @throws \think\db\exception\DbException
  38. * @throws \think\db\exception\ModelNotFoundException
  39. */
  40. public function tree()
  41. {
  42. $list = RegionModel::getCacheTree();
  43. return $this->renderSuccess(compact('list'));
  44. }
  45. }