Преглед изворни кода

课程小节保利威视频

he2802 пре 4 година
родитељ
комит
1e7a674923

+ 1 - 1
zhongzheng-admin/src/main/java/com/zhongzheng/controller/course/CourseSectionController.java

@@ -52,7 +52,7 @@ public class CourseSectionController extends BaseController {
     @GetMapping("/list")
     public TableDataInfo<CourseSectionVo> list(CourseSectionQueryBo bo) {
         startPage();
-        List<CourseSectionVo> list = iCourseSectionService.queryList(bo);
+        List<CourseSectionVo> list = iCourseSectionService.selectList(bo);
         return getDataTable(list);
     }
 

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseSectionAddBo.java

@@ -46,4 +46,7 @@ public class CourseSectionAddBo {
     private Integer status;
     @ApiModelProperty("排序")
     private Long sort;
+    @ApiModelProperty("保利威视频ID")
+    @NotBlank(message = "保利威视频ID不能为空")
+    private String vid;
 }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseSectionEditBo.java

@@ -52,4 +52,7 @@ public class CourseSectionEditBo {
     private Integer status;
     @ApiModelProperty("排序")
     private Long sort;
+    @ApiModelProperty("保利威视频ID")
+    @NotBlank(message = "保利威视频ID不能为空")
+    private String vid;
 }

+ 11 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/domain/CourseSection.java

@@ -54,6 +54,16 @@ private static final long serialVersionUID=1L;
     /** $column.columnComment */
     private Long sort;
 
-    /** 保利威视频ID */
+    /** 本地保利威视频ID */
     private Long polyvId;
+
+    /** 保利威视频ID */
+    @TableField(exist = false)
+    private String vid;
+    @TableField(exist = false)
+    private String duration;
+    @TableField(exist = false)
+    private String mp4;
+    @TableField(exist = false)
+    private String firstImage;
 }

+ 8 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/mapper/CourseSectionMapper.java

@@ -2,7 +2,13 @@ package com.zhongzheng.modules.course.mapper;
 
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zhongzheng.modules.course.bo.CourseQueryBo;
+import com.zhongzheng.modules.course.bo.CourseSectionQueryBo;
 import com.zhongzheng.modules.course.domain.CourseSection;
+import com.zhongzheng.modules.course.vo.CourseSectionVo;
+import com.zhongzheng.modules.course.vo.CourseVo;
+
+import java.util.List;
 
 /**
  * 课程小节Mapper接口
@@ -12,4 +18,6 @@ import com.zhongzheng.modules.course.domain.CourseSection;
  */
 public interface CourseSectionMapper extends BaseMapper<CourseSection> {
 
+    List<CourseSectionVo> selectCourseSectionList(CourseSectionQueryBo bo);
+
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/ICourseSectionService.java

@@ -29,6 +29,8 @@ public interface ICourseSectionService extends IService<CourseSection> {
 	 */
 	List<CourseSectionVo> queryList(CourseSectionQueryBo bo);
 
+	List<CourseSectionVo> selectList(CourseSectionQueryBo bo);
+
 	/**
 	 * 根据新增业务对象插入课程小节
 	 * @param bo 课程小节新增业务对象

+ 31 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseSectionServiceImpl.java

@@ -2,14 +2,20 @@ package com.zhongzheng.modules.course.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.modules.course.bo.CourseSectionAddBo;
 import com.zhongzheng.modules.course.bo.CourseSectionEditBo;
 import com.zhongzheng.modules.course.bo.CourseSectionQueryBo;
 import com.zhongzheng.modules.course.domain.CourseSection;
+import com.zhongzheng.modules.course.mapper.CourseMapper;
 import com.zhongzheng.modules.course.mapper.CourseSectionMapper;
 import com.zhongzheng.modules.course.service.ICourseSectionService;
 import com.zhongzheng.modules.course.vo.CourseSectionVo;
+import com.zhongzheng.modules.polyv.service.IPolyvVideoService;
+import com.zhongzheng.modules.polyv.vo.PolyvVideoQuerVo;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -30,6 +36,12 @@ import java.util.stream.Collectors;
 @Service
 public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, CourseSection> implements ICourseSectionService {
 
+    @Autowired
+    private IPolyvVideoService iPolyvVideoService;
+
+    @Autowired
+    private CourseSectionMapper courseSectionMapper;
+
     @Override
     public CourseSectionVo queryById(Long sectionId){
         CourseSection db = this.baseMapper.selectById(sectionId);
@@ -47,6 +59,11 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
         return entity2Vo(this.list(lqw));
     }
 
+    @Override
+    public List<CourseSectionVo> selectList(CourseSectionQueryBo bo) {
+        return courseSectionMapper.selectCourseSectionList(bo);
+    }
+
     /**
     * 实体类转化成视图对象
     *
@@ -89,8 +106,21 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
      *
      * @param entity 实体类数据
      */
-    private void validEntityBeforeSave(CourseSection entity){
+    private void validEntityBeforeSave(CourseSection entity) {
         //TODO 做一些数据校验,如唯一约束
+        if(StringUtils.isNotBlank(entity.getVid())){
+            try{
+                PolyvVideoQuerVo polyvVideo = iPolyvVideoService.queryById(entity.getVid());
+                if(polyvVideo == null){
+                    throw new CustomException("保利威视频不存在");
+                }
+                entity.setPolyvId(polyvVideo.getPolyvId());
+            }catch (Exception e){
+                throw new CustomException("保利威视频错误");
+            }
+
+        }
+
     }
 
     @Override

+ 7 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/vo/CourseSectionVo.java

@@ -1,5 +1,6 @@
 package com.zhongzheng.modules.course.vo;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.zhongzheng.common.annotation.Excel;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
@@ -48,5 +49,11 @@ public class CourseSectionVo {
 	@Excel(name = "排序")
 	@ApiModelProperty("排序")
 	private Long sort;
+	@ApiModelProperty("时长")
+	private String duration;
+	@ApiModelProperty("mp4 地址")
+	private String mp4;
+	@ApiModelProperty("预览图")
+	private String firstImage;
 
 }

+ 29 - 1
zhongzheng-system/src/main/resources/mapper/modules/course/CourseSectionMapper.xml

@@ -15,7 +15,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="status" column="status"/>
         <result property="sort" column="sort"/>
         <result property="polyvId" column="polyv_id"/>
+        <result property="duration" column="duration"/>
+        <result property="mp4" column="mp4"/>
+        <result property="firstImage" column="first_image"/>
     </resultMap>
 
-
+    <select id="selectCourseSectionList" parameterType="com.zhongzheng.modules.course.bo.CourseSectionQueryBo"  resultMap="CourseSectionResult">
+        SELECT
+        cs.section_id,
+        cs.name,
+        cs.chapter_id,
+        cs.`status`,
+        pv.duration,
+        pv.first_image,
+        pv.mp4
+        FROM
+        course_section cs
+        LEFT JOIN polyv_video pv ON cs.polyv_id = pv.polyv_id
+        WHERE 1=1
+        <if test="status != null and status.size()!=0 ">
+            AND cs.status in
+            <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="name != null and name != ''">
+            AND cs.name like concat('%', #{bankName}, '%')
+        </if>
+        <if test="chapterId != null and chapterId != ''">
+            AND cs.chapter_id = #{chapterId}
+        </if>
+    </select>
 </mapper>