124 lines
2.9 KiB
PHP
Executable File
124 lines
2.9 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* @createtime 2023/5/20
|
|
* @author wild
|
|
* @copyright PhpStorm
|
|
*/
|
|
|
|
|
|
namespace App\Http\Controllers\Api\Seller;
|
|
|
|
|
|
use App\Model\ProvinceCityArea;
|
|
use Illuminate\Http\Request;
|
|
|
|
class AreaController extends BaseController
|
|
{
|
|
/**
|
|
* @api {POST} /api/seller/area/tree 地区-省市县
|
|
* @apiVersion 0.1.0
|
|
* @apiGroup 店主
|
|
*
|
|
* @apiSuccessExample {json} 返回结果
|
|
* {
|
|
* "code":200,
|
|
* "message":"",
|
|
* "data":[
|
|
* {
|
|
* "id":1,
|
|
* "name":"北京",
|
|
* "parent_id":"0",
|
|
* "type":"province"
|
|
* },
|
|
* ]
|
|
* }
|
|
*/
|
|
public function tree(Request $request)
|
|
{
|
|
$trees = ProvinceCityArea::toTree();
|
|
return $this->jsonSuccess($trees);
|
|
}
|
|
|
|
/**
|
|
* @api {POST} /api/seller/area/province 地区-省
|
|
* @apiVersion 0.1.0
|
|
* @apiGroup 店主
|
|
*
|
|
* @apiSuccessExample {json} 返回结果
|
|
* {
|
|
* "code":200,
|
|
* "message":"",
|
|
* "data":[
|
|
* {
|
|
* "id":1,
|
|
* "name":"北京",
|
|
* "parent_id":"0",
|
|
* "type":"province"
|
|
* },
|
|
* ]
|
|
* }
|
|
*/
|
|
public function province(Request $request)
|
|
{
|
|
$province = ProvinceCityArea::where('parent_id', 0)->get();
|
|
return $this->jsonSuccess($province);
|
|
}
|
|
|
|
/**
|
|
* @api {POST} /api/seller/area/city 地区-市
|
|
* @apiVersion 0.1.0
|
|
* @apiGroup 店主
|
|
*
|
|
* @apiParam {String} parent_id 省级id
|
|
*
|
|
* @apiSuccessExample {json} 返回结果
|
|
* {
|
|
* "code":200,
|
|
* "message":"",
|
|
* "data":[
|
|
* {
|
|
* "id":1,
|
|
* "name":"北京",
|
|
* "parent_id":"0",
|
|
* "type":"province"
|
|
* },
|
|
* ]
|
|
* }
|
|
*/
|
|
public function city(Request $request)
|
|
{
|
|
$parentId = $request->input('parent_id');
|
|
$province = ProvinceCityArea::where('parent_id', $parentId)->where('type', 'city')->get();
|
|
return $this->jsonSuccess($province);
|
|
}
|
|
|
|
|
|
/**
|
|
* @api {POST} /api/seller/area/area 地区-县/区
|
|
* @apiVersion 0.1.0
|
|
* @apiGroup 店主
|
|
*
|
|
* @apiParam {String} parent_id 市级id
|
|
*
|
|
* @apiSuccessExample {json} 返回结果
|
|
* {
|
|
* "code":200,
|
|
* "message":"",
|
|
* "data":[
|
|
* {
|
|
* "id":1,
|
|
* "name":"北京",
|
|
* "parent_id":"0",
|
|
* "type":"province"
|
|
* },
|
|
* ]
|
|
* }
|
|
*/
|
|
public function area(Request $request)
|
|
{
|
|
$parentId = $request->input('parent_id');
|
|
$province = ProvinceCityArea::where('parent_id', $parentId)->where('type', 'area')->get();
|
|
return $this->jsonSuccess($province);
|
|
}
|
|
}
|