diff --git a/admin/src/views/product/index.vue b/admin/src/views/product/index.vue
index 82c5fee..d877829 100644
--- a/admin/src/views/product/index.vue
+++ b/admin/src/views/product/index.vue
@@ -44,8 +44,8 @@
- ID: {{ row.land_id }}
- 名称: {{ row.title }}
+ ID: {{ row.fence_house_id }}
+ 名称: {{ row.fenceHouse.fence_house_name}}
diff --git a/app/adminapi/lists/device/DeviceLists.php b/app/adminapi/lists/device/DeviceLists.php
index de637e6..eaefeb9 100644
--- a/app/adminapi/lists/device/DeviceLists.php
+++ b/app/adminapi/lists/device/DeviceLists.php
@@ -86,11 +86,10 @@ class DeviceLists extends BaseAdminDataLists implements ListsSearchInterface
return Db::name('device')->alias('d')
->where($this->searchWhere)->where($this->userSearch())->where($this->querySearch())
->leftJoin('user u','u.id = d.user_id')
+ ->leftJoin('farm f','f.user_id = u.id')
->leftJoin('product_device pd','pd.device_id = d.id')
->leftJoin('product p','p.id = pd.product_id')
- ->leftJoin('land_product lp','lp.product_id = pd.product_id')
- ->leftJoin('land l','l.id = lp.land_id')
- ->field('d.*, u.account, pd.product_id, p.name as product_name, lp.land_id, l.title as land_title')
+ ->field('d.*, u.account, pd.product_id, p.name as product_name, f.id as farm_id, f.farm_name')
->limit($this->limitOffset, $this->limitLength)
->order(['d.id' => 'desc'])
->select()->each(function($item, $key){
diff --git a/app/adminapi/lists/land/ProductLists.php b/app/adminapi/lists/land/ProductLists.php
index a4f47cb..ed28c39 100644
--- a/app/adminapi/lists/land/ProductLists.php
+++ b/app/adminapi/lists/land/ProductLists.php
@@ -83,12 +83,11 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface
*/
public function lists(): array
{
- return Db::name('product')->alias('p')
+ return Product::alias('p')
->where($this->searchWhere)->where($this->userSearch())->where($this->querySearch())
+ ->with(['fenceHouse'])
->leftJoin('user u','u.id = p.user_id')
- ->leftJoin('land_product lp','lp.product_id = p.id')
- ->leftJoin('land l','l.id = lp.land_id')
- ->field('p.*, lp.land_id, l.title, u.account')
+ ->field('p.*, u.account')
->limit($this->limitOffset, $this->limitLength)
->order(['p.id' => 'desc'])
->select()
@@ -107,8 +106,6 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface
return Db::name('product')->alias('p')
->where($this->searchWhere)->where($this->userSearch())->where($this->querySearch())
->leftJoin('user u','u.id = p.user_id')
- ->leftJoin('land_product lp','lp.product_id = p.id')
- ->leftJoin('land l','l.id = lp.land_id')
->count();
}
diff --git a/app/common/model/land/Product.php b/app/common/model/land/Product.php
index e848a0d..ad6478d 100644
--- a/app/common/model/land/Product.php
+++ b/app/common/model/land/Product.php
@@ -16,7 +16,7 @@ namespace app\common\model\land;
use app\common\model\BaseModel;
-
+use app\common\model\fence_house\FenceHouse;
/**
@@ -42,4 +42,8 @@ class Product extends BaseModel
return $this->hasOne(\app\common\model\user\User::class, 'id', 'user_id');
}
+ public function fenceHouse()
+ {
+ return $this->hasOne(FenceHouse::class, 'id', 'fence_house_id');
+ }
}
\ No newline at end of file