88 lines
2.3 KiB
PHP
Executable File
88 lines
2.3 KiB
PHP
Executable File
<?php
|
|
namespace app\shopapi\controller;
|
|
use app\shopapi\logic\CityLogic;
|
|
|
|
/**
|
|
* 城市控制器类
|
|
* Class CityController
|
|
* @package app\shopapi\controller
|
|
*/
|
|
class CityController extends BaseShopController
|
|
{
|
|
|
|
public function getCityLists()
|
|
{
|
|
$lists = (new CityLogic())->getCityLists();
|
|
return $this->success('',$lists);
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 搜索附近地址
|
|
* @return \think\response\Json
|
|
* @author ljj
|
|
* @date 2024/7/23 上午11:21
|
|
*/
|
|
public function getNearbyLocation()
|
|
{
|
|
$params = $this->request->get();
|
|
$result = (new CityLogic())->getNearbyLocation($params);
|
|
if ($result['status'] !== 0) {
|
|
return $this->fail($result['message']);
|
|
}
|
|
return $this->success('',$result);
|
|
}
|
|
|
|
/**
|
|
* @notes 获取当前位置最近的城市
|
|
* @return \think\response\Json
|
|
* @author cjhao
|
|
* @date 2024/9/3 17:34
|
|
*/
|
|
public function getNearbyCity()
|
|
{
|
|
$params = $this->request->get();
|
|
$result = (new CityLogic())->getNearbyCity($params);
|
|
if(false === $result){
|
|
return $this->fail(CityLogic::getError());
|
|
}
|
|
return $this->success('',$result);
|
|
}
|
|
|
|
/**
|
|
* @notes 地级市列表
|
|
* @return \think\response\Json
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
* @author ljj
|
|
* @date 2022/4/6 2:41 下午
|
|
*/
|
|
public function city()
|
|
{
|
|
$params = $this->request->get();
|
|
$result = (new CityLogic())->city($params);
|
|
return $this->success('获取成功',$result);
|
|
}
|
|
|
|
/**
|
|
* @notes 逆地址解析(坐标位置描述)
|
|
* @return \think\response\Json
|
|
* @author ljj
|
|
* @date 2022/10/13 2:44 下午
|
|
* 本接口提供由经纬度到文字地址及相关位置信息的转换能力
|
|
*/
|
|
public function geocoderCoordinate()
|
|
{
|
|
$get = $this->request->get();
|
|
if (!isset($get['location']) || $get['location'] == '') {
|
|
return $this->fail('经纬度缺失');
|
|
}
|
|
|
|
$result = (new CityLogic())->geocoderCoordinate($get);
|
|
if ($result['status'] !== 0) {
|
|
return $this->fail($result['message']);
|
|
}
|
|
return $this->success('',$result);
|
|
}
|
|
} |