!286 视频分类查询视频优化

Merge pull request !286 from 德仔/xzj
This commit is contained in:
德仔 2021-06-16 10:23:35 +08:00 committed by Gitee
commit e72deee8fb
20 changed files with 653 additions and 60 deletions

View File

@ -3,14 +3,7 @@ package com.stdiet.web.controller.custom;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.stdiet.common.annotation.Log;
import com.stdiet.common.core.controller.BaseController;
import com.stdiet.common.core.domain.AjaxResult;
@ -40,7 +33,8 @@ public class SysVideoClassifyController extends BaseController
@GetMapping("/list")
public TableDataInfo list(SysVideoClassify sysVideoClassify)
{
startPage();
//startPage();
//sysVideoClassify.setParentId(0L);
List<SysVideoClassify> list = sysVideoClassifyService.selectSysVideoClassifyList(sysVideoClassify);
return getDataTable(list);
}
@ -105,9 +99,9 @@ public class SysVideoClassifyController extends BaseController
* 查询视频分类列表
*/
@GetMapping("/getAllClassify")
public AjaxResult getAllClassify()
public AjaxResult getAllClassify(SysVideoClassify sysVideoClassify)
{
List<SysVideoClassify> list = sysVideoClassifyService.getAllClassify();
List<SysVideoClassify> list = sysVideoClassifyService.getAllClassify(sysVideoClassify);
return AjaxResult.success(list);
}
}

View File

@ -0,0 +1,104 @@
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.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.dto.response.NutritionalVideoResponse;
import com.stdiet.custom.dto.response.VideoClassifyResponse;
import com.stdiet.custom.service.ISysNutritionalVideoService;
import com.stdiet.custom.service.ISysVideoClassifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/web/video")
public class VideoWebInterfaceController extends BaseController {
@Autowired
private ISysVideoClassifyService sysVideoClassifyService;
@Autowired
private ISysNutritionalVideoService sysNutritionalVideoService;
/**
* 查询视频分类目录列表
*/
@GetMapping("/getAllClassify")
public TableDataInfo getClassifyAndVideo(SysVideoClassify sysVideoClassify)
{
//不分页则不需要传pageNumpageSize参数
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));
}
}

View File

@ -714,7 +714,9 @@ public class WechatAppletController extends BaseController {
*/
@GetMapping("/getVideoClassify")
public AjaxResult getVideoClassify(@RequestParam("openid")String openid) {
List<SysVideoClassify> list = sysVideoClassifyService.selectSysVideoClassifyList(new SysVideoClassify());
SysVideoClassify param = new SysVideoClassify();
param.setParentId(0L);
List<SysVideoClassify> list = sysVideoClassifyService.getAllClassify(param);
List<List<Map<String,Object>>> result = new ArrayList<>();
int groupCount = 3;
SysVideoClassify all = new SysVideoClassify();

View File

@ -1,11 +1,13 @@
package com.stdiet.custom.domain;
import com.stdiet.custom.dto.response.VideoClassifyTwoResponse;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.stdiet.common.annotation.Excel;
import com.stdiet.common.core.domain.BaseEntity;
import java.util.List;
import java.util.Map;
/**
* 视频分类对象 sys_video_classify
*
@ -24,10 +26,17 @@ public class SysVideoClassify extends BaseEntity
@Excel(name = "分类名称")
private String cateName;
private Long parentId;
private Integer orderNum;
/** 类型标识0全部可看 1客户可看 2额外付费观看 */
@Excel(name = "类型标识0全部可看 1客户可看 2额外付费观看")
private Integer payFlag;
/** 删除标识 0未删除 1已删除 */
private Integer delFlag;
//用户类型 0 普通用户 1付费客户
private Integer userType;
}

View File

@ -0,0 +1,27 @@
package com.stdiet.custom.dto.response;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
@Data
public class VideoClassifyResponse implements Serializable {
private static final long serialVersionUID = 1L;
//目录分类ID
private Long id;
//目录分类名称
private String cateName;
//用户类型 0 普通用户 1付费客户
private Integer userType;
//子分类
private List<VideoClassifyTwoResponse> childrenClassify;
//子视频
private List<VideoResponse> childrenVideo;
}

View File

@ -0,0 +1,45 @@
package com.stdiet.custom.dto.response;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
public class VideoClassifyThreeResponse implements Serializable {
private static final long serialVersionUID = 1L;
//目录分类ID
private Long id;
//目录分类名称
private String cateName;
//子视频
private List<Map<String, Object>> 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<Map<String, Object>> getChildrenVideo() {
return childrenVideo;
}
public void setChildrenVideo(List<Map<String, Object>> childrenVideo) {
this.childrenVideo = childrenVideo;
}
}

View File

@ -0,0 +1,56 @@
package com.stdiet.custom.dto.response;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
public class VideoClassifyTwoResponse implements Serializable {
private static final long serialVersionUID = 1L;
//目录分类ID
private Long id;
//目录分类名称
private String cateName;
//子分类
private List<VideoClassifyThreeResponse> childrenClassify;
//子视频
private List<Map<String, Object>> 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<VideoClassifyThreeResponse> getChildrenClassify() {
return childrenClassify;
}
public void setChildrenClassify(List<VideoClassifyThreeResponse> childrenClassify) {
this.childrenClassify = childrenClassify;
}
public List<Map<String, Object>> getChildrenVideo() {
return childrenVideo;
}
public void setChildrenVideo(List<Map<String, Object>> childrenVideo) {
this.childrenVideo = childrenVideo;
}
}

View File

@ -0,0 +1,61 @@
package com.stdiet.custom.dto.response;
import com.stdiet.common.utils.AliyunVideoUtils;
import com.stdiet.common.utils.StringUtils;
import com.stdiet.common.utils.oss.AliyunOSSUtils;
import lombok.Data;
import java.io.Serializable;
public class VideoResponse implements Serializable {
private static final long serialVersionUID = 1L;
//阿里云中对应视频ID
private String videoId;
//视频标题
private String title;
//视频封面
private String coverUrl;
//播放次数
private Integer playNum;
public String getVideoId() {
return videoId;
}
public void setVideoId(String videoId) {
this.videoId = videoId;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getCoverUrl() {
if (StringUtils.isNotEmpty(this.coverUrl)) {
return AliyunOSSUtils.generatePresignedUrl(this.coverUrl);
} else {
return AliyunVideoUtils.getVideoCoverUrl(this.videoId);
}
}
public void setCoverUrl(String coverUrl) {
this.coverUrl = coverUrl;
}
public Integer getPlayNum() {
return playNum;
}
public void setPlayNum(Integer playNum) {
this.playNum = playNum;
}
}

View File

@ -2,6 +2,7 @@ package com.stdiet.custom.mapper;
import java.util.List;
import com.stdiet.custom.domain.SysVideoClassify;
import com.stdiet.custom.dto.response.VideoClassifyResponse;
/**
* 视频分类Mapper接口
@ -63,5 +64,12 @@ public interface SysVideoClassifyMapper
* 获取所有类别
* @return
*/
public List<SysVideoClassify> getAllClassify();
public List<SysVideoClassify> getAllClassify(SysVideoClassify sysVideoClassify);
/**
* 根据父级ID获取下面子分类以及视频
* @param parentId
* @return
*/
public List<VideoClassifyResponse> getOneAllClassifyAndVideo(SysVideoClassify sysVideoClassify);
}

View File

@ -4,6 +4,7 @@ import java.util.List;
import java.util.Map;
import com.stdiet.custom.domain.SysNutritionalVideo;
import com.stdiet.custom.domain.SysVideoClassify;
import org.apache.ibatis.annotations.Param;
/**

View File

@ -2,6 +2,7 @@ package com.stdiet.custom.service;
import java.util.List;
import com.stdiet.custom.domain.SysVideoClassify;
import com.stdiet.custom.dto.response.VideoClassifyResponse;
/**
* 视频分类Service接口
@ -63,5 +64,12 @@ public interface ISysVideoClassifyService
* 获取所有类别
* @return
*/
public List<SysVideoClassify> getAllClassify();
public List<SysVideoClassify> getAllClassify(SysVideoClassify sysVideoClassify);
/**
* 按分类层级分类返回视频目录列表
*
* @return 视频分类集合
*/
public List<VideoClassifyResponse> getAllClassifyAndVideo(SysVideoClassify sysVideoClassify);
}

View File

@ -378,7 +378,7 @@ public class SysOrderServiceImpl implements ISysOrderService {
LocalDate newStartTime = null;
//判断是否提成单拆分单中的副单体验单,定金单
if(sysOrder.getStartTime() == null || sysOrder.getAfterSaleCommissOrder().intValue() == 1 || sysOrder.getMainOrderId().intValue() != 0 ||
"2".equals(sysOrder.getOrderType()) || "1".equals(sysOrder.getOrderMoneyType())){
"2".equals(sysOrder.getOrderType()) || !isNeedByOrderMoneyType(sysOrder)){
continue;
}
//判断前一个订单的结束时间是否大于第二个订单的
@ -404,6 +404,21 @@ public class SysOrderServiceImpl implements ISysOrderService {
return row;
}
//定金单或尾款单是否需要生成食谱计划2021-01-12修改为6月11日之后成交的订单只生成定金单计划
private boolean isNeedByOrderMoneyType(SysOrder sysOrder){
if("0".equals(sysOrder.getOrderMoneyType())){
return true;
}else{
//成交时间
LocalDate orderDate = DateUtils.dateToLocalDate(sysOrder.getOrderTime());
if(ChronoUnit.DAYS.between(SysRecipesPlanServiceImpl.newVersionPlanStartDate, orderDate) >= 0){
return "1".equals(sysOrder.getOrderMoneyType());
}else{
return "2".equals(sysOrder.getOrderMoneyType());
}
}
}
/**
* 给对象SysOrder对象设置服务到期时间
*

View File

@ -44,6 +44,9 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService {
@Autowired
private SysRecipesMapper sysRecipesMapper;
//2021-06-11之后大于等于成交的订单只生成定金单食谱计划不生成尾款食谱计划之前成交的订单还是保持之前逻辑
public static final LocalDate newVersionPlanStartDate = DateUtils.stringToLocalDate("2021-06-11", "yyyy-MM-dd");
/**
* 查询食谱计划
*
@ -172,7 +175,7 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService {
//判断是否提成单拆分单中的副单体验单,定金单
if (sysOrder.getAfterSaleCommissOrder().intValue() == 1 || sysOrder.getMainOrderId().intValue() != 0 ||
// "2".equals(sysOrder.getOrderType()) || // 体验单也需要生成计划 2021.05.29
"1".equals(sysOrder.getOrderMoneyType()) || sysOrder.getCounted() == 1) {
!isNeedByOrderMoneyType(sysOrder) || sysOrder.getCounted() == 1) {
System.out.println("---------------------" + sysOrder.getOrderId() + "不生成食谱------------------------");
continue;
}
@ -208,6 +211,21 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService {
}
}
//定金单或尾款单是否需要生成食谱计划2021-01-12修改为6月11日之后成交的订单只生成定金单计划
private boolean isNeedByOrderMoneyType(SysOrder sysOrder){
if("0".equals(sysOrder.getOrderMoneyType())){
return true;
}else{
//成交时间
LocalDate orderDate = DateUtils.dateToLocalDate(sysOrder.getOrderTime());
if(ChronoUnit.DAYS.between(newVersionPlanStartDate, orderDate) >= 0){
return "1".equals(sysOrder.getOrderMoneyType());
}else{
return "2".equals(sysOrder.getOrderMoneyType());
}
}
}
/**
* 查询食谱计划中对应食谱存在天数缺失的食谱计划食谱计划发生变化时可能会导致sys_customer_daily_menu表中天数缺失需要查询出来进行补充
* @param cusId 客户ID

View File

@ -2,6 +2,8 @@ package com.stdiet.custom.service.impl;
import java.util.List;
import com.stdiet.common.utils.DateUtils;
import com.stdiet.custom.dto.response.VideoClassifyResponse;
import com.stdiet.custom.mapper.SysNutritionalVideoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.stdiet.custom.mapper.SysVideoClassifyMapper;
@ -20,6 +22,9 @@ public class SysVideoClassifyServiceImpl implements ISysVideoClassifyService
@Autowired
private SysVideoClassifyMapper sysVideoClassifyMapper;
@Autowired
private SysNutritionalVideoMapper sysNutritionalVideoMapper;
/**
* 查询视频分类
*
@ -94,12 +99,28 @@ public class SysVideoClassifyServiceImpl implements ISysVideoClassifyService
return sysVideoClassifyMapper.deleteSysVideoClassifyById(id);
}
private boolean delChildrenClassify(Long id){
//判断分类下是否存在视频存在视频不能删除
return true;
}
/**
* 获取所有类别
* @return
*/
@Override
public List<SysVideoClassify> getAllClassify(){
return sysVideoClassifyMapper.getAllClassify();
public List<SysVideoClassify> getAllClassify(SysVideoClassify sysVideoClassify){
return sysVideoClassifyMapper.getAllClassify(sysVideoClassify);
}
/**
* 按分类层级分类返回视频目录列表
*
* @param sysVideoClassify 视频分类
* @return 视频分类集合
*/
public List<VideoClassifyResponse> getAllClassifyAndVideo(SysVideoClassify sysVideoClassify){
return sysVideoClassifyMapper.getOneAllClassifyAndVideo(sysVideoClassify);
}
}

View File

@ -42,7 +42,11 @@
and snv.show_flag = #{showFlag}
</if>
<if test="cateId != null">
and snv.cate_id = #{cateId}
and snv.cate_id in (
select id from sys_video_classify where del_flag = 0
and (id = #{cateId} or id in (select s.id from sys_video_classify s where s.parent_id = #{cateId} and s.del_flag = 0)
or id in (select ss.id from sys_video_classify ss where ss.del_flag = 0 and ss.parent_id in (select a.id from sys_video_classify a where a.parent_id = #{cateId} and a.del_flag = 0 )))
)
</if>
<if test="payLevel != null">
and snv.pay_level = #{payLevel}

View File

@ -7,6 +7,8 @@
<resultMap type="SysVideoClassify" id="SysVideoClassifyResult">
<result property="id" column="id" />
<result property="cateName" column="cate_name" />
<result property="parentId" column="parent_id" />
<result property="orderNum" column="order_num" />
<result property="payFlag" column="pay_flag" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
@ -16,12 +18,16 @@
</resultMap>
<sql id="selectSysVideoClassifyVo">
select id, cate_name, pay_flag, create_time, create_by, update_time, update_by, del_flag from sys_video_classify
select id, cate_name, parent_id, order_num, pay_flag, create_time, create_by, update_time, update_by, del_flag from sys_video_classify
</sql>
<select id="selectSysVideoClassifyList" parameterType="SysVideoClassify" resultMap="SysVideoClassifyResult">
<include refid="selectSysVideoClassifyVo"/>
select id, cate_name, parent_id, order_num, pay_flag, create_time from sys_video_classify
where del_flag = 0
<if test="parentId != null">
and parent_id = #{parentId}
</if>
order by order_num asc,id asc
</select>
<select id="selectSysVideoClassifyById" parameterType="Long" resultMap="SysVideoClassifyResult">
@ -34,6 +40,8 @@
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="cateName != null">cate_name,</if>
<if test="parentId != null">parent_id,</if>
<if test="orderNum != null">order_num,</if>
<if test="payFlag != null">pay_flag,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
@ -44,6 +52,8 @@
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="cateName != null">#{cateName},</if>
<if test="parentId != null">#{parentId},</if>
<if test="orderNum != null">#{orderNum},</if>
<if test="payFlag != null">#{payFlag},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
@ -57,6 +67,8 @@
update sys_video_classify
<trim prefix="SET" suffixOverrides=",">
<if test="cateName != null">cate_name = #{cateName},</if>
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="orderNum != null">order_num = #{orderNum},</if>
<if test="payFlag != null">pay_flag = #{payFlag},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
@ -78,8 +90,73 @@
</foreach>
</update>
<select id="getAllClassify" resultMap="SysVideoClassifyResult">
select id,cate_name from sys_video_classify where del_flag = 0
<select id="getAllClassify" resultMap="SysVideoClassifyResult" parameterType="SysVideoClassify">
select id, cate_name, parent_id, order_num, pay_flag, create_time, create_by, update_time, update_by, del_flag from sys_video_classify
where del_flag = 0
<if test="parentId != null">
and parent_id = #{parentId}
</if>
order by order_num asc,id asc
</select>
<resultMap type="com.stdiet.custom.dto.response.VideoClassifyResponse" id="VideoClassifyOneResult">
<result property="id" column="id" />
<result property="cateName" column="cate_name" />
<result property="userType" column="userType"></result>
<!-- 查询子分类 -->
<association property="childrenClassify" column="{userType=userType,id=id}" select="getTwoAllClassifyAndVideo"/>
<!-- 查询子视频 -->
<association property="childrenVideo" column="{userType=userType,id=id}" select="getAllVideoByClassify"/>
</resultMap>
<resultMap type="com.stdiet.custom.dto.response.VideoClassifyResponse" id="VideoClassifyTwoResult">
<result property="id" column="id" />
<result property="cateName" column="cate_name" />
<result property="userType" column="userType"></result>
<!-- 查询子分类 -->
<association property="childrenClassify" column="{userType=userType,id=id}" select="getThreeAllClassifyAndVideo"/>
<!-- 查询子视频 -->
<association property="childrenVideo" column="{userType=userType,id=id}" select="getAllVideoByClassify"/>
</resultMap>
<resultMap type="com.stdiet.custom.dto.response.VideoClassifyResponse" id="VideoClassifyThreeResult">
<result property="id" column="id" />
<result property="cateName" column="cate_name" />
<result property="userType" column="userType" ></result>
<!-- 查询子视频 -->
<association property="childrenVideo" column="{userType=userType,id=id}" select="getAllVideoByClassify"/>
</resultMap>
<select id="getOneAllClassifyAndVideo" resultMap="VideoClassifyOneResult" parameterType="SysVideoClassify">
select id, cate_name, #{userType} as userType from sys_video_classify
where del_flag = 0 and parent_id = #{parentId} and 1 = 1
order by order_num asc,id asc
</select>
<select id="getTwoAllClassifyAndVideo" resultMap="VideoClassifyTwoResult">
select id, cate_name,#{userType} as userType from sys_video_classify
where del_flag = 0 and parent_id = #{id} and 2 = 2
order by order_num asc,id asc
</select>
<select id="getThreeAllClassifyAndVideo" resultMap="VideoClassifyThreeResult">
select id, cate_name,#{userType} as userType from sys_video_classify
where del_flag = 0 and parent_id = #{id} and 3 = 3
order by order_num asc,id asc
</select>
<select id="getAllVideoByClassify" resultType="com.stdiet.custom.dto.response.VideoResponse">
select snv.video_id as videoId, snv.title, snv.cover_url as coverUrl,snv.play_num as playNum
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>
</mapper>

View File

@ -106,7 +106,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
"/wap/**",
"/investigate/**",
"/common/customerUploadFile",
"/custom/nutritionQuestion/regenerateNutritionQuestionIndex"
"/custom/nutritionQuestion/regenerateNutritionQuestionIndex",
"/web/**"
).anonymous()
.antMatchers(
HttpMethod.GET,

View File

@ -26,15 +26,14 @@
<UploadFile ref="uploadFile" :prefix="'videoCover'" @callbackMethod="handleCoverUrl" :tips="'视频未传封面图片时,会主动截取封面,但会存在延迟,请勿直接发布到小程序'"></UploadFile>
</el-form-item>
<div style="display:flex">
<el-form-item label="视频类别" prop="cateId">
<el-select v-model="videoFrom.cateId" clearable filterable placeholder="请选择类别">
<el-option
v-for="classify in classifyList"
:key="classify.id"
:label="classify.cateName"
:value="classify.id"
<el-form-item label="视频类别" prop="cateId" style="width:300px">
<treeselect
v-model="videoFrom.cateId"
:options="classifyList"
:normalizer="normalizer"
:show-count="true"
placeholder="选择分类"
/>
</el-select>
</el-form-item>
<el-form-item label="视频权限" prop="payLevel" style="margin-left:40px">
<el-select v-model="videoFrom.payLevel" clearable filterable placeholder="请选择权限">
@ -78,6 +77,9 @@
import {getUploadVideoAuth,addNutritionalVideo } from "@/api/custom/nutritionalVideo";
import {getAllClassify } from "@/api/custom/videoClassify";
import UploadFile from "@/components/FileUpload/UploadFile";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import IconSelect from "@/components/IconSelect";
export default {
name: "UploadVideo",
data () {
@ -140,7 +142,7 @@
},
components: {
UploadFile
UploadFile,Treeselect, IconSelect
},
methods: {
showDialog(classifyList, callback){
@ -150,7 +152,8 @@
this.resetVideoFrom();
this.open = true;
this.callback = callback;
this.classifyList = classifyList;
this.dealClassify(classifyList);
//this.classifyList = classifyList;
},
handleCoverUrl(url){
this.videoFrom.coverUrl = url;
@ -181,6 +184,23 @@
},
submitVideoForm(){
},
/** 转换菜单数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children;
}
return {
id: node.id,
label: node.cateName,
children: node.children
};
},
dealClassify(data){
this.classifyList = [];
const classify = { id: 0, cateName: '主分类', children: [] };
classify.children = this.handleTree(data, "id");
this.classifyList.push(classify);
},
cancel(){
if(this.uploading){
@ -211,6 +231,14 @@
this.authProgress = 0
this.statusText = ""
}**/
//
if(this.videoFrom.cateId == 0){
this.$message({
message: "视频分类不能选择主分类",
type: "warning",
});
return;
}
this.videoFrom.fileName = this.file.name;
if(this.videoFrom.fileName == null || this.videoFrom.fileName.length == 0 || this.videoFrom.fileName.lastIndexOf(".") == -1){
this.$message({

View File

@ -21,14 +21,22 @@
</el-select>
</el-form-item>
<el-form-item label="视频类别" prop="cateId">
<el-select v-model="queryParams.cateId" clearable filterable placeholder="请选择类别">
<!-- <el-select v-model="queryParams.cateId" clearable filterable placeholder="请选择类别">
<el-option
v-for="classify in classifyList"
:key="classify.id"
:label="classify.cateName"
:value="classify.id"
/>
</el-select>
</el-select>-->
<treeselect
v-model="queryParams.cateId"
:options="classifyList"
:normalizer="normalizer"
:show-count="true"
placeholder="选择分类"
style="width:200px"
/>
</el-form-item>
<el-form-item label="视频权限" prop="payLevel">
<el-select v-model="queryParams.payLevel" clearable filterable placeholder="请选择权限">
@ -243,7 +251,9 @@
<!-- 视频分类管理 -->
<el-dialog title="视频分类列表" :visible.sync="videoClassifyOpen" width="800px" append-to-body @closed="getAllVideoClassify();">
<div style="height: 500px; overflow: auto">
<VideoClassify ref="videoClassifyRef"></VideoClassify>
</div>
</el-dialog>
</div>
</template>
@ -255,6 +265,9 @@
import UploadFile from "@/components/FileUpload/UploadFile";
import VideoClassify from "../videoClassify";
import AutoHideMessage from "@/components/AutoHideMessage";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import IconSelect from "@/components/IconSelect";
export default {
name: "NutritionalVideo",
data() {
@ -318,7 +331,7 @@
});
},
components: {
UploadVideo,UploadFile,VideoClassify,AutoHideMessage
UploadVideo,UploadFile,VideoClassify,AutoHideMessage,Treeselect, IconSelect
},
methods: {
/** 查询营养视频列表 */
@ -337,7 +350,10 @@
getAllVideoClassify(){
getAllClassify().then(response => {
if(response.code == 200){
this.classifyList = response.data;
this.classifyList = [];
const classify = { id: 0, cateName: '主分类', children: [] };
classify.children = this.handleTree(response.data, "id");
this.classifyList.push(classify);
}
});
},
@ -411,6 +427,17 @@
}
});
},
/** 转换菜单数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children;
}
return {
id: node.id,
label: node.cateName,
children: node.children
};
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {

View File

@ -35,7 +35,7 @@
v-hasPermi="['custom:videoClassify:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<!--<el-col :span="1.5">
<el-button
type="success"
icon="el-icon-edit"
@ -54,7 +54,7 @@
@click="handleDelete"
v-hasPermi="['custom:videoClassify:remove']"
>删除</el-button>
</el-col>
</el-col>-->
<!--<el-col :span="1.5">
<el-button
type="warning"
@ -67,11 +67,29 @@
<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
v-loading="loading"
:data="videoClassifyList"
row-key="id"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
>
<el-table-column label="分类名称" prop="cateName" :show-overflow-tooltip="true"/>
<el-table-column label="显示排序" prop="orderNum" align="center"/>
<el-table-column label="创建时间" prop="createTime" align="center">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
icon="el-icon-plus"
type="text"
size="mini"
v-if="threeLevelClassify.indexOf(scope.row.id) == -1"
@click="handleAdd(scope.row)"
v-hasPermi="['custom:videoClassify:add']"
>新增</el-button>
<el-button
size="mini"
type="text"
@ -90,21 +108,34 @@
</el-table-column>
</el-table>
<pagination
<!--<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="上级分类">
<treeselect
v-model="form.parentId"
:options="classifyOptions"
:normalizer="normalizer"
:show-count="true"
placeholder="选择上级分类"
/>
</el-form-item>
<el-form-item label="分类名称" prop="cateName">
<el-input v-model.trim="form.cateName" placeholder="请输入分类名称" />
</el-form-item>
<el-form-item label="显示排序" prop="orderNum">
<el-input-number v-model="form.orderNum" controls-position="right" :min="0" />
</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>
@ -114,8 +145,10 @@
</template>
<script>
import { listVideoClassify, getVideoClassify, delVideoClassify, addVideoClassify, updateVideoClassify, exportVideoClassify } from "@/api/custom/videoClassify";
import { listVideoClassify, getVideoClassify, delVideoClassify, addVideoClassify, updateVideoClassify, exportVideoClassify,getAllClassify } from "@/api/custom/videoClassify";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import IconSelect from "@/components/IconSelect";
export default {
name: "VideoClassify",
data() {
@ -152,18 +185,23 @@
cateName: [
{ required: true, message: "分类名称不能为空", trigger: "blur" },
],
}
},
classifyOptions:[],
//ID
threeLevelClassify:[]
};
},
components: { Treeselect, IconSelect },
created() {
this.getList();
this.getTreeselect();
},
methods: {
/** 查询视频分类列表 */
getList() {
this.loading = true;
listVideoClassify(this.queryParams).then(response => {
this.videoClassifyList = response.rows;
this.videoClassifyList = this.handleTree(response.rows, "id");
this.total = response.total;
this.loading = false;
});
@ -178,6 +216,8 @@
this.form = {
id: null,
cateName: null,
parentId: null,
orderNum: 0,
payFlag: null,
createTime: null,
createBy: null,
@ -204,8 +244,13 @@
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
handleAdd(row) {
this.reset();
if (row != null && row.id) {
this.form.parentId = row.id;
} else {
this.form.parentId = 0;
}
this.open = true;
this.title = "添加视频分类";
},
@ -223,12 +268,21 @@
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
//
if(this.threeLevelClassify.indexOf(this.form.parentId) != -1){
this.$message({
message: "最多只支持三级分类,三级类别不能作为上级",
type: "warning",
});
return;
}
if (this.form.id != null) {
updateVideoClassify(this.form).then(response => {
if (response.code === 200) {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
this.getTreeselect();
}
});
} else {
@ -237,6 +291,7 @@
this.msgSuccess("新增成功");
this.open = false;
this.getList();
this.getTreeselect();
}
});
}
@ -269,7 +324,39 @@
}).then(response => {
this.download(response.msg);
}).catch(function() {});
},
/** 转换菜单数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children;
}
return {
id: node.id,
label: node.cateName,
children: node.children
};
},
/** 查询目录下拉树结构 */
getTreeselect() {
getAllClassify().then(response => {
this.classifyOptions = [];
const classify = { id: 0, cateName: '主分类', children: [] };
classify.children = this.handleTree(response.data, "id");
classify.children.forEach((item,i) => {
if(item.children && item.children.length > 0){
item.children.forEach((tem,j) => {
if(tem.children && tem.children.length > 0){
tem.children.forEach(element => {
this.threeLevelClassify.push(element.id);
});
}
});
}
});
//console.log(this.threeLevelClassify.length);
this.classifyOptions.push(classify);
});
},
}
};
</script>