package com.yihu.jw.base.config;

import com.yihu.jw.base.dao.device.YsConfigDao;
import com.yihu.jw.entity.care.device.YsConfigDo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by Bing on 2021/6/1.
 * 萤石摄像头配置
 */
@Component
public class YsConfig {

    @Autowired
    private YsConfigDao ysConfigDao;

    //文档地址 https://www.yuque.com/u1400669/kb/lmfp6u


    public static final String baseUrl = "https://esopen.ys7.com";

    public static final String iotBaseUrl = "https://open.ys7.com";

   //saas平台 https://www.yuque.com/u1400669/kb/wdvi3b#9ZP70

    public static final String saasAssesToken =baseUrl+ "/api/user/open-app/auth/gettoken";

    //开放平台  https://open.ys7.com/doc/zh/book/index/user.html
    public static final String iotAssesToken =baseUrl+ "/api/user/component-open/sso/oauth2/getEZAccessToken";

    //获取通道列表
    public static final String surveillanceWayList =baseUrl+ "/api/resource/open-app/surveillance/camera/list/page";

    //获取通道信息(通道默认为1)
    public static final String surveillanceWay =baseUrl+ "/api/resource/open-app/surveillance/camera/info";

    //设备抓拍
    public static final String deviceCapture =baseUrl +"/api/resource/device/capture";

    //获取设备有效直播地址
    public static final String getDeviceLiveAddress = iotBaseUrl+ "/api/lapp/live/address/limited";

    //设备视频加解密开关
    public static final String deviceEncrypt = baseUrl+ "/api/resource/device/encrypt/switch";

    //跌倒检测功能查询、设置(立即检测！判断是否有跌倒通过推送消息)
    public static final String deviceFailConfig = iotBaseUrl + "/api/route/device/devconfig/keyValue/{0}/{1}/op";

    //云台控制
    public static final String ptzStart = iotBaseUrl +"/api/lapp/device/ptz/start";

    //云台停止
    public static final String ptzStop = iotBaseUrl +"/api/lapp/device/ptz/stop";

    public static final String openChannelNo = iotBaseUrl +"/api/lapp/live/video/open";

    public static final String defenceSet = iotBaseUrl +"/open.ys7.com/api/lapp/device/intelligence/detection/switch/set";

    /**
     * 录像相关
     */

    //获取录像accessKey、上传录像地址
    public static final String videoKey = baseUrl +"/seastart/vod/token";

    //上传录像上传地址通过videoKey接口获取
    public static final String videoUpload = "https://seastart.ss.bscstorage.com";

    //录像列表
    public static final String videoList = baseUrl +"/seastart/vod/list";

    //批量获取录像详情
    public static final String videoDetailList = baseUrl +"/seastart/vod";

    //录像详情
    public static final String videoDetail = baseUrl +"/seastart/vod/get";

    public YsConfigDo getConfig(String deviceSn){
        YsConfigDo configDo = ysConfigDao.getYsConfigByDeviceSn(deviceSn);
        if (null==configDo){
            configDo = ysConfigDao.getDefaultConfig(1);
        }
        return configDo;
    }

}
