Compare commits
2 Commits
67d830c567
...
6be8667105
Author | SHA1 | Date |
---|---|---|
weiz | 6be8667105 | |
weiz | c132164e06 |
|
@ -17,6 +17,10 @@ namespace app\api\controller;
|
|||
|
||||
use app\api\logic\IndexLogic;
|
||||
use app\common\enum\notice\NoticeEnum;
|
||||
use app\common\model\land\Land;
|
||||
use app\common\model\land\LandDevice;
|
||||
use app\common\model\monitor\AirMonitor;
|
||||
use app\common\model\monitor\SoilMonitor;
|
||||
use think\facade\Log;
|
||||
use think\response\Json;
|
||||
|
||||
|
@ -28,68 +32,40 @@ use think\response\Json;
|
|||
*/
|
||||
class IndexController extends BaseApiController
|
||||
{
|
||||
|
||||
|
||||
public array $notNeedLogin = ['index', 'config', 'policy', 'decorate','code','suYuan'];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 首页数据
|
||||
* @return Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/9/21 19:15
|
||||
*/
|
||||
public function index()
|
||||
|
||||
public array $notNeedLogin = ['code','suYuan'];
|
||||
|
||||
public function index(): Json
|
||||
{
|
||||
$result = IndexLogic::getIndexData();
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 全局配置
|
||||
* @return Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/9/21 19:41
|
||||
*/
|
||||
public function config()
|
||||
{
|
||||
$result = IndexLogic::getConfigData();
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 政策协议
|
||||
* @return Json
|
||||
* @author 段誉
|
||||
* @date 2022/9/20 20:00
|
||||
*/
|
||||
public function policy()
|
||||
{
|
||||
$type = $this->request->get('type/s', '');
|
||||
$result = IndexLogic::getPolicyByType($type);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 装修信息
|
||||
* @return Json
|
||||
* @author 段誉
|
||||
* @date 2022/9/21 18:37
|
||||
*/
|
||||
public function decorate()
|
||||
{
|
||||
$id = $this->request->get('id/d');
|
||||
$result = IndexLogic::getDecorate($id);
|
||||
return $this->data($result);
|
||||
//获取土地信息
|
||||
$land = Land::where('user_id',$this->userId)->order('id desc')->findOrEmpty();
|
||||
if($land->isEmpty()){
|
||||
return $this->success('请求成功',[]);
|
||||
}
|
||||
$land['pic'] = json_decode($land['pic'],true);
|
||||
//获取监测数据
|
||||
$landDeviceForSoil = LandDevice::where('land_id',$land['id'])->where('device_type',1)->findOrEmpty();
|
||||
if($landDeviceForSoil->isEmpty()){
|
||||
$data['soil_device'] = 0;
|
||||
}else{
|
||||
$data['soil_device'] = 1;
|
||||
$data['soil_monitor_data'] = SoilMonitor::where('device_id',$landDeviceForSoil['device_id'])->order('id desc')->findOrEmpty();
|
||||
}
|
||||
$landDeviceForAir = LandDevice::where('land_id',$land['id'])->where('device_type',2)->findOrEmpty();
|
||||
if($landDeviceForAir->isEmpty()){
|
||||
$data['air_device'] = 0;
|
||||
}else{
|
||||
$data['air_device'] = 1;
|
||||
$data['air_monitor_data'] = AirMonitor::where('device_id',$landDeviceForAir['device_id'])->order('id desc')->findOrEmpty();
|
||||
}
|
||||
$landDeviceForVideo = LandDevice::where('land_id',$land['id'])->where('device_type',3)->findOrEmpty();
|
||||
if($landDeviceForVideo->isEmpty()){
|
||||
$data['video_device'] = 0;
|
||||
}else{
|
||||
$data['video_device'] = 1;
|
||||
$data['video_monitor_data'] = '';
|
||||
}
|
||||
return $this->success('请求成功',$land->toArray());
|
||||
}
|
||||
|
||||
// 获取短信验证码
|
||||
|
|
Loading…
Reference in New Issue