add 产品列表图

This commit is contained in:
chenbo 2023-12-15 15:25:10 +08:00
parent 3bf466d098
commit f8bcbe6e6c
1 changed files with 17 additions and 1 deletions

View File

@ -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()
{