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

namespace Modules\Mine\Http\Controllers\Api;

use App\Enum\ApiEnum;
use App\Http\Controllers\Api\BaseController;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Log;
use Modules\Camera\Http\Controllers\Api\HaiKangController;
use Modules\Mine\Entities\MineListExt;
use Modules\Mine\Enum\MineEnum;
use Modules\Mine\Enum\SurfaceEnum;
use Modules\Mine\Services\MineServices;
use Modules\Mine\Services\SurfaceServices;

class MineApiController extends BaseController
{

    /**
     * 作者: qiuzijian
     * 注释: 获取矿井列表
     * @return \App\Http\Controllers\Api\JsonResponse
     */
    public function getMineList()
    {
        $mine_code = Input::get('mine_code', '');

        $result = MineServices::getMineList($mine_code);

        return self::successResponse($result);
    }

    /**
     * 作者: qiuzijian
     * 注释: 获取矿区列表
     * @return \App\Http\Controllers\Api\JsonResponse
     */
    public function getAreaList()
    {
        $mine_code = Input::get('mine_code', '');

        $result = MineServices::getAreaList($mine_code);

//        foreach ($result['data'] as $key => $val) {
            //分矿区判断是否使用海康视频服务器
//            $is_hak = MineListExt::where('mine_id', $val['mine_id'])->value('is_hak');

//            if ($is_hak) {
//                $hk_result = MineServices::getHaiKangArea($val['mine_id']);
//                $result['data'][$key]['children'] = $hk_result['data'];
//            }
//        }

        return self::successResponse($result);
    }

    /**
     * 作者: qiuzijian
     * 注释: 获取工作面列表
     * @return \App\Http\Controllers\Api\JsonResponse
     */
    public function getSurfaceList()
    {
        $working_area = Input::get('area_type', SurfaceEnum::WORKING_AREA_WORK);

        $result = SurfaceServices::getApiSurfaceList($working_area);

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