update
This commit is contained in:
parent
a3704c69e3
commit
edce7b2ce3
|
@ -134,6 +134,10 @@ class AnimalInfoLogic extends BaseLogic
|
||||||
*/
|
*/
|
||||||
public static function detail($params): array
|
public static function detail($params): array
|
||||||
{
|
{
|
||||||
|
if (isset($params['sn'])) {
|
||||||
|
return AnimalInfo::with(['fenceHouseAttr'])->where('sn', $params['sn'])->toArray();
|
||||||
|
}
|
||||||
return AnimalInfo::with(['fenceHouseAttr'])->findOrEmpty($params['id'])->toArray();
|
return AnimalInfo::with(['fenceHouseAttr'])->findOrEmpty($params['id'])->toArray();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -15,9 +15,12 @@
|
||||||
namespace app\adminapi\logic\fence_house;
|
namespace app\adminapi\logic\fence_house;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\device\Device;
|
||||||
use app\common\model\farm\Farm;
|
use app\common\model\farm\Farm;
|
||||||
use app\common\model\fence_house\FenceHouse;
|
use app\common\model\fence_house\FenceHouse;
|
||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
|
use app\common\model\land\Product;
|
||||||
|
use app\common\model\product\ProductDevice;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,7 +123,14 @@ class FenceHouseLogic extends BaseLogic
|
||||||
*/
|
*/
|
||||||
public static function detail($params): array
|
public static function detail($params): array
|
||||||
{
|
{
|
||||||
return FenceHouse::findOrEmpty($params['id'])->toArray();
|
$data = FenceHouse::findOrEmpty($params['id'])->toArray();
|
||||||
|
$product = Product::where('fence_house_id', $params['id'])->findOrEmpty()->toArray();
|
||||||
|
$deviceIds = ProductDevice::where('product_id', $product['id'])->column('device_id');
|
||||||
|
$device = Device::whereIn('id', $deviceIds)->where('type', 2)->findOrEmpty();
|
||||||
|
$data['video_url'] = $device['video_url'];
|
||||||
|
$data['device_id'] = $device['id'];
|
||||||
|
|
||||||
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -99,10 +99,8 @@ class AnimalInfoController extends BaseApiController
|
||||||
*/
|
*/
|
||||||
public function detail()
|
public function detail()
|
||||||
{
|
{
|
||||||
$params = (new AnimalInfoValidate())->goCheck('detail');
|
$params = $this->request->param();
|
||||||
$result = AnimalInfoLogic::detail($params);
|
$result = AnimalInfoLogic::detail($params);
|
||||||
return $this->data($result);
|
return $this->data($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue