123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace app\controller;
- use app\service\ZdXzqService;
- use think\annotation\Route;
- use think\annotation\route\Middleware;
- use hg\apidoc\annotation as Apidoc;
- use app\BaseController;
- use think\facade\Cache;
- /**
- * @Apidoc\Title("行政区")
- * @Apidoc\Group("行政区")
- * @Apidoc\Sort (3)
- */
- class ZdXzq extends BaseController
- {
- protected $middleware = [
- 'jwt',
- ];
- use ResponseJson;
- /**
- * @Apidoc\Title("行政区代码,无限极分类")
- * @Apidoc\Tag("行政区")
- * @Apidoc\Method ("POST")
- * @Apidoc\Author ("ihavoc")
- * @Route("getXzqdm",method="POST")
- */
- public function getXzqdm(){
- $citydict = Cache::store("redis")->get("citydict");
- if ($citydict){
- return $this->JsonSucess($citydict);
- }else{
- $citydict =ZdXzqService::getXzq();
- Cache::store("redis")->set("citydict",$citydict);
- return $this->JsonSucess($citydict);
- }
- }
-
- /**
- * @Apidoc\Title("根据街道行政区代码获取所属区域")
- * @Apidoc\Tag("行政区")
- * @Apidoc\Method ("GET")
- * @Apidoc\Author ("ihavoc")
- * @Route("getXzqDetail",method="GET")
- */
- public function getXzqDetail(){
- $xzq = $this->request->get();
- $data["towns"]=ZdXzqService::getXzqDetail($xzq["xzqdm"]);
- $data["country"] = ZdXzqService::getXzqDetail(str_pad(substr($xzq["xzqdm"],0,6),9,'0'));
- $data["city"] = ZdXzqService::getXzqDetail(str_pad(substr($xzq["xzqdm"],0,4),9,'0'));
- return $this->JsonSucess($data);
- }
- }
|