he2802 před 1 rokem
rodič
revize
2b2a99e729

+ 6 - 1
zhongzheng-admin/src/main/java/com/zhongzheng/controller/common/CommonController.java

@@ -80,6 +80,7 @@ import com.zhongzheng.modules.system.service.ISysConfigService;
 import com.zhongzheng.modules.system.service.ISysTenantService;
 import com.zhongzheng.modules.system.service.ISysWebService;
 import com.zhongzheng.modules.system.vo.SysTenantVo;
+import com.zhongzheng.modules.tencentcloud.service.IVodService;
 import com.zhongzheng.modules.top.user.bo.TopSysTenantRegisterAddBo;
 import com.zhongzheng.modules.top.user.service.ITopSysTenantRegisterService;
 import com.zhongzheng.modules.user.service.IUserService;
@@ -173,6 +174,9 @@ public class CommonController extends BaseController {
     @Autowired
     private ClassGradeUserMapper classGradeUserMapper;
 
+    @Autowired
+    private IVodService iVodService;
+
     @Autowired
     private IMajorService iMajorService;
     private IZsBankService iZsBankService;
@@ -797,7 +801,8 @@ public class CommonController extends BaseController {
     @Log(title = "测试获取山东题库", businessType = BusinessType.INSERT)
     @GetMapping("/common/free/getShanDongExam")
     public AjaxResult getShanDongExam(GoodsQueryBo bo) throws UnsupportedEncodingException {
-        System.out.println(bo.getBuyNote());
+   //     System.out.println(bo.getBuyNote());
+        iVodService.describeMediaInfos(null);
         return AjaxResult.success();
     }
 

+ 42 - 0
zhongzheng-api/src/main/java/com/zhongzheng/controller/vod/VodVideoController.java

@@ -0,0 +1,42 @@
+package com.zhongzheng.controller.vod;
+
+import com.zhongzheng.common.core.controller.BaseController;
+import com.zhongzheng.common.core.domain.AjaxResult;
+import com.zhongzheng.common.utils.ServletUtils;
+import com.zhongzheng.framework.web.service.WxTokenService;
+import com.zhongzheng.modules.polyv.bo.PolyvLiveQueryBo;
+import com.zhongzheng.modules.polyv.service.IPolyvVideoService;
+import com.zhongzheng.modules.tencentcloud.service.IVodService;
+import com.zhongzheng.modules.user.entity.ClientLoginUser;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+@Api(value = "腾讯视频信息控制器", tags = {"腾讯视频信息管理"})
+@RequiredArgsConstructor(onConstructor_ = @Autowired)
+@RestController
+@RequestMapping("/vod/video")
+public class VodVideoController extends BaseController {
+
+    private final IVodService iVodService;
+
+
+
+    @ApiOperation("获取腾讯视频小程序播放凭证")
+    @GetMapping("/sign/{fileId}")
+    public AjaxResult getPlaySign(@PathVariable("fileId") String fileId){
+        Map<String,Object> map = iVodService.vodSignRequest(fileId);
+        return AjaxResult.success(map);
+    }
+
+}

+ 6 - 0
zhongzheng-common/pom.xml

@@ -92,6 +92,12 @@
             <version>3.3.0</version>
         </dependency>
 
+        <dependency>
+            <groupId>com.auth0</groupId>
+            <artifactId>java-jwt</artifactId>
+            <version>3.19.2</version>
+        </dependency>
+
         <!-- OSS SDK 相关依赖 -->
         <dependency>
             <groupId>com.aliyun.oss</groupId>

+ 16 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/tencentcloud/service/IVodService.java

@@ -0,0 +1,16 @@
+package com.zhongzheng.modules.tencentcloud.service;
+
+
+import com.zhongzheng.modules.tencentcloud.bo.FaceQueryBo;
+import com.zhongzheng.modules.tencentcloud.bo.InvoiceQueryBo;
+
+import java.util.Map;
+
+public interface IVodService {
+
+    Map<String,Object> describeMediaInfos(String[] fileIds);
+
+    Map<String,Object> vodSignRequest(String FileId);
+
+
+}

+ 123 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/tencentcloud/service/impl/VodServiceImpl.java

@@ -0,0 +1,123 @@
+package com.zhongzheng.modules.tencentcloud.service.impl;
+
+
+import cn.hutool.core.lang.Validator;
+import com.alibaba.fastjson.JSONObject;
+import com.auth0.jwt.JWT;
+import com.auth0.jwt.algorithms.Algorithm;
+import com.auth0.jwt.exceptions.JWTCreationException;
+import com.tencentcloudapi.common.Credential;
+import com.tencentcloudapi.common.exception.TencentCloudSDKException;
+import com.tencentcloudapi.common.profile.ClientProfile;
+import com.tencentcloudapi.common.profile.HttpProfile;
+import com.tencentcloudapi.faceid.v20180301.FaceidClient;
+import com.tencentcloudapi.faceid.v20180301.models.ImageRecognitionRequest;
+import com.tencentcloudapi.faceid.v20180301.models.ImageRecognitionResponse;
+import com.tencentcloudapi.iai.v20200303.IaiClient;
+import com.tencentcloudapi.iai.v20200303.models.CompareFaceRequest;
+import com.tencentcloudapi.iai.v20200303.models.CompareFaceResponse;
+import com.tencentcloudapi.ocr.v20181119.OcrClient;
+import com.tencentcloudapi.ocr.v20181119.models.*;
+import com.tencentcloudapi.vod.v20180717.VodClient;
+import com.tencentcloudapi.vod.v20180717.models.DescribeMediaInfosRequest;
+import com.tencentcloudapi.vod.v20180717.models.DescribeMediaInfosResponse;
+import com.zhongzheng.common.exception.CustomException;
+import com.zhongzheng.common.utils.DateUtils;
+import com.zhongzheng.modules.alioss.bo.OssRequest;
+import com.zhongzheng.modules.alioss.service.OssService;
+import com.zhongzheng.modules.base.service.IUserProfileService;
+import com.zhongzheng.modules.tencentcloud.bo.FaceQueryBo;
+import com.zhongzheng.modules.tencentcloud.bo.InvoiceQueryBo;
+import com.zhongzheng.modules.tencentcloud.service.IFaceOcrService;
+import com.zhongzheng.modules.tencentcloud.service.IVodService;
+import com.zhongzheng.modules.user.service.IUserService;
+import com.zhongzheng.modules.user.vo.UserVo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Service
+public class VodServiceImpl implements IVodService {
+
+    @Value("${tencent.cloud.SecretId}")
+    private String SecretId;
+
+    @Value("${tencent.cloud.SecretKey}")
+    private String SecretKey;
+
+    @Value("${aliyun.oss.endpoint}")
+    private String ossHost;
+
+
+    @Override
+    public Map<String, Object> describeMediaInfos(String[] fileIds) {
+        try{
+            Credential cred = new Credential(SecretId, SecretKey);
+            // 实例化一个http选项,可选的,没有特殊需求可以跳过
+            HttpProfile httpProfile = new HttpProfile();
+            httpProfile.setEndpoint("vod.tencentcloudapi.com");
+            // 实例化一个client选项,可选的,没有特殊需求可以跳过
+            ClientProfile clientProfile = new ClientProfile();
+            clientProfile.setHttpProfile(httpProfile);
+            // 实例化要请求产品的client对象,clientProfile是可选的
+            VodClient client = new VodClient(cred, "", clientProfile);
+            // 实例化一个请求对象,每个接口都会对应一个request对象
+            DescribeMediaInfosRequest req = new DescribeMediaInfosRequest();
+            req.setSubAppId(1306117675L);
+            String[] fileIdss = new String[]{"3270835015060309946"};
+            req.setFileIds(fileIdss);
+            // 返回的resp是一个DescribeMediaInfosResponse的实例,与请求对象对应
+            DescribeMediaInfosResponse resp = client.DescribeMediaInfos(req);
+
+            Map<String,Object> rs = new HashMap<>();
+            rs.put("name",resp.getMediaInfoSet()[0].getBasicInfo().getName());
+            rs.put("duration",resp.getMediaInfoSet()[0].getMetaData().getDuration());
+            System.out.println(rs);
+            return rs;
+        }catch (TencentCloudSDKException e){
+            System.out.println("错误"+e.getMessage());
+        }
+        return null;
+    }
+
+    @Override
+    public Map<String, Object> vodSignRequest(String FileId) {
+        Integer AppId = 1306117675;
+    //    String FileId = "4564972818519602447";
+        String AudioVideoType = "RawAdaptive";
+        Integer RawAdaptiveDefinition = 10;
+        Integer ImageSpriteDefinition = 10;
+        Long CurrentTime = DateUtils.getNowTime();
+        Long PsignExpire = DateUtils.getNowTime()+12*3600;
+        String UrlTimeExpire = Long.toHexString(PsignExpire);
+        String PlayKey = "TxtyhLlgo7J3iOADIron";
+        HashMap<String, Object> urlAccessInfo = new HashMap<String, Object>();
+        urlAccessInfo.put("t", UrlTimeExpire);
+        HashMap<String, Object> contentInfo = new HashMap<String, Object>();
+        contentInfo.put("audioVideoType", AudioVideoType);
+    //    contentInfo.put("rawAdaptiveDefinition", RawAdaptiveDefinition);
+        contentInfo.put("imageSpriteDefinition", ImageSpriteDefinition);
+        System.out.println(urlAccessInfo);
+        try {
+            Algorithm algorithm = Algorithm.HMAC256(PlayKey);
+            String token = JWT.create().withClaim("appId", AppId).withClaim("fileId", FileId)
+                    .withClaim("contentInfo", contentInfo)
+                    .withClaim("currentTimeStamp", CurrentTime).withClaim("expireTimeStamp", PsignExpire)
+                    .withClaim("urlAccessInfo", urlAccessInfo).sign(algorithm);
+            Map<String,Object> rs = new HashMap<>();
+            rs.put("fileID",FileId);
+            rs.put("appID",AppId);
+            rs.put("psign",token);
+            rs.put("licenseUrl","https://license.vod2.myqcloud.com/license/v2/1306117675_1/v_cube.license");
+    //        System.out.println("token:" + token);
+            return rs;
+
+        } catch (JWTCreationException exception) {
+            // Invalid Signing configuration / Couldn't convert Claims.
+        }
+        return null;
+    }
+}