...
|
...
|
@@ -63,12 +63,48 @@ class SchoolController extends AdminBaseController{ |
|
|
return $this -> fetch();
|
|
|
|
|
|
}
|
|
|
public function getArea(){
|
|
|
$parent_id = $this->request->param('pid');
|
|
|
$where['name'] = ['like',"%$parent_id%"];
|
|
|
$where['pid'] = ['eq',0];
|
|
|
$data = Db::name('area')->where($where)->select();
|
|
|
$this->success('SUCCESS','',$data);
|
|
|
/**
|
|
|
* 获取城市
|
|
|
* @return string
|
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
* @throws \think\exception\DbException
|
|
|
*/
|
|
|
public function select_city(){
|
|
|
$province_name = $this->request->param('province_name');
|
|
|
if(!isset($province_name)){
|
|
|
$arr['code'] = 40005;
|
|
|
$arr['msg'] = '缺少必要参数';
|
|
|
}else{
|
|
|
$province = Db::name('area')->where(['name'=>$province_name,'level'=>1])->find();
|
|
|
$city = Db::name('area')->where(['pid'=>$province['id'],'level'=>2])->select();
|
|
|
$arr['code'] = 20000;
|
|
|
$arr['msg'] = 'SUCCESS';
|
|
|
$arr['data'] = $city;
|
|
|
}
|
|
|
return json_encode($arr);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取区/县
|
|
|
* @return string
|
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
* @throws \think\exception\DbException
|
|
|
*/
|
|
|
public function select_county(){
|
|
|
$city_name = $this->request->param('city_name');
|
|
|
if(!isset($city_name)){
|
|
|
$arr['code'] = 40005;
|
|
|
$arr['msg'] = '缺少必要参数';
|
|
|
}else{
|
|
|
$city = Db::name('area')->where(['name'=>$city_name,'level'=>2])->find();
|
|
|
$county = Db::name('area')->where(['pid'=>$city['id'],'level'=>3])->select();
|
|
|
$arr['code'] = 20000;
|
|
|
$arr['msg'] = 'SUCCESS';
|
|
|
$arr['data'] = $county;
|
|
|
}
|
|
|
return json_encode($arr);
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
|