|
@@ -1,7 +1,6 @@
|
|
package com.qmth.themis.business.util;
|
|
package com.qmth.themis.business.util;
|
|
|
|
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
-import com.qmth.themis.business.domain.TencentYunDomain;
|
|
|
|
import com.qmth.themis.business.entity.SysConfig;
|
|
import com.qmth.themis.business.entity.SysConfig;
|
|
import com.qmth.themis.business.entity.TOeExamRecord;
|
|
import com.qmth.themis.business.entity.TOeExamRecord;
|
|
import com.qmth.themis.business.enums.MonitorVideoSourceEnum;
|
|
import com.qmth.themis.business.enums.MonitorVideoSourceEnum;
|
|
@@ -19,6 +18,7 @@ import com.tencentcloudapi.vod.v20180717.VodClient;
|
|
import com.tencentcloudapi.vod.v20180717.models.SearchMediaRequest;
|
|
import com.tencentcloudapi.vod.v20180717.models.SearchMediaRequest;
|
|
import com.tencentcloudapi.vod.v20180717.models.SearchMediaResponse;
|
|
import com.tencentcloudapi.vod.v20180717.models.SearchMediaResponse;
|
|
import com.tencentyun.TLSSigAPIv2;
|
|
import com.tencentyun.TLSSigAPIv2;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Bean;
|
|
@@ -47,23 +47,68 @@ public class TencentYunUtil {
|
|
@Resource
|
|
@Resource
|
|
CacheService cacheService;
|
|
CacheService cacheService;
|
|
|
|
|
|
- private TencentYunDomain tencentYunDomain;
|
|
|
|
|
|
+ private String appId;
|
|
|
|
+ private String key;
|
|
|
|
+ private List<String> urls;
|
|
|
|
+ private String queryUrl;
|
|
|
|
+ private String service;
|
|
|
|
+ private String secretId;
|
|
|
|
+ private String secretKey;
|
|
|
|
+ private Long vodAppId;
|
|
|
|
+ private String callbackPwd;
|
|
|
|
+ private String callbackTime;
|
|
|
|
+ private String trtcQueryUrl;
|
|
|
|
+ private String trtcRegion;
|
|
|
|
|
|
@Bean
|
|
@Bean
|
|
- public TencentYunDomain tencentYunEnv(TencentYunDomain tencentYunDomain) {
|
|
|
|
- this.tencentYunDomain = new TencentYunDomain(tencentYunDomain.getAppId(),
|
|
|
|
- tencentYunDomain.getKey(),
|
|
|
|
- tencentYunDomain.getUrls(),
|
|
|
|
- tencentYunDomain.getQueryUrl(),
|
|
|
|
- tencentYunDomain.getService(),
|
|
|
|
- tencentYunDomain.getSecretId(),
|
|
|
|
- tencentYunDomain.getSecretKey(),
|
|
|
|
- tencentYunDomain.getVodAppId(),
|
|
|
|
- tencentYunDomain.getCallbackPwd(),
|
|
|
|
- tencentYunDomain.getCallbackTime(),
|
|
|
|
- tencentYunDomain.getTrtcQueryUrl(),
|
|
|
|
- tencentYunDomain.getTrtcRegion());
|
|
|
|
- return this.tencentYunDomain;
|
|
|
|
|
|
+ public void tencentCloudEnv() {
|
|
|
|
+ SysConfig sysConfigTencentCloudSdkAppId = cacheService.addSysConfigCache(SystemConstant.TENCENT_CLOUD_SDK_APPID);
|
|
|
|
+ Optional.ofNullable(sysConfigTencentCloudSdkAppId).orElseThrow(() -> new BusinessException("未配置腾讯云sdk_app_id"));
|
|
|
|
+ this.appId = sysConfigTencentCloudSdkAppId.getConfigValue();
|
|
|
|
+
|
|
|
|
+ SysConfig sysConfigTencentCloudSdkKey = cacheService.addSysConfigCache(SystemConstant.TENCENT_CLOUD_SDK_KEY);
|
|
|
|
+ Optional.ofNullable(sysConfigTencentCloudSdkKey).orElseThrow(() -> new BusinessException("未配置腾讯云sdk_key"));
|
|
|
|
+ this.key = sysConfigTencentCloudSdkKey.getConfigValue();
|
|
|
|
+
|
|
|
|
+ SysConfig sysConfigTencentCloudSdkUrls = cacheService.addSysConfigCache(SystemConstant.TENCENT_CLOUD_SDK_URLS);
|
|
|
|
+ Optional.ofNullable(sysConfigTencentCloudSdkUrls).orElseThrow(() -> new BusinessException("未配置腾讯云sdk_url"));
|
|
|
|
+ this.urls = Arrays.asList(StringUtils.split(sysConfigTencentCloudSdkUrls.getConfigValue(), ","));
|
|
|
|
+
|
|
|
|
+ SysConfig sysConfigTencentCloudSdkService = cacheService.addSysConfigCache(SystemConstant.TENCENT_CLOUD_SDK_SERVICE);
|
|
|
|
+ Optional.ofNullable(sysConfigTencentCloudSdkService).orElseThrow(() -> new BusinessException("未配置腾讯云sdk_service"));
|
|
|
|
+ this.service = sysConfigTencentCloudSdkService.getConfigValue();
|
|
|
|
+
|
|
|
|
+ SysConfig sysConfigTencentCloudSdkQueryUrl = cacheService.addSysConfigCache(SystemConstant.TENCENT_CLOUD_SDK_QUERY_URL);
|
|
|
|
+ Optional.ofNullable(sysConfigTencentCloudSdkQueryUrl).orElseThrow(() -> new BusinessException("未配置腾讯云sdk_query_url"));
|
|
|
|
+ this.queryUrl = sysConfigTencentCloudSdkQueryUrl.getConfigValue();
|
|
|
|
+
|
|
|
|
+ SysConfig sysConfigTencentCloudSdkSecretId = cacheService.addSysConfigCache(SystemConstant.TENCENT_CLOUD_SDK_SECRET_ID);
|
|
|
|
+ Optional.ofNullable(sysConfigTencentCloudSdkSecretId).orElseThrow(() -> new BusinessException("未配置腾讯云sdk_secret_id"));
|
|
|
|
+ this.secretId = sysConfigTencentCloudSdkSecretId.getConfigValue();
|
|
|
|
+
|
|
|
|
+ SysConfig sysConfigTencentCloudSdkSecretKey = cacheService.addSysConfigCache(SystemConstant.TENCENT_CLOUD_SDK_SECRET_KEY);
|
|
|
|
+ Optional.ofNullable(sysConfigTencentCloudSdkSecretKey).orElseThrow(() -> new BusinessException("未配置腾讯云sdk_secret_key"));
|
|
|
|
+ this.secretKey = sysConfigTencentCloudSdkSecretKey.getConfigValue();
|
|
|
|
+
|
|
|
|
+ SysConfig sysConfigTencentCloudSdkVodAppId = cacheService.addSysConfigCache(SystemConstant.TENCENT_CLOUD_SDK_VOD_APP_ID);
|
|
|
|
+ Optional.ofNullable(sysConfigTencentCloudSdkVodAppId).orElseThrow(() -> new BusinessException("未配置腾讯云sdk_vod_app_id"));
|
|
|
|
+ this.vodAppId = Long.parseLong(sysConfigTencentCloudSdkVodAppId.getConfigValue());
|
|
|
|
+
|
|
|
|
+ SysConfig sysConfigTencentCloudSdkCallBackPwd = cacheService.addSysConfigCache(SystemConstant.TENCENT_CLOUD_SDK_CALLBACK_PWD);
|
|
|
|
+ Optional.ofNullable(sysConfigTencentCloudSdkCallBackPwd).orElseThrow(() -> new BusinessException("未配置腾讯云sdk_回调密码"));
|
|
|
|
+ this.callbackPwd = sysConfigTencentCloudSdkCallBackPwd.getConfigValue();
|
|
|
|
+
|
|
|
|
+ SysConfig sysConfigTencentCloudSdkCallBackTime = cacheService.addSysConfigCache(SystemConstant.TENCENT_CLOUD_SDK_CALLBACK_TIME);
|
|
|
|
+ Optional.ofNullable(sysConfigTencentCloudSdkCallBackTime).orElseThrow(() -> new BusinessException("未配置腾讯云sdk_回调时间"));
|
|
|
|
+ this.callbackTime = sysConfigTencentCloudSdkCallBackTime.getConfigValue();
|
|
|
|
+
|
|
|
|
+ SysConfig sysConfigTencentCloudSdkTrtcQueryUrl = cacheService.addSysConfigCache(SystemConstant.TENCENT_CLOUD_SDK_TRTC_QUERY_URL);
|
|
|
|
+ Optional.ofNullable(sysConfigTencentCloudSdkTrtcQueryUrl).orElseThrow(() -> new BusinessException("未配置腾讯云sdk_trtc_query_url"));
|
|
|
|
+ this.trtcQueryUrl = sysConfigTencentCloudSdkTrtcQueryUrl.getConfigValue();
|
|
|
|
+
|
|
|
|
+ SysConfig sysConfigTencentCloudSdkTrtcRegion = cacheService.addSysConfigCache(SystemConstant.TENCENT_CLOUD_SDK_TRTC_REGION);
|
|
|
|
+ Optional.ofNullable(sysConfigTencentCloudSdkTrtcRegion).orElseThrow(() -> new BusinessException("未配置腾讯云sdk_trtc_region"));
|
|
|
|
+ this.trtcRegion = sysConfigTencentCloudSdkTrtcRegion.getConfigValue();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -74,14 +119,10 @@ public class TencentYunUtil {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public String getSign(String sessionId, Long expireTime) {
|
|
public String getSign(String sessionId, Long expireTime) {
|
|
- TLSSigAPIv2 api = new TLSSigAPIv2(Long.parseLong(this.tencentYunDomain.getAppId()), this.tencentYunDomain.getKey());
|
|
|
|
|
|
+ TLSSigAPIv2 api = new TLSSigAPIv2(Long.parseLong(this.getAppId()), this.getKey());
|
|
return api.genSig(sessionId, expireTime);
|
|
return api.genSig(sessionId, expireTime);
|
|
}
|
|
}
|
|
|
|
|
|
- public TencentYunDomain getTencentYunDomain() {
|
|
|
|
- return tencentYunDomain;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 请求腾讯云视频地址
|
|
* 请求腾讯云视频地址
|
|
*
|
|
*
|
|
@@ -106,10 +147,10 @@ public class TencentYunUtil {
|
|
SystemConstant.REDIS_LOCK_TENCENT_VIDEO_STREAM_ID_TIME_OUT);
|
|
SystemConstant.REDIS_LOCK_TENCENT_VIDEO_STREAM_ID_TIME_OUT);
|
|
if (lockStreamIds) {
|
|
if (lockStreamIds) {
|
|
try {
|
|
try {
|
|
- resultMap = this.tencentVodSdk(this.getTencentYunDomain().getSecretId(),
|
|
|
|
- this.getTencentYunDomain().getSecretKey(),
|
|
|
|
- this.getTencentYunDomain().getQueryUrl(),
|
|
|
|
- this.getTencentYunDomain().getVodAppId(),
|
|
|
|
|
|
+ resultMap = this.tencentVodSdk(this.getSecretId(),
|
|
|
|
+ this.getSecretKey(),
|
|
|
|
+ this.getQueryUrl(),
|
|
|
|
+ this.getVodAppId(),
|
|
streamIds);
|
|
streamIds);
|
|
break;
|
|
break;
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -230,4 +271,100 @@ public class TencentYunUtil {
|
|
}
|
|
}
|
|
return resultMap;
|
|
return resultMap;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public String getAppId() {
|
|
|
|
+ return appId;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setAppId(String appId) {
|
|
|
|
+ this.appId = appId;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String getKey() {
|
|
|
|
+ return key;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setKey(String key) {
|
|
|
|
+ this.key = key;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public List<String> getUrls() {
|
|
|
|
+ return urls;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setUrls(List<String> urls) {
|
|
|
|
+ this.urls = urls;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String getQueryUrl() {
|
|
|
|
+ return queryUrl;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setQueryUrl(String queryUrl) {
|
|
|
|
+ this.queryUrl = queryUrl;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String getService() {
|
|
|
|
+ return service;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setService(String service) {
|
|
|
|
+ this.service = service;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String getSecretId() {
|
|
|
|
+ return secretId;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setSecretId(String secretId) {
|
|
|
|
+ this.secretId = secretId;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String getSecretKey() {
|
|
|
|
+ return secretKey;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setSecretKey(String secretKey) {
|
|
|
|
+ this.secretKey = secretKey;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public Long getVodAppId() {
|
|
|
|
+ return vodAppId;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setVodAppId(Long vodAppId) {
|
|
|
|
+ this.vodAppId = vodAppId;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String getCallbackPwd() {
|
|
|
|
+ return callbackPwd;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setCallbackPwd(String callbackPwd) {
|
|
|
|
+ this.callbackPwd = callbackPwd;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String getCallbackTime() {
|
|
|
|
+ return callbackTime;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setCallbackTime(String callbackTime) {
|
|
|
|
+ this.callbackTime = callbackTime;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String getTrtcQueryUrl() {
|
|
|
|
+ return trtcQueryUrl;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setTrtcQueryUrl(String trtcQueryUrl) {
|
|
|
|
+ this.trtcQueryUrl = trtcQueryUrl;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String getTrtcRegion() {
|
|
|
|
+ return trtcRegion;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setTrtcRegion(String trtcRegion) {
|
|
|
|
+ this.trtcRegion = trtcRegion;
|
|
|
|
+ }
|
|
}
|
|
}
|