From f8bcbe6e6c54b531c6f99fe6f45f365992404a34 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Fri, 15 Dec 2023 15:25:10 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E4=BA=A7=E5=93=81=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/dataview/LandController.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/api/controller/dataview/LandController.php b/app/api/controller/dataview/LandController.php index a18b9b30..fcbdf532 100644 --- a/app/api/controller/dataview/LandController.php +++ b/app/api/controller/dataview/LandController.php @@ -6,6 +6,7 @@ use app\api\controller\BaseApiController; use app\common\model\device\MonitorAlarm; use app\common\model\land\Land; use app\common\model\land\LandPlant; +use app\common\model\land\Product; use app\common\model\LandCollection; use think\facade\Db; use think\exception\ValidateException; @@ -13,7 +14,7 @@ use think\exception\ValidateException; class LandController extends BaseApiController { - public array $notNeedLogin = ['plantProductCount', 'landCollectionList', 'landMonitorAlarmHistory', 'landList', 'centralCount']; + public array $notNeedLogin = ['plantProductCount', 'landCollectionList', 'landMonitorAlarmHistory', 'productList', 'landList', 'centralCount']; public $areaCode; public $streetCode; @@ -150,6 +151,21 @@ class LandController extends BaseApiController return $this->success('成功', compact('list')); } + public function productList() + { + $list = Product::alias('p')->field('p.*') + ->join('land_product lp', 'p.id=lp.product_id') + ->join('land l', 'lp.land_id=l.id') + ->where(function ($query) { + if ($this->streetCode != '') { + $query->where('l.town_code', $this->streetCode); + } else { + $query->where('l.county_code', $this->areaCode); + } + })->select(); + return $this->success('成功', compact('list')); + } + public function centralCount() {