ZdXzq.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace app\controller;
  3. use app\service\ZdXzqService;
  4. use think\annotation\Route;
  5. use think\annotation\route\Middleware;
  6. use hg\apidoc\annotation as Apidoc;
  7. use app\BaseController;
  8. use think\facade\Cache;
  9. /**
  10. * @Apidoc\Title("行政区")
  11. * @Apidoc\Group("行政区")
  12. * @Apidoc\Sort (3)
  13. */
  14. class ZdXzq extends BaseController
  15. {
  16. protected $middleware = [
  17. 'jwt',
  18. ];
  19. use ResponseJson;
  20. /**
  21. * @Apidoc\Title("行政区代码,无限极分类")
  22. * @Apidoc\Tag("行政区")
  23. * @Apidoc\Method ("POST")
  24. * @Apidoc\Author ("ihavoc")
  25. * @Route("getXzqdm",method="POST")
  26. */
  27. public function getXzqdm(){
  28. $citydict = Cache::store("redis")->get("citydict");
  29. if ($citydict){
  30. return $this->JsonSucess($citydict);
  31. }else{
  32. $citydict =ZdXzqService::getXzq();
  33. Cache::store("redis")->set("citydict",$citydict);
  34. return $this->JsonSucess($citydict);
  35. }
  36. }
  37. /**
  38. * @Apidoc\Title("根据街道行政区代码获取所属区域")
  39. * @Apidoc\Tag("行政区")
  40. * @Apidoc\Method ("GET")
  41. * @Apidoc\Author ("ihavoc")
  42. * @Route("getXzqDetail",method="GET")
  43. */
  44. public function getXzqDetail(){
  45. $xzq = $this->request->get();
  46. $data["towns"]=ZdXzqService::getXzqDetail($xzq["xzqdm"]);
  47. $data["country"] = ZdXzqService::getXzqDetail(str_pad(substr($xzq["xzqdm"],0,6),9,'0'));
  48. $data["city"] = ZdXzqService::getXzqDetail(str_pad(substr($xzq["xzqdm"],0,4),9,'0'));
  49. return $this->JsonSucess($data);
  50. }
  51. }