64 lines
2.4 KiB
PHP
64 lines
2.4 KiB
PHP
<?php
|
||
// +----------------------------------------------------------------------
|
||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||
// +----------------------------------------------------------------------
|
||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||
// | 开源版本可自由商用,可去除界面版权logo
|
||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||
// | 访问官网:https://www.likeadmin.cn
|
||
// | likeadmin团队 版权所有 拥有最终解释权
|
||
// +----------------------------------------------------------------------
|
||
// | author: likeadminTeam
|
||
// +----------------------------------------------------------------------
|
||
|
||
namespace app\api\controller;
|
||
|
||
use app\api\logic\GpsLogic;
|
||
|
||
/**
|
||
* 文章管理
|
||
* Class ArticleController
|
||
* @package app\api\controller
|
||
*/
|
||
class GpsController extends BaseApiController
|
||
{
|
||
public array $notNeedLogin = ['getCarInfo','getCarStatus','getCarHistory','test'];
|
||
|
||
public function getCarInfo() {
|
||
//获取参数
|
||
$params = $this -> request -> get('imei');
|
||
//验证参数
|
||
if(empty($params)) return $this->fail('参数错误');
|
||
//获取数据
|
||
$result = (new GpsLogic()) -> info($params);
|
||
return $result['code'] == 1 ? $this->success($result['msg'],$result['data']) : $this->fail($result['msg']);
|
||
}
|
||
|
||
public function getCarStatus() {
|
||
$result = (new GpsLogic()) -> status();
|
||
return $result['code'] == 1 ? $this->success($result['msg'],$result['data']) : $this->fail($result['msg']);
|
||
}
|
||
|
||
public function getCarHistory() {
|
||
//获取参数
|
||
$params = $this->request->get(['car_id','start_time','end_time']);
|
||
//验证参数
|
||
if(empty($params['car_id']) || empty($params['start_time']) || empty($params['end_time'])){
|
||
return $this->fail('参数错误');
|
||
}
|
||
//获取车辆行驶历史信息
|
||
$result = (new GpsLogic()) -> history($params);
|
||
if($result['code'] == 1){
|
||
$data = [];
|
||
foreach ($result['data'] as $k => $v) {
|
||
$data[$k]['lat'] = $v['latc'];
|
||
$data[$k]['lon'] = $v['lonc'];
|
||
}
|
||
return $this->success($result['msg'],$data);
|
||
}else{
|
||
return $this->fail($result['msg']);
|
||
}
|
||
}
|
||
}
|