Commit 6614b0dd authored by hujun's avatar hujun

城市地铁

parent dd05ef6a
<?php
/**
* Created by PhpStorm.
* User: HuJun
* Date: 2019/6/3
* Time: 15:23
*/
namespace app\index\controller;
use app\index\extend\Basic;
use app\index\service\StationService;
class Station extends Basic
{
private $station_service;
private $code = 200;
private $msg = '';
private $data = [];
public function __construct()
{
parent::__construct();
$this->station_service = new StationService();
}
/**
* 城市地铁
*
* @return \think\Response
*/
public function getList()
{
$code = 200;
$msg = '';
$data = [];
$result = $this->station_service->getStationList($this->params);
if ($result['status'] == 'successful') {
$data = $result['data'];
} else {
$code = 101;
$msg = $result['msg'];
}
return $this->response($code, $msg, $data);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: HuJun
* Date: 2019/6/3
* Time: 15:25
*/
namespace app\index\service;
use app\model\MetroStations;
class StationService
{
private $m_metro_stations;
public function __construct()
{
$this->m_metro_stations = new MetroStations();
}
/**
* 当前城市地铁
*
* @param $params
* @return mixed
*/
public function getStationList($params) {
$result['status'] = 'fail';
if (empty($params['province'])) {
$result['msg'] = '省为空';
return $result;
}
if (empty($params['city'])) {
$result['msg'] = '市为空';
return $result;
}
$where['province'] = $params['province'];
$where['city'] = $params['city'];
$field = 'id,line_name_simple,name,latitude,longitude';
try{
$data = $this->m_metro_stations->getListAll($field, $where);
} catch (\Exception $e) {
$result['msg'] = $e->getMessage();
return $result;
}
$line_name = [];
foreach ($data as $k=>$v) {
$line_name[$v['line_name_simple']][] = [
'id'=> $v['id'],
'name'=> $v['name'],
'latitude'=> $v['latitude'],
'longitude'=> $v['longitude'],
];
}
$result['status'] = 'successful';
$result['data'] = $line_name;
return $result;
}
}
\ No newline at end of file
...@@ -42,7 +42,7 @@ class MetroStations extends BaseModel ...@@ -42,7 +42,7 @@ class MetroStations extends BaseModel
*/ */
public function getListAll($field, $where) public function getListAll($field, $where)
{ {
$where['img_status'] = 0; $where['is_del'] = 0;
return $this->db_->field($field) return $this->db_->field($field)
->where($where) ->where($where)
->select(); ->select();
......
...@@ -986,6 +986,7 @@ Route::group('office_index', [ ...@@ -986,6 +986,7 @@ Route::group('office_index', [
'getBuildingList' => ['index/OfficeManage/getBuildingList', ['method' => 'GET']],//楼盘列表 'getBuildingList' => ['index/OfficeManage/getBuildingList', ['method' => 'GET']],//楼盘列表
'delBuilding' => ['index/OfficeManage/delBuilding', ['method' => 'GET']],//删除楼盘 'delBuilding' => ['index/OfficeManage/delBuilding', ['method' => 'GET']],//删除楼盘
'getRoomList' => ['index/OfficeRoom/getRoomList', ['method' => 'GET']],//删除楼盘 'getRoomList' => ['index/OfficeRoom/getRoomList', ['method' => 'GET']],//删除楼盘
'getList' => ['index/Station/getList', ['method' => 'GET']],//城市地铁
]); ]);
//Route::miss('api/index/miss');//处理错误的url //Route::miss('api/index/miss');//处理错误的url
\ 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