|
@@ -1,15 +1,22 @@
|
|
package com.miaxis.teachingVideo.service.impl;
|
|
package com.miaxis.teachingVideo.service.impl;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
-import com.baomidou.mybatisplus.extension.conditions.update.UpdateChainWrapper;
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.miaxis.common.core.domain.Response;
|
|
import com.miaxis.common.core.domain.Response;
|
|
-import com.miaxis.feign.service.ITencentCosService;
|
|
|
|
|
|
+import com.miaxis.common.enums.FileUploadTypeEnum;
|
|
|
|
+import com.miaxis.common.exception.CustomException;
|
|
|
|
+import com.miaxis.file.domain.FileInfo;
|
|
import com.miaxis.file.service.IFileInfoService;
|
|
import com.miaxis.file.service.IFileInfoService;
|
|
import com.miaxis.teachingVideo.domain.TeachingVideoInfo;
|
|
import com.miaxis.teachingVideo.domain.TeachingVideoInfo;
|
|
|
|
+import com.miaxis.teachingVideo.dto.TeachingVideoInfoDto;
|
|
import com.miaxis.teachingVideo.mapper.TeachingVideoInfoMapper;
|
|
import com.miaxis.teachingVideo.mapper.TeachingVideoInfoMapper;
|
|
import com.miaxis.teachingVideo.service.ITeachingVideoInfoService;
|
|
import com.miaxis.teachingVideo.service.ITeachingVideoInfoService;
|
|
import com.miaxis.teachingVideo.vo.TeachingVideoInfoVo;
|
|
import com.miaxis.teachingVideo.vo.TeachingVideoInfoVo;
|
|
|
|
+import com.tencentcloudapi.vod.v20180717.VodClient;
|
|
|
|
+import com.tencentcloudapi.vod.v20180717.models.DescribeMediaInfosRequest;
|
|
|
|
+import com.tencentcloudapi.vod.v20180717.models.DescribeMediaInfosResponse;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -28,10 +35,10 @@ public class TeachingVideoInfoServiceImpl extends ServiceImpl<TeachingVideoInfoM
|
|
|
|
|
|
private final TeachingVideoInfoMapper teachingVideoInfoMapper;
|
|
private final TeachingVideoInfoMapper teachingVideoInfoMapper;
|
|
|
|
|
|
- private final ITencentCosService tencentCosService;
|
|
|
|
-
|
|
|
|
private final IFileInfoService fileInfoService;
|
|
private final IFileInfoService fileInfoService;
|
|
|
|
|
|
|
|
+ private final VodClient vodClient;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 查询教学视频列表
|
|
* 查询教学视频列表
|
|
*
|
|
*
|
|
@@ -60,15 +67,66 @@ public class TeachingVideoInfoServiceImpl extends ServiceImpl<TeachingVideoInfoM
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public Response saveTeachingVideo(TeachingVideoInfo teachingVideoInfo) {
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- //根据fileId获取云点播视频信息
|
|
|
|
- //tencentCosService.getVideoInfo(teachingVideoInfo.getFileId(),"basicInfo")
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public Response saveTeachingVideo(TeachingVideoInfoDto teachingVideoInfo) {
|
|
|
|
+
|
|
|
|
+ try{
|
|
|
|
+ //根据fileId获取云点播视频信息
|
|
|
|
+ DescribeMediaInfosRequest req = new DescribeMediaInfosRequest();
|
|
|
|
+ String[] fileId = {teachingVideoInfo.getFileId()};
|
|
|
|
+ String[] filter = {"basicInfo","metaData"};
|
|
|
|
+ req.setFileIds(fileId);
|
|
|
|
+ req.setFilters(filter);
|
|
|
|
+ DescribeMediaInfosResponse resp = vodClient.DescribeMediaInfos(req);
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(DescribeMediaInfosResponse.toJsonString(resp));
|
|
|
|
+ JSONArray mediaInfoSetArr = (JSONArray)jsonObject.get("MediaInfoSet");
|
|
|
|
+ JSONObject mediaInfoSetObj = (JSONObject)mediaInfoSetArr.get(0);
|
|
|
|
+ JSONObject basicInfo = (JSONObject)mediaInfoSetObj.get("BasicInfo");
|
|
|
|
+ JSONObject metaData = (JSONObject)mediaInfoSetObj.get("MetaData");
|
|
|
|
+
|
|
|
|
+ //获取视频、封面基础信息
|
|
|
|
+ String coverUrl = (String)basicInfo.get("CoverUrl");//封面访问路径
|
|
|
|
+ String mediaUrl = (String)basicInfo.get("MediaUrl");//视频访问路径
|
|
|
|
+ String size = String.valueOf(metaData.get("Size"));//视频文件大小
|
|
|
|
+ String duration = String.valueOf(metaData.get("Duration"));//视屏时长
|
|
|
|
+ Integer height = (Integer)metaData.get("Height");//视屏高度
|
|
|
|
+ Integer width = (Integer)metaData.get("Width");//视屏宽度
|
|
|
|
+
|
|
|
|
+ //保存视频、封面文件信息
|
|
|
|
+ FileInfo cover = new FileInfo();
|
|
|
|
+ cover.setFileType(FileUploadTypeEnum.STUDY_MOVIE.getFileType());
|
|
|
|
+ cover.setFileUrl(coverUrl);
|
|
|
|
+ cover.setRemark("视频封面");
|
|
|
|
+
|
|
|
|
+ FileInfo media = new FileInfo();
|
|
|
|
+ media.setFileType(FileUploadTypeEnum.STUDY_MOVIE.getFileType());
|
|
|
|
+ media.setFileUrl(mediaUrl);
|
|
|
|
+ media.setRemark(FileUploadTypeEnum.STUDY_MOVIE.getInfo());
|
|
|
|
+
|
|
|
|
+ fileInfoService.save(cover);
|
|
|
|
+ fileInfoService.save(media);
|
|
|
|
+
|
|
|
|
+ //保存教学视频详细信息
|
|
|
|
+ TeachingVideoInfo videoInfo = new TeachingVideoInfo();
|
|
|
|
+ videoInfo.setFileId(media.getFileId());
|
|
|
|
+ videoInfo.setCoverFileId(cover.getFileId());
|
|
|
|
+ videoInfo.setTitle(teachingVideoInfo.getTitle());
|
|
|
|
+ videoInfo.setVideoDescribe(teachingVideoInfo.getVideoDescribe());
|
|
|
|
+ videoInfo.setTeachingVideoTypeId(teachingVideoInfo.getTeachingVideoTypeId());
|
|
|
|
+ videoInfo.setVideoDuration(duration);
|
|
|
|
+ videoInfo.setVideoSize(String.valueOf((Integer.valueOf(size) / 1024) / 1024));
|
|
|
|
+ videoInfo.setVideoHeight(height);
|
|
|
|
+ videoInfo.setVideoWidth(width);
|
|
|
|
+ teachingVideoInfoMapper.insert(videoInfo);
|
|
|
|
+
|
|
|
|
+ return Response.success();
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new CustomException("系统错误");
|
|
|
|
+ }
|
|
|
|
|
|
- return null;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 删除教学视频(伪删除)
|
|
* 删除教学视频(伪删除)
|
|
* @param ids
|
|
* @param ids
|