Commit a0400d49 by 庄欣

city

parent 51754a11
......@@ -42,4 +42,6 @@ class Category extends ControllerBase
}
}
}
\ No newline at end of file
......@@ -3,10 +3,45 @@
namespace App\Http\Controllers\City\Controller;
use App\Http\Controllers\ControllerBase;
use App\Lib\Response\Response;
class City extends ControllerBase
{
protected $prefix = "city";
public function getParent($id)
{
$client = app("client");
try {
$res = $client->get($this->prefix."/$id/parent");
return Response::success($res);
} catch (\Exception $e) {
return Response::error($e->getMessage());
}
}
public function index($query = "", $checkUid = true)
{
return parent::index($query, false);
}
public function china()
{
$query = $this->combine(['name'=>'中国']);
return parent::index($query,false);
}
public function show($id, $query = "", $checkUid = true)
{
return parent::show($id, $query, false);
}
protected function after_hook($res)
{
if(!empty($res)) {
return $res[0];
}
return $res;
}
}
\ No newline at end of file
......@@ -129,4 +129,10 @@ Route::group(["prefix" => "category", 'namespace' => Provider::getNamespace("cat
Route::group(["prefix" => "city", 'namespace' => Provider::getNamespace("city")],function() {
//列表
Route::get("/", "City@index");
//上一级信息
Route::get("/{id}/parent","City@getParent");
//获取详细信息
Route::get("/{id}","City@show")->where(['id'=>'\d+']);
//获取中国的ID
Route::get("/china","City@china");
});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment