!236 视频列表优化

Merge pull request !236 from 德仔/xzj
This commit is contained in:
德仔 2021-05-07 19:46:17 +08:00 committed by Gitee
commit cf764ae860
13 changed files with 518 additions and 51 deletions

View File

@ -38,14 +38,8 @@ public class SysNutritionalVideoController extends BaseController
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(SysNutritionalVideo sysNutritionalVideo) public TableDataInfo list(SysNutritionalVideo sysNutritionalVideo)
{ {
/*AjaxResult result = AjaxResult.success();
Map<String, Object> map = sysNutritionalVideoService.searchVideo(sysNutritionalVideo.getKey(), sysNutritionalVideo.getShowFlag(), pageNum, pageSize, null);
if(map != null){
result.put("total", map.get("total"));
result.put("rows", map.get("nutritionalVideoList"));
}
return result;*/
startPage(); startPage();
sysNutritionalVideo.setSortType(1);
List<SysNutritionalVideo> list = sysNutritionalVideoService.selectSysNutritionalVideoList(sysNutritionalVideo, true); List<SysNutritionalVideo> list = sysNutritionalVideoService.selectSysNutritionalVideoList(sysNutritionalVideo, true);
return getDataTable(list); return getDataTable(list);
} }
@ -72,7 +66,6 @@ public class SysNutritionalVideoController extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@RequestBody SysNutritionalVideo sysNutritionalVideo) public AjaxResult add(@RequestBody SysNutritionalVideo sysNutritionalVideo)
{ {
sysNutritionalVideo.setShowFlag(1);
return toAjax(sysNutritionalVideoService.insertSysNutritionalVideo(sysNutritionalVideo)); return toAjax(sysNutritionalVideoService.insertSysNutritionalVideo(sysNutritionalVideo));
} }

View File

@ -255,7 +255,7 @@ public class WechatAppletController extends BaseController {
List<String> allUrlList = new ArrayList<>(); List<String> allUrlList = new ArrayList<>();
for (String key : imageName) { for (String key : imageName) {
if (!"bodyImages".equals(key)) { if(!"bodyImages".equals(key)){
allUrlList.addAll(downUrlList.get(key)); allUrlList.addAll(downUrlList.get(key));
allImagesList.addAll(imageUrlMap.get(key)); allImagesList.addAll(imageUrlMap.get(key));
} }
@ -358,13 +358,9 @@ public class WechatAppletController extends BaseController {
*/ */
@GetMapping(value = "/getVideoList") @GetMapping(value = "/getVideoList")
public TableDataInfo getVideoList(SysNutritionalVideo sysNutritionalVideo) { public TableDataInfo getVideoList(SysNutritionalVideo sysNutritionalVideo) {
/* AjaxResult result = AjaxResult.success();
Map<String, Object> map = sysNutritionalVideoService.searchVideo(sysNutritionalVideo.getKey(), 1, pageNum, pageSize, null);
result.put("total", map.get("total"));
result.put("rows", map.get("nutritionalVideoList"));
return result;*/
startPage(); startPage();
sysNutritionalVideo.setShowFlag(1); sysNutritionalVideo.setShowFlag(1);
sysNutritionalVideo.setSortType(2);
List<SysNutritionalVideo> list = sysNutritionalVideoService.selectSysNutritionalVideoList(sysNutritionalVideo, true); List<SysNutritionalVideo> list = sysNutritionalVideoService.selectSysNutritionalVideoList(sysNutritionalVideo, true);
return getDataTable(list); return getDataTable(list);
} }
@ -377,24 +373,38 @@ public class WechatAppletController extends BaseController {
public AjaxResult getVideoDetailById(@RequestParam(value = "videoId") String videoId) { public AjaxResult getVideoDetailById(@RequestParam(value = "videoId") String videoId) {
AjaxResult result = AjaxResult.success(); AjaxResult result = AjaxResult.success();
NutritionalVideoResponse nutritionalVideoResponse = new NutritionalVideoResponse(); NutritionalVideoResponse nutritionalVideoResponse = new NutritionalVideoResponse();
try { try{
GetPlayInfoResponseBody playInfoResponseBody = AliyunVideoUtils.getVideoVisitDetail(videoId); SysNutritionalVideo sysNutritionalVideo = sysNutritionalVideoService.selectSysNutritionalVideByVideoId(videoId);
GetVideoInfoResponseBody videoInfoResponseBody = AliyunVideoUtils.getVideoById(videoId); if(sysNutritionalVideo != null){
List<GetPlayInfoResponseBody.GetPlayInfoResponseBodyPlayInfoListPlayInfo> playList = playInfoResponseBody.playInfoList.playInfo; GetPlayInfoResponseBody playInfoResponseBody = AliyunVideoUtils.getVideoVisitDetail(videoId);
if (playList != null && playList.size() > 0) { List<GetPlayInfoResponseBody.GetPlayInfoResponseBodyPlayInfoListPlayInfo> playList = playInfoResponseBody.playInfoList.playInfo;
nutritionalVideoResponse.setPlayUrl(playList.get(0).getPlayURL()); if(playList != null && playList.size() > 0){
} nutritionalVideoResponse.setPlayUrl(playList.get(0).getPlayURL());
nutritionalVideoResponse.setDescription(videoInfoResponseBody.video.getDescription()); }
nutritionalVideoResponse.setTags(videoInfoResponseBody.video.getTags()); nutritionalVideoResponse.setDescription(sysNutritionalVideo.getDescription());
nutritionalVideoResponse.setTitle(videoInfoResponseBody.video.getTitle()); nutritionalVideoResponse.setTags(sysNutritionalVideo.getTags());
//nutritionalVideoResponse.setCreateTime(sysNutritionalVideo.getCreateTime() == null ? "" : DateUtils.dateTime(sysNutritionalVideo.getCreateTime())); nutritionalVideoResponse.setTitle(sysNutritionalVideo.getTitle());
} catch (Exception e) { nutritionalVideoResponse.setPlayNum(sysNutritionalVideo.getPlayNum());
}
}catch (Exception e){
e.printStackTrace(); e.printStackTrace();
} }
result.put("videoDetail", nutritionalVideoResponse); result.put("videoDetail", nutritionalVideoResponse);
return result; return result;
} }
/**
* 更新播放次数
*/
@GetMapping(value = "/updateVideoPlayNum")
public AjaxResult updateVideoPlayNum(@RequestParam(value = "videoId") String videoId) {
AjaxResult result = AjaxResult.error();
if(sysNutritionalVideoService.updateVideoPlayNum(videoId) > 0){
result = AjaxResult.success();
}
return result;
}
@PostMapping("/login") @PostMapping("/login")
public AjaxResult login(@RequestBody SysWxUserInfo sysWxUserInfo) { public AjaxResult login(@RequestBody SysWxUserInfo sysWxUserInfo) {
if (StringUtils.isEmpty(sysWxUserInfo.getOpenid())) { if (StringUtils.isEmpty(sysWxUserInfo.getOpenid())) {

View File

@ -19,6 +19,9 @@ public class AliyunVideoUtils {
//播放地址日期30天 //播放地址日期30天
public static final Long default_authTimeout = 2592000L; public static final Long default_authTimeout = 2592000L;
//阿里云回收站分类ID
public static final Long default_delete_cateId = 1860L;
public static final String search_field = "VideoId,Title,CoverURL,CateName,Tags,Status,Description,CreationTime"; public static final String search_field = "VideoId,Title,CoverURL,CateName,Tags,Status,Description,CreationTime";
/** /**
@ -154,6 +157,51 @@ public class AliyunVideoUtils {
return client.searchMedia(searchMediaRequest); return client.searchMedia(searchMediaRequest);
} }
/**
* 更新视频消息
* @param videoId 视频ID必须
* @param title
* @param tags
* @param description
* @param cateId
* @return
* @throws Exception
*/
public static String updateVideo(String videoId, String title, String tags, String description, Long cateId) throws Exception{
com.aliyun.vod20170321.Client client = AliyunVideoUtils.createClient();
if(StringUtils.isEmpty(videoId)){
return null;
}
UpdateVideoInfoRequest updateVideoInfoRequest = new UpdateVideoInfoRequest().setVideoId(videoId);
if(StringUtils.isNotEmpty(title)){
updateVideoInfoRequest.setTitle(title);
}
if(StringUtils.isNotEmpty(tags)){
updateVideoInfoRequest.setTags(tags);
}
if(StringUtils.isNotEmpty(description)){
updateVideoInfoRequest.setDescription(description);
}
if(cateId != null && cateId.longValue() > 0){
updateVideoInfoRequest.setCateId(cateId);
}
UpdateVideoInfoResponse updateVideoInfoResponse = client.updateVideoInfo(updateVideoInfoRequest);
if(updateVideoInfoResponse != null){
return updateVideoInfoResponse.body.requestId;
}
return null;
}
/**
* 将视频分类到回收站中
* @param videoId
* @return
* @throws Exception
*/
public static String delVideo(String videoId) throws Exception{
return updateVideo(videoId, null,null,null, default_delete_cateId);
}

View File

@ -65,6 +65,10 @@ public class SysNutritionalVideo extends BaseEntity
private String payLevelName; private String payLevelName;
/** 播放次数默认0 */
@Excel(name = "播放次数默认0")
private Integer playNum;
/** 删除标识0未删除 1已删除默认0 */ /** 删除标识0未删除 1已删除默认0 */
private Integer delFlag; private Integer delFlag;
@ -72,4 +76,7 @@ public class SysNutritionalVideo extends BaseEntity
private String fileName; private String fileName;
private String key; private String key;
//排序方式 1 按照创建时间倒序 2按照优先级时间倒序
private Integer sortType;
} }

View File

@ -33,6 +33,8 @@ public class NutritionalVideoResponse implements Serializable {
//播放链接 //播放链接
public String playUrl; public String playUrl;
//播放量
private Integer playNum;
public String createTime; public String createTime;

View File

@ -75,4 +75,17 @@ public interface SysNutritionalVideoMapper
* @return * @return
*/ */
public int updateWxshowByIds(@Param("wxShow")Integer wxShow, @Param("array") Long[] ids); public int updateWxshowByIds(@Param("wxShow")Integer wxShow, @Param("array") Long[] ids);
/**
* 查询阿里云的视频ID包含已删除的
* @param ids
* @return
*/
public List<String> getVideoIdByIds(@Param("array") Long[] ids);
/**
* 更新视频播放量
* @return
*/
public int updateVideoPlayNum(@Param("videoId")String videoId);
} }

View File

@ -4,6 +4,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import com.stdiet.custom.domain.SysNutritionalVideo; import com.stdiet.custom.domain.SysNutritionalVideo;
import org.apache.ibatis.annotations.Param;
/** /**
* 营养视频Service接口 * 营养视频Service接口
@ -81,4 +82,10 @@ public interface ISysNutritionalVideoService
* @return * @return
*/ */
public int updateWxshowByIds(Integer wxShow, Long[] ids); public int updateWxshowByIds(Integer wxShow, Long[] ids);
/**
* 更新视频播放量
* @return
*/
public int updateVideoPlayNum(String videoId);
} }

View File

@ -11,6 +11,7 @@ import com.stdiet.common.utils.AliyunVideoUtils;
import com.stdiet.common.utils.DateUtils; import com.stdiet.common.utils.DateUtils;
import com.stdiet.common.utils.oss.AliyunOSSUtils; import com.stdiet.common.utils.oss.AliyunOSSUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.stdiet.custom.mapper.SysNutritionalVideoMapper; import com.stdiet.custom.mapper.SysNutritionalVideoMapper;
import com.stdiet.custom.domain.SysNutritionalVideo; import com.stdiet.custom.domain.SysNutritionalVideo;
@ -90,7 +91,23 @@ public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoServi
public int updateSysNutritionalVideo(SysNutritionalVideo sysNutritionalVideo) public int updateSysNutritionalVideo(SysNutritionalVideo sysNutritionalVideo)
{ {
sysNutritionalVideo.setUpdateTime(DateUtils.getNowDate()); sysNutritionalVideo.setUpdateTime(DateUtils.getNowDate());
return sysNutritionalVideoMapper.updateSysNutritionalVideo(sysNutritionalVideo); int row = sysNutritionalVideoMapper.updateSysNutritionalVideo(sysNutritionalVideo);
if(row > 0){
updateAliyunVideo(sysNutritionalVideo.getId());
}
return row;
}
@Async
public void updateAliyunVideo(Long id){
try{
SysNutritionalVideo sysNutritionalVideo = selectSysNutritionalVideoById(id);
if(sysNutritionalVideo != null && sysNutritionalVideo.getVideoId() != null){
AliyunVideoUtils.updateVideo(sysNutritionalVideo.getVideoId(), sysNutritionalVideo.getTitle(), sysNutritionalVideo.getTags(), sysNutritionalVideo.getDescription(), null);
}
}catch (Exception e){
e.printStackTrace();
}
} }
/** /**
@ -102,7 +119,11 @@ public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoServi
@Override @Override
public int deleteSysNutritionalVideoByIds(Long[] ids) public int deleteSysNutritionalVideoByIds(Long[] ids)
{ {
return sysNutritionalVideoMapper.deleteSysNutritionalVideoByIds(ids); int row = sysNutritionalVideoMapper.deleteSysNutritionalVideoByIds(ids);
if(row > 0){
updateAliyunVideoCateId(ids);
}
return row;
} }
/** /**
@ -114,7 +135,12 @@ public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoServi
@Override @Override
public int deleteSysNutritionalVideoById(Long id) public int deleteSysNutritionalVideoById(Long id)
{ {
return sysNutritionalVideoMapper.deleteSysNutritionalVideoById(id); int row = sysNutritionalVideoMapper.deleteSysNutritionalVideoById(id);
if(row > 0){
Long[] ids = {id};
updateAliyunVideoCateId(ids);
}
return row;
} }
/** /**
@ -187,7 +213,33 @@ public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoServi
* @return * @return
*/ */
public int updateWxshowByIds(Integer wxShow, Long[] ids){ public int updateWxshowByIds(Integer wxShow, Long[] ids){
return sysNutritionalVideoMapper. updateWxshowByIds(wxShow, ids); return sysNutritionalVideoMapper.updateWxshowByIds(wxShow, ids);
}
/**
* 将删除的阿里云视频放入回收站
* @param ids
*/
@Async
public void updateAliyunVideoCateId(Long[] ids){
try {
List<String> videoIdList = sysNutritionalVideoMapper.getVideoIdByIds(ids);
if(videoIdList != null && videoIdList.size() > 0){
for (String videoId : videoIdList) {
AliyunVideoUtils.delVideo(videoId);
}
}
}catch (Exception e){
e.printStackTrace();
}
}
/**
* 更新视频播放量
* @return
*/
public int updateVideoPlayNum(String videoId){
return sysNutritionalVideoMapper.updateVideoPlayNum(videoId);
} }
} }

View File

@ -16,6 +16,7 @@
<result property="showFlag" column="show_flag" /> <result property="showFlag" column="show_flag" />
<result property="priorityLevel" column="priority_level" /> <result property="priorityLevel" column="priority_level" />
<result property="payLevel" column="pay_level" /> <result property="payLevel" column="pay_level" />
<result property="playNum" column="play_num" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
@ -27,11 +28,11 @@
</resultMap> </resultMap>
<sql id="selectSysNutritionalVideoVo"> <sql id="selectSysNutritionalVideoVo">
select id, cate_id, video_id, cover_url, title, description, priority_level,pay_level,video_size, tags, show_flag, create_time, create_by, update_time, update_by, del_flag from sys_nutritional_video select id, cate_id, video_id, cover_url, title, description, priority_level,pay_level,play_num,video_size, tags, show_flag, create_time, create_by, update_time, update_by, del_flag from sys_nutritional_video
</sql> </sql>
<select id="selectSysNutritionalVideoList" parameterType="SysNutritionalVideo" resultMap="SysNutritionalVideoResult"> <select id="selectSysNutritionalVideoList" parameterType="SysNutritionalVideo" resultMap="SysNutritionalVideoResult">
select snv.id, snv.cate_id, snv.video_id, snv.cover_url, snv.title, snv.description, snv.priority_level,snv.pay_level,snv.video_size, snv.tags, snv.show_flag, snv.create_time, select snv.id, snv.cate_id, snv.video_id, snv.cover_url, snv.title, snv.description, snv.priority_level,snv.pay_level,snv.play_num,snv.video_size, snv.tags, snv.show_flag, snv.create_time,
pay.dict_label as pay_level_name, svc.cate_name pay.dict_label as pay_level_name, svc.cate_name
from sys_nutritional_video snv from sys_nutritional_video snv
left join (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'video_pay_level') AS pay ON pay.dict_value = snv.pay_level left join (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'video_pay_level') AS pay ON pay.dict_value = snv.pay_level
@ -49,7 +50,12 @@
<if test="key != null and key != ''"> <if test="key != null and key != ''">
and (snv.title like concat('%',#{key},'%') or snv.description like concat('%',#{key},'%')) and (snv.title like concat('%',#{key},'%') or snv.description like concat('%',#{key},'%'))
</if> </if>
order by snv.priority_level DESC,snv.create_time DESC <if test="sortType == null or sortType == 1">
order by snv.create_time DESC
</if>
<if test="sortType != null and sortType == 2">
order by snv.priority_level DESC,snv.create_time DESC
</if>
</select> </select>
<select id="selectSysNutritionalVideoById" parameterType="Long" resultMap="SysNutritionalVideoResult"> <select id="selectSysNutritionalVideoById" parameterType="Long" resultMap="SysNutritionalVideoResult">
@ -69,6 +75,7 @@
<if test="tags != null">tags,</if> <if test="tags != null">tags,</if>
<if test="showFlag != null">show_flag,</if> <if test="showFlag != null">show_flag,</if>
<if test="priorityLevel != null">priority_level,</if> <if test="priorityLevel != null">priority_level,</if>
<if test="playNum != null">play_num,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if> <if test="createBy != null">create_by,</if>
<if test="payLevel != null">pay_level,</if> <if test="payLevel != null">pay_level,</if>
@ -86,6 +93,7 @@
<if test="tags != null">#{tags},</if> <if test="tags != null">#{tags},</if>
<if test="showFlag != null">#{showFlag},</if> <if test="showFlag != null">#{showFlag},</if>
<if test="priorityLevel != null">#{priorityLevel},</if> <if test="priorityLevel != null">#{priorityLevel},</if>
<if test="playNum != null">#{playNum},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if> <if test="createBy != null">#{createBy},</if>
<if test="payLevel != null">#{payLevel},</if> <if test="payLevel != null">#{payLevel},</if>
@ -107,6 +115,7 @@
<if test="tags != null">tags = #{tags},</if> <if test="tags != null">tags = #{tags},</if>
<if test="showFlag != null">show_flag = #{showFlag},</if> <if test="showFlag != null">show_flag = #{showFlag},</if>
<if test="priorityLevel != null">priority_level = #{priorityLevel},</if> <if test="priorityLevel != null">priority_level = #{priorityLevel},</if>
<if test="playNum != null">play_num = #{playNum},</if>
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if> <if test="createBy != null">create_by = #{createBy},</if>
<if test="payLevel != null">pay_level = #{payLevel},</if> <if test="payLevel != null">pay_level = #{payLevel},</if>
@ -139,4 +148,17 @@
</foreach> </foreach>
</update> </update>
<!-- 查询视频的阿里云ID包含已删除的 -->
<select id="getVideoIdByIds" parameterType="String" resultType="String">
select video_id from sys_nutritional_video where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<!-- 更新视频播放量 -->
<update id="updateVideoPlayNum" parameterType="String">
update sys_nutritional_video set play_num = play_num + 1 where video_id = #{videoId} and del_flag = 0
</update>
</mapper> </mapper>

View File

@ -5,7 +5,7 @@
<el-input <el-input
type="textarea" type="textarea"
placeholder="请输入视频标题" placeholder="请输入视频标题"
v-model="videoFrom.title" v-model.trim="videoFrom.title"
maxlength="50" maxlength="50"
rows="1" rows="1"
show-word-limit show-word-limit
@ -15,7 +15,7 @@
<el-input <el-input
type="textarea" type="textarea"
placeholder="请输入视频描述" placeholder="请输入视频描述"
v-model="videoFrom.description" v-model.trim="videoFrom.description"
maxlength="1000" maxlength="1000"
rows="3" rows="3"
show-word-limit show-word-limit
@ -98,7 +98,9 @@
}, },
callback: null, callback: null,
classifyList: [], classifyList: [],
defaultClassify: null,
payVideoLevelList:[], payVideoLevelList:[],
defaultPayLevel: null,
uploadAuth:{ uploadAuth:{
}, },
@ -118,17 +120,23 @@
uploader: null, uploader: null,
statusText: '', statusText: '',
fileType:['mp4','MP4'], fileType:['mp4','MP4'],
uploading: false uploading: false,
} }
}, },
created(){ created(){
getAllClassify().then(response => { /*getAllClassify().then(response => {
if(response.code == 200){ if(response.code == 200){
this.classifyList = response.data; this.classifyList = response.data;
if(response.data != null && response.data.length > 0){
this.defaultClassify = response.data[0].id;
}
} }
}); });*/
this.getDicts("video_pay_level").then((response) => { this.getDicts("video_pay_level").then((response) => {
this.payVideoLevelList = response.data; this.payVideoLevelList = response.data;
if(response.data != null && response.data.length > 0){
this.defaultPayLevel = response.data[0].dictValue;
}
}); });
}, },
@ -136,22 +144,26 @@
UploadFile UploadFile
}, },
methods: { methods: {
showDialog(callback){ showDialog(classifyList, callback){
this.resetVideoFrom(); this.resetVideoFrom();
this.open = true; this.open = true;
this.callback = callback; this.callback = callback;
this.classifyList = classifyList;
if(classifyList != null && classifyList.length > 0){
this.defaultClassify = classifyList[0].id;
}
}, },
handleCoverUrl(url){ handleCoverUrl(url){
this.videoFrom.coverUrl = url; this.videoFrom.coverUrl = url;
}, },
resetVideoFrom(){ resetVideoFrom(){
this.videoFrom = { this.videoFrom = {
cateId: null, cateId: this.defaultClassify ? this.defaultClassify : null,
coverUrl: null, coverUrl: null,
title: null, title: null,
description: null, description: null,
tags: null, tags: null,
payLevel: 0, payLevel: this.defaultPayLevel ? parseInt(this.defaultPayLevel) : null,
videoId: null, videoId: null,
wxShow: false wxShow: false
}; };

View File

@ -3,7 +3,7 @@
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="关键词" prop="title"> <el-form-item label="关键词" prop="title">
<el-input <el-input
v-model="queryParams.key" v-model.trim="queryParams.key"
placeholder="请输入关键词" placeholder="请输入关键词"
clearable clearable
size="small" size="small"
@ -62,6 +62,7 @@
<el-button <el-button
type="primary" type="primary"
size="mini" size="mini"
icon="el-icon-question"
@click="handleAskQuestion" @click="handleAskQuestion"
v-hasPermi="['custom:askQuestion:list']" v-hasPermi="['custom:askQuestion:list']"
>问题解答</el-button> >问题解答</el-button>

View File

@ -3,7 +3,7 @@
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="关键词" prop="key"> <el-form-item label="关键词" prop="key">
<el-input <el-input
v-model="queryParams.key" v-model.trim="queryParams.key"
placeholder="请输入关键词" placeholder="请输入关键词"
clearable clearable
size="small" size="small"
@ -76,6 +76,15 @@
v-hasPermi="['custom:nutritionalVideo:remove']" v-hasPermi="['custom:nutritionalVideo:remove']"
>删除</el-button> >删除</el-button>
</el-col> </el-col>
<el-col :span="1.5">
<el-button
type="primary"
size="mini"
icon="el-icon-menu"
@click="handleVideoClassify"
v-hasPermi="['custom:videoClassify:list']"
>视频分类管理</el-button>
</el-col>
<!-- <!--
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@ -211,6 +220,11 @@
</el-dialog> </el-dialog>
<UploadVideo ref="uploadVideoRef"></UploadVideo> <UploadVideo ref="uploadVideoRef"></UploadVideo>
<!-- 视频分类管理 -->
<el-dialog title="视频分类列表" :visible.sync="videoClassifyOpen" width="800px" append-to-body @closed="getAllVideoClassify();">
<VideoClassify ref="videoClassifyRef"></VideoClassify>
</el-dialog>
</div> </div>
</template> </template>
@ -219,6 +233,7 @@
import {getAllClassify } from "@/api/custom/videoClassify"; import {getAllClassify } from "@/api/custom/videoClassify";
import UploadVideo from "@/components/UploadVideo"; import UploadVideo from "@/components/UploadVideo";
import UploadFile from "@/components/FileUpload/UploadFile"; import UploadFile from "@/components/FileUpload/UploadFile";
import VideoClassify from "../videoClassify";
export default { export default {
name: "NutritionalVideo", name: "NutritionalVideo",
data() { data() {
@ -259,22 +274,21 @@
// //
classifyList:[], classifyList:[],
// //
payVideoLevelList:[] payVideoLevelList:[],
//
videoClassifyOpen:false
}; };
}, },
created() { created() {
this.getList(); this.getList();
getAllClassify().then(response => { this.getAllVideoClassify();
if(response.code == 200){
this.classifyList = response.data;
}
});
this.getDicts("video_pay_level").then((response) => { this.getDicts("video_pay_level").then((response) => {
this.payVideoLevelList = response.data; this.payVideoLevelList = response.data;
}); });
}, },
components: { components: {
UploadVideo,UploadFile UploadVideo,UploadFile,VideoClassify
}, },
methods: { methods: {
/** 查询营养视频列表 */ /** 查询营养视频列表 */
@ -289,6 +303,14 @@
this.loading = false; this.loading = false;
}); });
}, },
//
getAllVideoClassify(){
getAllClassify().then(response => {
if(response.code == 200){
this.classifyList = response.data;
}
});
},
// //
cancel() { cancel() {
this.open = false; this.open = false;
@ -326,10 +348,13 @@
this.multiple = !selection.length this.multiple = !selection.length
}, },
clickUploadVideo(){ clickUploadVideo(){
this.$refs.uploadVideoRef.showDialog(()=>{ this.$refs.uploadVideoRef.showDialog(this.classifyList, ()=>{
this.getList(); this.getList();
}); });
}, },
handleVideoClassify(){
this.videoClassifyOpen = true;
},
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
this.reset(); this.reset();

View File

@ -0,0 +1,275 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<!--<el-form-item label="分类名称" prop="cateName">
<el-input
v-model="queryParams.cateName"
placeholder="请输入分类名称"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="类型标识0全部可看 1客户可看 2额外付费观看" prop="payFlag">
<el-input
v-model="queryParams.payFlag"
placeholder="请输入类型标识0全部可看 1客户可看 2额外付费观看"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>-->
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['custom:videoClassify:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['custom:videoClassify:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['custom:videoClassify:remove']"
>删除</el-button>
</el-col>
<!--<el-col :span="1.5">
<el-button
type="warning"
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['custom:videoClassify:export']"
>导出</el-button>
</el-col>-->
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="videoClassifyList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="分类名称" align="center" prop="cateName" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['custom:videoClassify:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['custom:videoClassify:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改视频分类对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="分类名称" prop="cateName">
<el-input v-model.trim="form.cateName" placeholder="请输入分类名称" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listVideoClassify, getVideoClassify, delVideoClassify, addVideoClassify, updateVideoClassify, exportVideoClassify } from "@/api/custom/videoClassify";
export default {
name: "VideoClassify",
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: false,
//
total: 0,
//
videoClassifyList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
cateName: null,
payFlag: null,
},
//
form: {},
//
rules: {
cateName: [
{ required: true, message: "分类名称不能为空", trigger: "blur" },
],
}
};
},
created() {
this.getList();
},
methods: {
/** 查询视频分类列表 */
getList() {
this.loading = true;
listVideoClassify(this.queryParams).then(response => {
this.videoClassifyList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
cateName: null,
payFlag: null,
createTime: null,
createBy: null,
updateTime: null,
updateBy: null,
delFlag: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加视频分类";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getVideoClassify(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改视频分类";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateVideoClassify(this.form).then(response => {
if (response.code === 200) {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
}
});
} else {
addVideoClassify(this.form).then(response => {
if (response.code === 200) {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
}
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$confirm('是否确认删除视频分类编号为"' + ids + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delVideoClassify(ids);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
}).catch(function() {});
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有视频分类数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return exportVideoClassify(queryParams);
}).then(response => {
this.download(response.msg);
}).catch(function() {});
}
}
};
</script>