diff --git a/app/api/controller/IndexController.php b/app/api/controller/IndexController.php index f87743d1..80b0cb32 100644 --- a/app/api/controller/IndexController.php +++ b/app/api/controller/IndexController.php @@ -5,6 +5,7 @@ use app\common\enum\notice\NoticeEnum; use app\common\model\action\Action; use app\common\model\device\Device; use app\common\model\device\MonitorThreshold; +use app\common\model\file\File; use app\common\model\land\Land; use app\common\model\land\LandProduct; use app\common\model\LandCollection; @@ -48,6 +49,9 @@ class IndexController extends BaseApiController $device = Device::where('id', $productDevice['device_id'])->findOrEmpty(); $data['video_url'] = $device['video_url']; $data['device_id'] = $device['id']; + // 监控视频封面 + $file = File::where('cid', $device['id'])->order('id', 'desc')->findOrEmpty(); + $data['video_cover'] = isset($file['url'])? env('project.project_url').'/'.$file['url']: ''; $landCollection = LandCollection::where('land_id',$params['land_id'])->order('id desc')->findOrEmpty(); if($landCollection->isEmpty()){ $data['monitor'] = []; diff --git a/app/api/controller/UploadController.php b/app/api/controller/UploadController.php index d17b0a69..adcb50b2 100644 --- a/app/api/controller/UploadController.php +++ b/app/api/controller/UploadController.php @@ -44,5 +44,16 @@ class UploadController extends BaseApiController } + public function uploadVideoCover() + { + try { + $deviceId = $this->request->param('device_id', ''); + $result = UploadService::image($deviceId, $this->userId,FileEnum::SOURCE_USER); + return $this->success('上传成功', ['url'=>env('project.project_url').'/'.$result['url']]); + } catch (Exception $e) { + return $this->fail($e->getMessage()); + } + } + } \ No newline at end of file