Compare commits
No commits in common. "6be8667105886f92e31b5f6beae04ae4ecea499a" and "67d830c567178934077e2b82c64b30b7ce518892" have entirely different histories.
6be8667105
...
67d830c567
|
@ -17,10 +17,6 @@ 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;
|
||||
|
||||
|
@ -33,39 +29,67 @@ use think\response\Json;
|
|||
class IndexController extends BaseApiController
|
||||
{
|
||||
|
||||
public array $notNeedLogin = ['code','suYuan'];
|
||||
|
||||
public function index(): Json
|
||||
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()
|
||||
{
|
||||
//获取土地信息
|
||||
$land = Land::where('user_id',$this->userId)->order('id desc')->findOrEmpty();
|
||||
if($land->isEmpty()){
|
||||
return $this->success('请求成功',[]);
|
||||
$result = IndexLogic::getIndexData();
|
||||
return $this->data($result);
|
||||
}
|
||||
$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();
|
||||
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
$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();
|
||||
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
$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());
|
||||
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
|
||||
// 获取短信验证码
|
||||
|
|
Loading…
Reference in New Issue