field('province_code,province_name')->select()->toArray(); return $this->success('请求成功',$data); }catch (\Exception $e) { return $this->fail($e->getMessage()); } } /** * 获取某个省份下的城市 * @params province_code 省份编码 * @return Response */ public function city(): Response { $province_code = $this->request->get('province_code'); if(empty($province_code)){ return $this->fail('参数错误'); } try { $data = Db::name('geo_city')->field('city_code,city_name')->where('province_code',$province_code)->select()->toArray(); return $this->success('请求成功',$data); }catch (\Exception $e) { return $this->fail($e->getMessage()); } } /** * 获取某个城市下面的区县 * @params city_code 城市编码 * @return Response */ public function area(): Response { $city_code = $this->request->get('city_code'); if(empty($city_code)){ return $this->fail('参数错误'); } try { $data = Db::name('geo_area')->field('area_code,area_name')->where('city_code',$city_code)->select()->toArray(); return $this->success('请求成功',$data); }catch (\Exception $e) { return $this->fail($e->getMessage()); } } /** * 获取某个区县下面的镇街 * @params area_code 城市编码 * @return Response */ public function street(): Response { $area_code = $this->request->get('area_code'); if(empty($area_code)){ return $this->fail('参数错误'); } try { $data = Db::name('geo_street')->field('street_code,street_name')->where('area_code',$area_code)->select()->toArray(); return $this->success('请求成功',$data); }catch (\Exception $e) { return $this->fail($e->getMessage()); } } /** * 获取某个镇街下面的村社 * @params street_code 镇街编码 * @return Response */ public function village(): Response { $street_code = $this->request->get('street_code'); if(empty($street_code)){ return $this->fail('参数错误'); } try { $data = Db::name('geo_village')->field('village_code,village_name')->where('street_code',$street_code)->select()->toArray(); return $this->success('请求成功',$data); }catch (\Exception $e) { return $this->fail($e->getMessage()); } } }