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

feat(course): 增加课程列表筛选功能

- 新增 CourseInfoDto 类,用于课程列表筛选参数
- 修改 CourseInfoMapper接口,使用 CourseInfoDto作为参数
- 更新 CourseInfoMapper.xml,添加新的筛选条件
- 修改 CourseInfoService 和 CourseInfoController,支持新的筛选功能
支撑courseId,keyWord查询
zhengjinbin пре 8 месеци
родитељ
комит
6111308ea4

+ 6 - 4
education-api/src/main/java/com/education/api/controller/admin/education/CourseInfoController.java

@@ -1,8 +1,6 @@
 package com.education.api.controller.admin.education;
 package com.education.api.controller.admin.education;
 
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.education.auth.annotation.Logical;
-import com.education.auth.annotation.RequiresPermissions;
 import com.education.business.service.education.CourseInfoService;
 import com.education.business.service.education.CourseInfoService;
 import com.education.business.service.education.CourseSectionNodeService;
 import com.education.business.service.education.CourseSectionNodeService;
 import com.education.business.service.education.CourseSectionService;
 import com.education.business.service.education.CourseSectionService;
@@ -11,11 +9,14 @@ import com.education.common.annotation.ParamsType;
 import com.education.common.annotation.ParamsValidate;
 import com.education.common.annotation.ParamsValidate;
 import com.education.common.base.BaseController;
 import com.education.common.base.BaseController;
 import com.education.common.utils.Result;
 import com.education.common.utils.Result;
+import com.education.model.dto.CourseInfoDto;
 import com.education.model.entity.CourseInfo;
 import com.education.model.entity.CourseInfo;
 import com.education.model.entity.CourseSection;
 import com.education.model.entity.CourseSection;
 import com.education.model.entity.CourseSectionNode;
 import com.education.model.entity.CourseSectionNode;
 import com.education.model.request.PageParam;
 import com.education.model.request.PageParam;
 import com.education.model.vo.CourseSectionVo;
 import com.education.model.vo.CourseSectionVo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
@@ -31,6 +32,7 @@ import java.util.stream.Collectors;
 @RestController
 @RestController
 @RequestMapping("/system/course")
 @RequestMapping("/system/course")
 public class CourseInfoController extends BaseController {
 public class CourseInfoController extends BaseController {
+    private static final Logger log = LoggerFactory.getLogger(CourseInfoController.class);
     @Resource
     @Resource
     private CourseSectionService courseSectionService;
     private CourseSectionService courseSectionService;
     @Resource
     @Resource
@@ -47,8 +49,8 @@ public class CourseInfoController extends BaseController {
      */
      */
     @GetMapping
     @GetMapping
     //@RequiresPermissions("system:course:list")
     //@RequiresPermissions("system:course:list")
-    public Result list(PageParam pageParam, CourseInfo courseInfo) {
-        return Result.success(courseInfoService.selectPageList(pageParam, courseInfo));
+    public Result list(PageParam pageParam, CourseInfoDto courseInfoDto) {
+        return Result.success(courseInfoService.selectPageList(pageParam, courseInfoDto));
     }
     }
 
 
     /**
     /**

+ 3 - 5
education-api/src/main/java/com/education/api/controller/student/CourseInfoController.java

@@ -5,11 +5,9 @@ import com.education.business.service.education.CourseInfoService;
 import com.education.business.service.education.CourseSectionService;
 import com.education.business.service.education.CourseSectionService;
 import com.education.common.base.BaseController;
 import com.education.common.base.BaseController;
 import com.education.common.utils.Result;
 import com.education.common.utils.Result;
-import com.education.model.entity.CourseInfo;
+import com.education.model.dto.CourseInfoDto;
 import com.education.model.entity.CourseSection;
 import com.education.model.entity.CourseSection;
-import com.education.model.entity.CourseSectionNode;
 import com.education.model.request.PageParam;
 import com.education.model.request.PageParam;
-import com.education.model.vo.CourseSectionVo;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -17,7 +15,6 @@ import org.springframework.web.bind.annotation.RestController;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.List;
-import java.util.stream.Collectors;
 
 
 /**
 /**
  * 课程管理接口
  * 课程管理接口
@@ -42,7 +39,8 @@ public class CourseInfoController extends BaseController {
      * @return
      * @return
      */
      */
     @GetMapping
     @GetMapping
-    public Result selectPageList(PageParam pageParam, CourseInfo courseInfo) {
+    public Result selectPageList(PageParam pageParam, CourseInfoDto courseInfo) {
+
         return Result.success(courseInfoService.selectPageList(pageParam, courseInfo));
         return Result.success(courseInfoService.selectPageList(pageParam, courseInfo));
     }
     }
 
 

+ 6 - 1
education-business/src/main/java/com/education/business/mapper/education/CourseInfoMapper.java

@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.education.model.dto.CourseInfoDto;
 import com.education.model.dto.CourseInfoDto;
 import com.education.model.entity.CourseInfo;
 import com.education.model.entity.CourseInfo;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
 import org.apache.ibatis.annotations.Update;
 
 
 /**
 /**
@@ -19,7 +21,8 @@ public interface CourseInfoMapper extends BaseMapper<CourseInfo> {
      * @param courseInfo
      * @param courseInfo
      * @return
      * @return
      */
      */
-    Page<CourseInfoDto> selectPageList(Page<CourseInfoDto> page, CourseInfo courseInfo);
+    Page<CourseInfoDto> selectPageList(Page<CourseInfoDto> page, @Param("courseInfo") CourseInfoDto courseInfo);
+
 
 
     /**
     /**
      * 课程章数量加一
      * 课程章数量加一
@@ -55,4 +58,6 @@ public interface CourseInfoMapper extends BaseMapper<CourseInfo> {
      */
      */
     @Update("update course_info set comment_number = comment_number + 1 where id = #{id}")
     @Update("update course_info set comment_number = comment_number + 1 where id = #{id}")
     void increaseCommentNumber(Integer courseId);
     void increaseCommentNumber(Integer courseId);
+
+
 }
 }

+ 2 - 2
education-business/src/main/java/com/education/business/service/education/CourseInfoService.java

@@ -32,9 +32,9 @@ public class CourseInfoService extends BaseService<CourseInfoMapper, CourseInfo>
     @Resource
     @Resource
     private RedissonClient redissonClient;
     private RedissonClient redissonClient;
 
 
-    public PageInfo<CourseInfoDto> selectPageList(PageParam pageParam, CourseInfo courseInfo) {
+    public PageInfo<CourseInfoDto> selectPageList(PageParam pageParam, CourseInfoDto courseInfoDto) {
         Page<CourseInfoDto> page = new Page<>(pageParam.getPageNumber(), pageParam.getPageSize());
         Page<CourseInfoDto> page = new Page<>(pageParam.getPageNumber(), pageParam.getPageSize());
-        Page<CourseInfoDto> resultPage = baseMapper.selectPageList(page, courseInfo);
+        Page<CourseInfoDto> resultPage = baseMapper.selectPageList(page, courseInfoDto);
         List<CourseInfoDto> list = resultPage.getRecords();
         List<CourseInfoDto> list = resultPage.getRecords();
         list.forEach(item -> {
         list.forEach(item -> {
             Integer studentId = item.getStudentId();
             Integer studentId = item.getStudentId();

+ 10 - 1
education-business/src/main/resources/mapper/education/CourseInfoMapper.xml

@@ -13,12 +13,15 @@
         LEFT JOIN subject_info subject ON course.subject_id = subject.id
         LEFT JOIN subject_info subject ON course.subject_id = subject.id
         LEFT JOIN grade_info grade ON course.grade_info_id = grade.id
         LEFT JOIN grade_info grade ON course.grade_info_id = grade.id
         LEFT JOIN student_course_collect collect ON course.id = collect.course_id
         LEFT JOIN student_course_collect collect ON course.id = collect.course_id
+        LEFT JOIN goal_info gInfo ON course.id = gInfo.course_id
        <where>
        <where>
            <if test="courseInfo.name != null and courseInfo.name != ''">
            <if test="courseInfo.name != null and courseInfo.name != ''">
                <bind name="name" value="'%' + courseInfo.name + '%'"/>
                <bind name="name" value="'%' + courseInfo.name + '%'"/>
                and course.name like #{name}
                and course.name like #{name}
            </if>
            </if>
-
+           <if test='courseInfo.courseId != null'>
+           AND course.id = #{courseInfo.courseId}
+           </if>
            <if test="courseInfo.recommendIndexFlag != null">
            <if test="courseInfo.recommendIndexFlag != null">
                and course.recommend_index_flag = #{courseInfo.recommendIndexFlag}
                and course.recommend_index_flag = #{courseInfo.recommendIndexFlag}
            </if>
            </if>
@@ -34,6 +37,12 @@
            <if test="courseInfo.status != null">
            <if test="courseInfo.status != null">
                and course.status = #{courseInfo.status}
                and course.status = #{courseInfo.status}
            </if>
            </if>
+           <if test="courseInfo.keyWord != null and courseInfo.keyWord != ''">
+               and (gInfo.content LIKE CONCAT('%', #{courseInfo.keyWord}, '%'))
+           </if>
+           <if test="courseInfo.schoolType != null">
+               and course.school_type = #{courseInfo.schoolType}
+           </if>
        </where>
        </where>
        order by course.sort desc
        order by course.sort desc
     </select>
     </select>

+ 64 - 0
education-model/src/main/java/com/education/model/dto/CourseInfoDto.java

@@ -9,12 +9,76 @@ import com.education.model.entity.CourseInfo;
  */
  */
 public class CourseInfoDto extends CourseInfo {
 public class CourseInfoDto extends CourseInfo {
 
 
+    /**
+     * 阶段id
+     */
+    private Integer schoolType;
+
+    /**
+     * 年级id
+     */
+    private Integer gradeInfoId;
+    /**
+     * 科目id
+     */
+    private Integer subjectId;
+    /**
+     * 课程id
+     */
+    private Integer courseId;
+    private String keyWord;
     private String subjectName;
     private String subjectName;
     private String gradeInfoName;
     private String gradeInfoName;
 
 
     private Integer studentId;
     private Integer studentId;
     private Integer collectFlag;
     private Integer collectFlag;
 
 
+    public String getKeyWord() {
+        return keyWord;
+    }
+
+    public void setKeyWord(String keyWord) {
+        this.keyWord = keyWord;
+    }
+
+    @Override
+    public Integer getSchoolType() {
+        return schoolType;
+    }
+
+    @Override
+    public void setSchoolType(Integer schoolType) {
+        this.schoolType = schoolType;
+    }
+
+    @Override
+    public Integer getGradeInfoId() {
+        return gradeInfoId;
+    }
+
+    @Override
+    public void setGradeInfoId(Integer gradeInfoId) {
+        this.gradeInfoId = gradeInfoId;
+    }
+
+    @Override
+    public Integer getSubjectId() {
+        return subjectId;
+    }
+
+    @Override
+    public void setSubjectId(Integer subjectId) {
+        this.subjectId = subjectId;
+    }
+
+    public Integer getCourseId() {
+        return courseId;
+    }
+
+    public void setCourseId(Integer courseId) {
+        this.courseId = courseId;
+    }
+
     public void setCollectFlag(Integer collectFlag) {
     public void setCollectFlag(Integer collectFlag) {
         this.collectFlag = collectFlag;
         this.collectFlag = collectFlag;
     }
     }