|
|
@@ -0,0 +1,127 @@
|
|
|
+package com.zhongzheng.modules.polyv.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
+import cn.hutool.core.lang.Validator;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.http.HttpStatus;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.github.pagehelper.Page;
|
|
|
+import com.zhongzheng.common.core.page.TableDataInfo;
|
|
|
+import com.zhongzheng.common.core.redis.RedisCache;
|
|
|
+import com.zhongzheng.common.utils.DateUtils;
|
|
|
+import com.zhongzheng.common.utils.ServletUtils;
|
|
|
+import com.zhongzheng.common.utils.http.HttpUtils;
|
|
|
+import com.zhongzheng.common.utils.polyv.PolyvUtils;
|
|
|
+import com.zhongzheng.modules.course.bo.CourseStreamingBusinessAddBo;
|
|
|
+import com.zhongzheng.modules.course.bo.CourseStreamingQueryBo;
|
|
|
+import com.zhongzheng.modules.course.domain.CourseStreaming;
|
|
|
+import com.zhongzheng.modules.course.service.ICourseStreamingBusinessService;
|
|
|
+import com.zhongzheng.modules.course.service.ICourseStreamingService;
|
|
|
+import com.zhongzheng.modules.course.vo.CourseStreamingVo;
|
|
|
+import com.zhongzheng.modules.polyv.bo.*;
|
|
|
+import com.zhongzheng.modules.polyv.domain.PolyvCata;
|
|
|
+import com.zhongzheng.modules.polyv.domain.PolyvVideDo;
|
|
|
+import com.zhongzheng.modules.polyv.domain.PolyvVideo;
|
|
|
+import com.zhongzheng.modules.polyv.domain.TokenResponse;
|
|
|
+import com.zhongzheng.modules.polyv.mapper.PolyvVideoMapper;
|
|
|
+import com.zhongzheng.modules.polyv.service.IPolyvCataService;
|
|
|
+import com.zhongzheng.modules.polyv.service.IPolyvLiveService;
|
|
|
+import com.zhongzheng.modules.polyv.service.IPolyvVideoService;
|
|
|
+import com.zhongzheng.modules.polyv.vo.*;
|
|
|
+import io.jsonwebtoken.lang.Assert;
|
|
|
+import net.polyv.common.v1.exception.PloyvSdkException;
|
|
|
+import net.polyv.live.v1.constant.LiveConstant;
|
|
|
+import net.polyv.live.v1.entity.channel.operate.LiveChannelAuthTokenRequest;
|
|
|
+import net.polyv.live.v1.entity.channel.operate.LiveChannelAuthTokenResponse;
|
|
|
+import net.polyv.live.v1.service.channel.impl.LiveChannelOperateServiceImpl;
|
|
|
+import net.polyv.live.v1.util.LiveSignUtil;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
+import java.security.NoSuchAlgorithmException;
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import static com.squareup.okhttp.internal.Util.md5Hex;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 保利威视频信息Service业务层处理
|
|
|
+ *
|
|
|
+ * @author change
|
|
|
+ * @date 2021-06-11
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class PolyvLiveServiceImpl implements IPolyvLiveService {
|
|
|
+
|
|
|
+ @Value("${poliv.sdk.userid}")
|
|
|
+ private String poliv_sdk_userid;
|
|
|
+
|
|
|
+ @Value("${poliv.sdk.appId}")
|
|
|
+ private String poliv_sdk_appId;
|
|
|
+
|
|
|
+ @Value("${poliv.sdk.appSecret}")
|
|
|
+ private String poliv_sdk_appSecret;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RedisCache redisCache;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getLiveSign(PolyvLiveQueryBo bo) throws IOException, NoSuchAlgorithmException {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ long timestamp = System.currentTimeMillis();
|
|
|
+ Map<String, String> paramMap = new HashMap<String, String>();
|
|
|
+ // 公共参数
|
|
|
+ paramMap.put("appId", poliv_sdk_appId);
|
|
|
+ paramMap.put("timestamp", Long.toString(timestamp));
|
|
|
+ // 业务参数
|
|
|
+ paramMap.put("channelId", bo.getChannelId());
|
|
|
+
|
|
|
+ // 一次性签名(可选参数)
|
|
|
+ // paramMap.put("signatureNonce", UUID.randomUUID().toString());
|
|
|
+ try{
|
|
|
+ // MD5签名(默认)
|
|
|
+ String sign = LiveSignUtil.getSign(paramMap, poliv_sdk_appSecret);
|
|
|
+ map.put("sign",sign);
|
|
|
+ map.put("timestamp",paramMap.get("timestamp"));
|
|
|
+ map.put("appId",paramMap.get("appId"));
|
|
|
+ }catch(UnsupportedEncodingException e){
|
|
|
+ throw e;
|
|
|
+ }catch (NoSuchAlgorithmException e){
|
|
|
+ throw e;
|
|
|
+ }
|
|
|
+ LiveChannelAuthTokenRequest liveChannelAuthTokenRequest = new LiveChannelAuthTokenRequest();
|
|
|
+ LiveChannelAuthTokenResponse liveChannelAuthTokenResponse;
|
|
|
+ try {
|
|
|
+ liveChannelAuthTokenRequest.setUserId(poliv_sdk_userid)
|
|
|
+ .setChannelId(bo.getChannelId())
|
|
|
+ .setRole(LiveConstant.Role.ADMIN.getDesc())
|
|
|
+ .setOrigin(null);
|
|
|
+ liveChannelAuthTokenResponse = new LiveChannelOperateServiceImpl().getChannelAuthToken(
|
|
|
+ liveChannelAuthTokenRequest);
|
|
|
+
|
|
|
+ if (liveChannelAuthTokenResponse != null) {
|
|
|
+ //to do something ......
|
|
|
+ map.put("token",liveChannelAuthTokenResponse.getToken());
|
|
|
+ map.put("mediaChannelKey",liveChannelAuthTokenResponse.getMediaChannelKey());
|
|
|
+ }
|
|
|
+ } catch (PloyvSdkException e) {
|
|
|
+ throw e;
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw e;
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+}
|