<?php
/**
 * Created by PhpStorm.
 * User: qiuzijian
 * Date: 2021-04-25
 * Time: 09:53
 */

namespace Modules\Camera\Http\Controllers\Api;

use App\Enum\ApiEnum;
use App\Http\Controllers\Api\BaseController;
use Illuminate\Support\Facades\Input;
use Modules\Camera\Services\CameraServices;

class CameraApiController extends BaseController
{
    /**
     * 作者: qiuzijian
     * 注释: 获取摄像头列表
     * @return \App\Http\Controllers\Api\JsonResponse
     */
    public function getCamerasList()
    {
        $mine_id = Input::get('mine_id', '');

        if (!$mine_id) {
            return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
        }

        $result = CameraServices::getCameraListByMineId($mine_id);

        return self::successResponse($result);
    }

    /**
     * 作者: qiuzijian
     * 注释: 获取摄像头播放地址
     * @return \App\Http\Controllers\Api\JsonResponse
     */
    public function getCamerasUrl()
    {
        $camera_id = Input::get('camera_id', '');

        if (!$camera_id) {
            return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
        }

        $result = CameraServices::getCameraUrlByCameraId($camera_id);

        return self::successResponse($result);
    }
}