Selaa lähdekoodia

refactor(course): 优化课程查询功能

- 移除 CourseInfoDto,直接使用 CourseInfo 实体类进行查询
- 删除课程查询中的关键字、课程 ID、学校类型等条件
以上为回滚内容
- 更新 GoalInfoController 中的字段映射
- 在 GoalInfoReqDto 中添加 keyWord 字段
适配前端模糊查询
zhengjinbin 5 kuukautta sitten
vanhempi
commit
561035fae8

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

@@ -1,6 +1,8 @@
 package com.education.api.controller.admin.education;
 
 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.CourseSectionNodeService;
 import com.education.business.service.education.CourseSectionService;
@@ -49,8 +51,8 @@ public class CourseInfoController extends BaseController {
      */
     @GetMapping
     //@RequiresPermissions("system:course:list")
-    public Result list(PageParam pageParam, CourseInfoDto courseInfoDto) {
-        return Result.success(courseInfoService.selectPageList(pageParam, courseInfoDto));
+    public Result list(PageParam pageParam, CourseInfo courseInfo) {
+        return Result.success(courseInfoService.selectPageList(pageParam, courseInfo));
     }
 
     /**
@@ -86,7 +88,7 @@ public class CourseInfoController extends BaseController {
 
     /**
      * 添加或修改课程章节
-     * @param CourseSection
+     * @param
      * @return
      */
     @PostMapping("/section")

+ 1 - 1
education-api/src/main/java/com/education/api/controller/admin/education/GoalInfoController.java

@@ -81,7 +81,7 @@ public class GoalInfoController extends BaseController {
         goalInfo.setSchoolType(goalInfoReqDto.getSchoolType());
         goalInfo.setGradeId(goalInfoReqDto.getGradeId());
         goalInfo.setCourseId(goalInfoReqDto.getCourseId());
-        goalInfo.setgOriented(goalInfoReqDto.getgOriented());
+        goalInfo.setgOriented(goalInfoReqDto.getKeyWord());
         return Result.success(goalInfoService.selectPageList(pageParam, goalInfo));
     }
 }

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

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

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

@@ -4,8 +4,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.education.model.dto.CourseInfoDto;
 import com.education.model.entity.CourseInfo;
-import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
 
 /**
@@ -21,8 +19,7 @@ public interface CourseInfoMapper extends BaseMapper<CourseInfo> {
      * @param courseInfo
      * @return
      */
-    Page<CourseInfoDto> selectPageList(Page<CourseInfoDto> page, @Param("courseInfo") CourseInfoDto courseInfo);
-
+    Page<CourseInfoDto> selectPageList(Page<CourseInfoDto> page, CourseInfo courseInfo);
 
     /**
      * 课程章数量加一

+ 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
     private RedissonClient redissonClient;
 
-    public PageInfo<CourseInfoDto> selectPageList(PageParam pageParam, CourseInfoDto courseInfoDto) {
+    public PageInfo<CourseInfoDto> selectPageList(PageParam pageParam, CourseInfo courseInfo) {
         Page<CourseInfoDto> page = new Page<>(pageParam.getPageNumber(), pageParam.getPageSize());
-        Page<CourseInfoDto> resultPage = baseMapper.selectPageList(page, courseInfoDto);
+        Page<CourseInfoDto> resultPage = baseMapper.selectPageList(page, courseInfo);
         List<CourseInfoDto> list = resultPage.getRecords();
         list.forEach(item -> {
             Integer studentId = item.getStudentId();

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

@@ -13,15 +13,12 @@
         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 student_course_collect collect ON course.id = collect.course_id
-        LEFT JOIN goal_info gInfo ON course.id = gInfo.course_id
        <where>
            <if test="courseInfo.name != null and courseInfo.name != ''">
                <bind name="name" value="'%' + courseInfo.name + '%'"/>
                and course.name like #{name}
            </if>
-           <if test='courseInfo.courseId != null'>
-           AND course.id = #{courseInfo.courseId}
-           </if>
+
            <if test="courseInfo.recommendIndexFlag != null">
                and course.recommend_index_flag = #{courseInfo.recommendIndexFlag}
            </if>
@@ -37,12 +34,6 @@
            <if test="courseInfo.status != null">
                and course.status = #{courseInfo.status}
            </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>
        order by course.sort desc
     </select>

+ 10 - 0
education-model/src/main/java/com/education/model/dto/GoalInfoReqDto.java

@@ -23,6 +23,16 @@ public class GoalInfoReqDto {
      */
     private String gOriented;
 
+    private String keyWord;
+
+    public String getKeyWord() {
+        return keyWord;
+    }
+
+    public void setKeyWord(String keyWord) {
+        this.keyWord = keyWord;
+    }
+
     public Integer getSchoolType() {
         return schoolType;
     }