视频播放接口
This commit is contained in:
parent
5f3dee08c2
commit
873dddae4f
@ -1,31 +1,104 @@
|
|||||||
package com.stdiet.web.controller.custom;
|
package com.stdiet.web.controller.custom;
|
||||||
|
|
||||||
|
import com.aliyun.vod20170321.models.GetPlayInfoResponseBody;
|
||||||
|
import com.stdiet.common.core.controller.BaseController;
|
||||||
import com.stdiet.common.core.domain.AjaxResult;
|
import com.stdiet.common.core.domain.AjaxResult;
|
||||||
|
import com.stdiet.common.core.page.TableDataInfo;
|
||||||
|
import com.stdiet.common.utils.AliyunVideoUtils;
|
||||||
|
import com.stdiet.common.utils.StringUtils;
|
||||||
|
import com.stdiet.common.utils.oss.AliyunOSSUtils;
|
||||||
|
import com.stdiet.custom.domain.SysNutritionalVideo;
|
||||||
import com.stdiet.custom.domain.SysVideoClassify;
|
import com.stdiet.custom.domain.SysVideoClassify;
|
||||||
|
import com.stdiet.custom.dto.response.NutritionalVideoResponse;
|
||||||
import com.stdiet.custom.dto.response.VideoClassifyResponse;
|
import com.stdiet.custom.dto.response.VideoClassifyResponse;
|
||||||
|
import com.stdiet.custom.service.ISysNutritionalVideoService;
|
||||||
import com.stdiet.custom.service.ISysVideoClassifyService;
|
import com.stdiet.custom.service.ISysVideoClassifyService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/web/video")
|
@RequestMapping("/web/video")
|
||||||
public class VideoWebInterfaceController {
|
public class VideoWebInterfaceController extends BaseController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysVideoClassifyService sysVideoClassifyService;
|
private ISysVideoClassifyService sysVideoClassifyService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysNutritionalVideoService sysNutritionalVideoService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询视频分类目录列表
|
* 查询视频分类目录列表
|
||||||
*/
|
*/
|
||||||
@GetMapping("/getAllClassify")
|
@GetMapping("/getAllClassify")
|
||||||
public AjaxResult getClassifyAndVideo(SysVideoClassify sysVideoClassify)
|
public TableDataInfo getClassifyAndVideo(SysVideoClassify sysVideoClassify)
|
||||||
{
|
{
|
||||||
List<SysVideoClassify> list = sysVideoClassifyService.getAllClassifyAndVideo(0L);
|
//不分页则不需要传pageNum、pageSize参数
|
||||||
return AjaxResult.success(list);
|
startPage();
|
||||||
|
//父级分类ID 0表示主分类
|
||||||
|
sysVideoClassify.setParentId(0L);
|
||||||
|
//客户类型 0 未付费客户 1已付费客户
|
||||||
|
sysVideoClassify.setUserType(1);
|
||||||
|
List<VideoClassifyResponse> list = sysVideoClassifyService.getAllClassifyAndVideo(sysVideoClassify);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据视频videoId获取视频详情以及播放地址
|
||||||
|
* @param videoId 阿里云中对应videoId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/getVideoDetail/{videoId}")
|
||||||
|
public AjaxResult getVideoDetail(@PathVariable("videoId") String videoId)
|
||||||
|
{
|
||||||
|
if(StringUtils.isEmpty(videoId)){
|
||||||
|
return AjaxResult.error("视频加载失败");
|
||||||
|
}
|
||||||
|
SysNutritionalVideo sysNutritionalVideo = sysNutritionalVideoService.selectSysNutritionalVideByVideoId(videoId);
|
||||||
|
if(sysNutritionalVideo == null){
|
||||||
|
return AjaxResult.error("视频加载失败");
|
||||||
|
}
|
||||||
|
NutritionalVideoResponse nutritionalVideoResponse = new NutritionalVideoResponse();
|
||||||
|
try {
|
||||||
|
GetPlayInfoResponseBody playInfoResponseBody = AliyunVideoUtils.getVideoVisitDetail(videoId);
|
||||||
|
List<GetPlayInfoResponseBody.GetPlayInfoResponseBodyPlayInfoListPlayInfo> playList = playInfoResponseBody.playInfoList.playInfo;
|
||||||
|
if (playList != null && playList.size() > 0) {
|
||||||
|
//播放地址
|
||||||
|
nutritionalVideoResponse.setPlayUrl(playList.get(0).getPlayURL());
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
return AjaxResult.error("视频加载失败");
|
||||||
|
}
|
||||||
|
//视频封面URL
|
||||||
|
if (StringUtils.isNotEmpty(sysNutritionalVideo.getCoverUrl())) {
|
||||||
|
nutritionalVideoResponse.setCoverUrl(AliyunOSSUtils.generatePresignedUrl(sysNutritionalVideo.getCoverUrl()));
|
||||||
|
} else {
|
||||||
|
nutritionalVideoResponse.setCoverUrl(AliyunVideoUtils.getVideoCoverUrl(videoId));
|
||||||
|
}
|
||||||
|
//视频描述
|
||||||
|
nutritionalVideoResponse.setDescription(sysNutritionalVideo.getDescription());
|
||||||
|
//视频标题
|
||||||
|
nutritionalVideoResponse.setTitle(sysNutritionalVideo.getTitle());
|
||||||
|
//视频播放量
|
||||||
|
nutritionalVideoResponse.setPlayNum(sysNutritionalVideo.getPlayNum());
|
||||||
|
|
||||||
|
return AjaxResult.success(nutritionalVideoResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新视频播放次数
|
||||||
|
* @param videoId 阿里云中对应videoId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/updateVideoPlayNum")
|
||||||
|
public AjaxResult updateVideoPlayNum(@RequestParam(value = "videoId") String videoId) {
|
||||||
|
if(StringUtils.isEmpty(videoId)){
|
||||||
|
return AjaxResult.error("更新失败");
|
||||||
|
}
|
||||||
|
return toAjax(sysNutritionalVideoService.updateVideoPlayNum(videoId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,9 +37,6 @@ public class SysVideoClassify extends BaseEntity
|
|||||||
/** 删除标识 0未删除 1已删除 */
|
/** 删除标识 0未删除 1已删除 */
|
||||||
private Integer delFlag;
|
private Integer delFlag;
|
||||||
|
|
||||||
//子分类
|
//用户类型 0 普通用户 1付费客户
|
||||||
private List<SysVideoClassify> childrenClassify;
|
private Integer userType;
|
||||||
|
|
||||||
//子视频
|
|
||||||
private List<Map<String, Object>> childrenVideo;
|
|
||||||
}
|
}
|
@ -5,6 +5,7 @@ import java.io.Serializable;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Data
|
||||||
public class VideoClassifyResponse implements Serializable {
|
public class VideoClassifyResponse implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@ -15,41 +16,12 @@ public class VideoClassifyResponse implements Serializable {
|
|||||||
//目录分类名称
|
//目录分类名称
|
||||||
private String cateName;
|
private String cateName;
|
||||||
|
|
||||||
|
//用户类型 0 普通用户 1付费客户
|
||||||
|
private Integer userType;
|
||||||
|
|
||||||
//子分类
|
//子分类
|
||||||
private List<VideoClassifyTwoResponse> childrenClassify;
|
private List<VideoClassifyTwoResponse> childrenClassify;
|
||||||
|
|
||||||
//子视频
|
//子视频
|
||||||
private List<Map<String, Object>> childrenVideo;
|
private List<VideoResponse> childrenVideo;
|
||||||
|
|
||||||
public Long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCateName() {
|
|
||||||
return cateName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCateName(String cateName) {
|
|
||||||
this.cateName = cateName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<VideoClassifyTwoResponse> getChildrenClassify() {
|
|
||||||
return childrenClassify;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setChildrenClassify(List<VideoClassifyTwoResponse> childrenClassify) {
|
|
||||||
this.childrenClassify = childrenClassify;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Map<String, Object>> getChildrenVideo() {
|
|
||||||
return childrenVideo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setChildrenVideo(List<Map<String, Object>> childrenVideo) {
|
|
||||||
this.childrenVideo = childrenVideo;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.stdiet.custom.dto.response;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class VideoResponse implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
//阿里云中对应视频ID
|
||||||
|
private String videoId;
|
||||||
|
|
||||||
|
//视频标题
|
||||||
|
private String title;
|
||||||
|
}
|
@ -71,5 +71,5 @@ public interface SysVideoClassifyMapper
|
|||||||
* @param parentId
|
* @param parentId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<SysVideoClassify> getOneAllClassifyAndVideo(Long parentId);
|
public List<VideoClassifyResponse> getOneAllClassifyAndVideo(SysVideoClassify sysVideoClassify);
|
||||||
}
|
}
|
@ -71,5 +71,5 @@ public interface ISysVideoClassifyService
|
|||||||
*
|
*
|
||||||
* @return 视频分类集合
|
* @return 视频分类集合
|
||||||
*/
|
*/
|
||||||
public List<SysVideoClassify> getAllClassifyAndVideo(Long parentId);
|
public List<VideoClassifyResponse> getAllClassifyAndVideo(SysVideoClassify sysVideoClassify);
|
||||||
}
|
}
|
@ -120,7 +120,7 @@ public class SysVideoClassifyServiceImpl implements ISysVideoClassifyService
|
|||||||
* @param sysVideoClassify 视频分类
|
* @param sysVideoClassify 视频分类
|
||||||
* @return 视频分类集合
|
* @return 视频分类集合
|
||||||
*/
|
*/
|
||||||
public List<SysVideoClassify> getAllClassifyAndVideo(Long parentId){
|
public List<VideoClassifyResponse> getAllClassifyAndVideo(SysVideoClassify sysVideoClassify){
|
||||||
return sysVideoClassifyMapper.getOneAllClassifyAndVideo(parentId);
|
return sysVideoClassifyMapper.getOneAllClassifyAndVideo(sysVideoClassify);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -99,53 +99,64 @@
|
|||||||
order by order_num asc,id asc
|
order by order_num asc,id asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<resultMap type="SysVideoClassify" id="VideoClassifyOneResult">
|
<resultMap type="com.stdiet.custom.dto.response.VideoClassifyResponse" id="VideoClassifyOneResult">
|
||||||
<result property="id" column="id" />
|
<result property="id" column="id" />
|
||||||
<result property="cateName" column="cate_name" />
|
<result property="cateName" column="cate_name" />
|
||||||
|
<result property="userType" column="userType"></result>
|
||||||
<!-- 查询子分类 -->
|
<!-- 查询子分类 -->
|
||||||
<!--<association property="childrenClassify" column="id" select="getTwoAllClassifyAndVideo"/>-->
|
<association property="childrenClassify" column="{userType=userType,id=id}" select="getTwoAllClassifyAndVideo"/>
|
||||||
<!-- 查询子视频 -->
|
<!-- 查询子视频 -->
|
||||||
<!--<association property="childrenVideo" column="id" select="getAllVideoByClassify"/>-->
|
<association property="childrenVideo" column="{userType=userType,id=id}" select="getAllVideoByClassify"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<resultMap type="SysVideoClassify" id="VideoClassifyTwoResult">
|
<resultMap type="com.stdiet.custom.dto.response.VideoClassifyResponse" id="VideoClassifyTwoResult">
|
||||||
<result property="id" column="id" />
|
<result property="id" column="id" />
|
||||||
<result property="cateName" column="cate_name" />
|
<result property="cateName" column="cate_name" />
|
||||||
|
<result property="userType" column="userType"></result>
|
||||||
<!-- 查询子分类 -->
|
<!-- 查询子分类 -->
|
||||||
<!--<association property="childrenClassify" column="id" select="getThreeAllClassifyAndVideo"/>-->
|
<association property="childrenClassify" column="{userType=userType,id=id}" select="getThreeAllClassifyAndVideo"/>
|
||||||
<!-- 查询子视频 -->
|
<!-- 查询子视频 -->
|
||||||
<!--<association property="childrenVideo" column="id" select="getAllVideoByClassify"/>-->
|
<association property="childrenVideo" column="{userType=userType,id=id}" select="getAllVideoByClassify"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<resultMap type="com.stdiet.custom.dto.response.VideoClassifyThreeResponse" id="VideoClassifyThreeResult">
|
<resultMap type="com.stdiet.custom.dto.response.VideoClassifyResponse" id="VideoClassifyThreeResult">
|
||||||
<result property="id" column="id" />
|
<result property="id" column="id" />
|
||||||
<result property="cateName" column="cate_name" />
|
<result property="cateName" column="cate_name" />
|
||||||
|
<result property="userType" column="userType" ></result>
|
||||||
<!-- 查询子视频 -->
|
<!-- 查询子视频 -->
|
||||||
<association property="childrenVideo" column="id" select="getAllVideoByClassify"/>
|
<association property="childrenVideo" column="{userType=userType,id=id}" select="getAllVideoByClassify"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<select id="getOneAllClassifyAndVideo" resultMap="VideoClassifyOneResult" parameterType="SysVideoClassify">
|
<select id="getOneAllClassifyAndVideo" resultMap="VideoClassifyOneResult" parameterType="SysVideoClassify">
|
||||||
select id, cate_name from sys_video_classify
|
select id, cate_name, #{userType} as userType from sys_video_classify
|
||||||
left join sys_video_classify
|
where del_flag = 0 and parent_id = #{parentId} and 1 = 1
|
||||||
where del_flag = 0 and parent_id = #{parentId}
|
|
||||||
order by order_num asc,id asc
|
order by order_num asc,id asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getTwoAllClassifyAndVideo" resultMap="VideoClassifyTwoResult" parameterType="Long">
|
<select id="getTwoAllClassifyAndVideo" resultMap="VideoClassifyTwoResult">
|
||||||
select id, cate_name from sys_video_classify
|
select id, cate_name,#{userType} as userType from sys_video_classify
|
||||||
where del_flag = 0 and parent_id = #{id}
|
where del_flag = 0 and parent_id = #{id} and 2 = 2
|
||||||
order by order_num asc,id asc
|
order by order_num asc,id asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getThreeAllClassifyAndVideo" resultMap="VideoClassifyThreeResult" parameterType="Long">
|
<select id="getThreeAllClassifyAndVideo" resultMap="VideoClassifyThreeResult">
|
||||||
select id, cate_name from sys_video_classify
|
select id, cate_name,#{userType} as userType from sys_video_classify
|
||||||
where del_flag = 0 and parent_id = #{id}
|
where del_flag = 0 and parent_id = #{id} and 3 = 3
|
||||||
order by order_num asc,id asc
|
order by order_num asc,id asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getAllVideoByClassify" resultType="Map" parameterType="Long">
|
<select id="getAllVideoByClassify" resultType="com.stdiet.custom.dto.response.VideoResponse">
|
||||||
select snv.video_id as videoId, snv.cover_url as coverUrl, snv.title, snv.description
|
select snv.video_id as videoId, snv.title
|
||||||
from sys_nutritional_video snv where cate_id = #{id} and del_flag = 0 and show_flag = 1
|
from sys_nutritional_video snv where cate_id = #{id} and del_flag = 0 and show_flag = 1
|
||||||
|
<if test="userType != null">
|
||||||
|
<if test="userType == 0">
|
||||||
|
and pay_level = 0
|
||||||
|
</if>
|
||||||
|
<if test="userType == 1">
|
||||||
|
and (pay_level = 0 or pay_level = 1)
|
||||||
|
</if>
|
||||||
|
</if>
|
||||||
|
order by priority_level desc,id asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
Loading…
x
Reference in New Issue
Block a user