Ver Fonte

提交:课程小节观看权限接口

yangdamao há 3 anos atrás
pai
commit
e7aa0136ed

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

@@ -12,15 +12,14 @@ import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.framework.web.service.TokenService;
 import com.zhongzheng.modules.bank.vo.QuestionImport;
-import com.zhongzheng.modules.course.bo.CourseSectionAddBo;
-import com.zhongzheng.modules.course.bo.CourseSectionBusinessAddBo;
-import com.zhongzheng.modules.course.bo.CourseSectionEditBo;
-import com.zhongzheng.modules.course.bo.CourseSectionQueryBo;
+import com.zhongzheng.modules.course.bo.*;
 import com.zhongzheng.modules.course.domain.CourseSectionBusiness;
 import com.zhongzheng.modules.course.service.ICourseSectionBusinessService;
 import com.zhongzheng.modules.course.service.ICourseSectionService;
+import com.zhongzheng.modules.course.service.ICourseSectionWatchPerService;
 import com.zhongzheng.modules.course.vo.CourseSectionImport;
 import com.zhongzheng.modules.course.vo.CourseSectionVo;
+import com.zhongzheng.modules.course.vo.CourseSectionWatchPerVo;
 import lombok.RequiredArgsConstructor;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -58,6 +57,8 @@ public class CourseSectionController extends BaseController {
 
     private final ICourseSectionBusinessService iCourseSectionBusinessService;
 
+    private final ICourseSectionWatchPerService iCourseSectionWatchPerService;
+
     @Autowired
     private TokenService tokenService;
 
@@ -186,4 +187,23 @@ public class CourseSectionController extends BaseController {
         List<CourseSectionBusiness> list = iCourseSectionBusinessService.getListById(sectionId);
         return AjaxResult.success(list);
     }
+
+    /**
+     * 获取课程小节观看权限
+     */
+    @ApiOperation("获取课程小节观看权限")
+    @GetMapping("/watch/per")
+    public AjaxResult<CourseSectionWatchPerVo> getSectionWatchPer(SectionWatchPerBo bo) {
+        CourseSectionWatchPerVo vo = iCourseSectionWatchPerService.getSectionWatchPer(bo);
+        return AjaxResult.success(vo);
+    }
+
+    /**
+     * 保存课程小节观看权限
+     */
+    @ApiOperation("保存课程小节观看权限")
+    @PostMapping("/add/watch/per")
+    public AjaxResult<Void> addSectionWatchPer(@RequestBody SectionWatchPerAddBo bo) {
+        return toAjax(iCourseSectionWatchPerService.insertByAddBo(bo));
+    }
 }

+ 53 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/SectionWatchPerAddBo.java

@@ -0,0 +1,53 @@
+package com.zhongzheng.modules.course.bo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author yangdamao
+ * @date 2022年08月16日 11:13
+ */
+@Data
+@ApiModel("保存课程小节观看权限")
+public class SectionWatchPerAddBo implements Serializable {
+
+    /** id */
+    @ApiModelProperty("id")
+    private Long id;
+
+    /** 商品ID */
+    @ApiModelProperty("商品ID")
+    private Long goodsId;
+
+    /** 课程ID */
+    @ApiModelProperty("课程ID")
+    private Long courseId;
+
+    /** 模块ID */
+    @ApiModelProperty("模块ID")
+    private Long moduleId;
+
+    /** 章ID */
+    @ApiModelProperty("章ID")
+    private Long chapterId;
+
+    /** 节id */
+    @ApiModelProperty("节id")
+    private Long sectionId;
+
+    /** 观看权限:1,已开通课程(默认) 2,全部 */
+    @ApiModelProperty("观看权限:1,已开通课程(默认) 2,全部 ")
+    private Integer watchPer;
+
+    /** 节类型 1录播 2直播 3回放 */
+    @ApiModelProperty("节类型 1录播 2直播 3回放")
+    private Integer sectionType;
+
+    /** 状态 1有效 0无效 */
+    @ApiModelProperty("状态 1有效 0无效")
+    private Integer status;
+
+}

+ 32 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/SectionWatchPerBo.java

@@ -0,0 +1,32 @@
+package com.zhongzheng.modules.course.bo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author yangdamao
+ * @date 2022年08月16日 11:13
+ */
+@Data
+@ApiModel("课程小节观看权限")
+public class SectionWatchPerBo implements Serializable {
+
+    @ApiModelProperty("商品ID")
+    private Long goodsId;
+
+    @ApiModelProperty("课程ID")
+    private Long courseId;
+
+    @ApiModelProperty("模块ID")
+    private Long moduleId;
+
+    @ApiModelProperty("章ID")
+    private Long chapterId;
+
+    @ApiModelProperty("节id")
+    private Long sectionId;
+
+}

+ 61 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/domain/CourseSectionWatchPer.java

@@ -0,0 +1,61 @@
+package com.zhongzheng.modules.course.domain;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/** 课程节观看权限表
+ * @author yangdamao
+ * @date 2022年08月16日 10:54
+ */
+@Data
+@NoArgsConstructor
+@Accessors(chain = true)
+@TableName("course_section_watch_per")
+public class CourseSectionWatchPer implements Serializable {
+
+    /** $column.columnComment */
+    @TableId(value = "id")
+    private Long id;
+
+    /** 商品ID */
+    private Long goodsId;
+
+    /** 课程ID */
+    private Long courseId;
+
+    /** 模块ID */
+    private Long moduleId;
+
+    /** 章ID */
+    private Long chapterId;
+
+    /** 节id */
+    private Long sectionId;
+
+    /** 观看权限:1,已开通课程(默认) 2,全部 */
+    private Integer watchPer;
+
+    /** 节类型 1录播 2直播 3回放 */
+    private Integer sectionType;
+
+    /** 状态 1有效 0无效 */
+    private Integer status;
+
+    /** 添加时间 */
+    @TableField(fill = FieldFill.INSERT)
+    private Long createTime;
+
+    /** 修改时间 */
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    private Long updateTime;
+
+    /** 商户ID */
+    private Long tenantId;
+}

+ 14 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/mapper/CourseSectionWatchPerMapper.java

@@ -0,0 +1,14 @@
+package com.zhongzheng.modules.course.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zhongzheng.modules.course.domain.CourseSectionWatchPer;
+
+/**
+ * 业务层次Mapper接口
+ *
+ * @author ruoyi
+ * @date 2021-10-08
+ */
+public interface CourseSectionWatchPerMapper extends BaseMapper<CourseSectionWatchPer> {
+
+}

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

@@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.zhongzheng.modules.course.bo.CourseSectionBusinessAddBo;
 import com.zhongzheng.modules.course.bo.CourseSectionBusinessEditBo;
 import com.zhongzheng.modules.course.bo.CourseSectionBusinessQueryBo;
+import com.zhongzheng.modules.course.bo.SectionWatchPerBo;
 import com.zhongzheng.modules.course.domain.CourseSectionBusiness;
 import com.zhongzheng.modules.course.vo.CourseSectionBusinessVo;
+import com.zhongzheng.modules.course.vo.CourseSectionWatchPerVo;
 
 import java.util.Collection;
 import java.util.List;

+ 28 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/ICourseSectionWatchPerService.java

@@ -0,0 +1,28 @@
+package com.zhongzheng.modules.course.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.zhongzheng.modules.course.bo.SectionWatchPerAddBo;
+import com.zhongzheng.modules.course.bo.SectionWatchPerBo;
+import com.zhongzheng.modules.course.domain.CourseSectionWatchPer;
+import com.zhongzheng.modules.course.vo.CourseSectionWatchPerVo;
+
+public interface ICourseSectionWatchPerService extends IService<CourseSectionWatchPer> {
+
+    /**
+     * 获取课程小节观看权限
+     * @author change
+     * @date 2022/8/16 11:23
+     * @param bo
+     * @return com.zhongzheng.modules.course.vo.CourseSectionWatchPerVo
+     */
+    CourseSectionWatchPerVo getSectionWatchPer(SectionWatchPerBo bo);
+
+    /**
+     * 保存课程小节观看权限
+     * @author change
+     * @date 2022/8/16 11:45
+     * @param bo
+     * @return int
+     */
+    Boolean insertByAddBo(SectionWatchPerAddBo bo);
+}

+ 51 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseSectionWatchPerServiceImpl.java

@@ -0,0 +1,51 @@
+package com.zhongzheng.modules.course.service.impl;
+
+import cn.hutool.core.bean.BeanUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.BeanUtils;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zhongzheng.common.utils.DateUtils;
+import com.zhongzheng.modules.course.bo.SectionWatchPerAddBo;
+import com.zhongzheng.modules.course.bo.SectionWatchPerBo;
+import com.zhongzheng.modules.course.domain.CourseSection;
+import com.zhongzheng.modules.course.domain.CourseSectionWatchPer;
+import com.zhongzheng.modules.course.mapper.CourseSectionWatchPerMapper;
+import com.zhongzheng.modules.course.service.ICourseSectionWatchPerService;
+import com.zhongzheng.modules.course.vo.CourseSectionWatchPerVo;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author tanzh
+ * @date 2022年08月16日 11:05
+ */
+@Service
+public class CourseSectionWatchPerServiceImpl extends ServiceImpl<CourseSectionWatchPerMapper, CourseSectionWatchPer> implements ICourseSectionWatchPerService {
+
+    @Override
+    public CourseSectionWatchPerVo getSectionWatchPer(SectionWatchPerBo bo) {
+        CourseSectionWatchPer watchPer = getOne(new LambdaQueryWrapper<CourseSectionWatchPer>()
+                .eq(ObjectUtils.isNotNull(bo.getCourseId()), CourseSectionWatchPer::getCourseId, bo.getCourseId())
+                .eq(ObjectUtils.isNotNull(bo.getChapterId()), CourseSectionWatchPer::getChapterId, bo.getChapterId())
+                .eq(ObjectUtils.isNotNull(bo.getModuleId()), CourseSectionWatchPer::getModuleId, bo.getModuleId())
+                .eq(ObjectUtils.isNotNull(bo.getSectionId()), CourseSectionWatchPer::getSectionId, bo.getSectionId())
+                .eq(ObjectUtils.isNotNull(bo.getGoodsId()), CourseSectionWatchPer::getGoodsId, bo.getGoodsId())
+                .eq(CourseSectionWatchPer::getStatus, 1)
+                .last("LIMIT 1"));
+        if (ObjectUtils.isNull(watchPer)){
+            return null;
+        }
+        CourseSectionWatchPerVo vo = new CourseSectionWatchPerVo();
+        BeanUtil.copyProperties(watchPer,vo,true);
+        return vo;
+    }
+
+    @Override
+    public Boolean insertByAddBo(SectionWatchPerAddBo bo) {
+        CourseSectionWatchPer add = BeanUtil.toBean(bo, CourseSectionWatchPer.class);
+        add.setStatus(1);
+        add.setCreateTime(DateUtils.getNowTime());
+        add.setUpdateTime(DateUtils.getNowTime());
+        return saveOrUpdate(add);
+    }
+}

+ 58 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/vo/CourseSectionWatchPerVo.java

@@ -0,0 +1,58 @@
+package com.zhongzheng.modules.course.vo;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/** 课程节观看权限表
+ * @author yangdamao
+ * @date 2022年08月16日 10:54
+ */
+@Data
+@NoArgsConstructor
+@Accessors(chain = true)
+@TableName("course_section_watch_per")
+public class CourseSectionWatchPerVo implements Serializable {
+
+    @ApiModelProperty("id")
+    private Long id;
+
+    /** 商品ID */
+    @ApiModelProperty("商品ID")
+    private Long goodsId;
+
+    /** 课程ID */
+    @ApiModelProperty("课程ID")
+    private Long courseId;
+
+    /** 模块ID */
+    @ApiModelProperty("模块ID")
+    private Long moduleId;
+
+    /** 章ID */
+    @ApiModelProperty("章ID")
+    private Long chapterId;
+
+    /** 节id */
+    @ApiModelProperty("节id")
+    private Long sectionId;
+
+    /** 观看权限:1,已开通课程(默认) 2,全部 */
+    @ApiModelProperty("观看权限:1,已开通课程(默认) 2,全部 ")
+    private Integer watchPer;
+
+    /** 节类型 1录播 2直播 3回放 */
+    @ApiModelProperty("节类型 1录播 2直播 3回放")
+    private Integer sectionType;
+
+    /** 状态 1有效 0无效 */
+    @ApiModelProperty("状态 1有效 0无效")
+    private Integer status;
+}