Przeglądaj źródła

refactor(education): 优化学生学习历史记录查询接口

-将 StuGoalInfo 参数改为 StuGoalInfoDto
-修复学生学习历史记录查询逻辑
-优化 SQL 查询语句
lzxing 4 miesięcy temu
rodzic
commit
acf2be8eae

+ 3 - 2
education-api/src/main/java/com/education/api/controller/student/StudentInfoController.java

@@ -13,6 +13,7 @@ import com.education.common.enums.LoginEnum;
 import com.education.common.utils.RegexUtils;
 import com.education.common.utils.Result;
 import com.education.common.utils.ResultCode;
+import com.education.model.dto.StuGoalInfoDto;
 import com.education.model.dto.StudentInfoDto;
 import com.education.model.entity.StuGoalInfo;
 import com.education.model.entity.StudentInfo;
@@ -107,8 +108,8 @@ public class StudentInfoController extends BaseController {
      * 根据缓存学生id学生查询学习记录
      */
     @GetMapping("selectStudyHistoryPageList")
-    public Result selectStudyHistoryPageList(PageParam pageParam, StuGoalInfo stuGoalInfo) {
-        return Result.success(studentInfoService.selectStudyHistoryPageList(pageParam, stuGoalInfo));
+    public Result selectStudyHistoryPageList(PageParam pageParam, StuGoalInfoDto stuGoalInfoDto) {
+        return Result.success(studentInfoService.selectStudyHistoryPageList(pageParam, stuGoalInfoDto));
     }
 
 

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

@@ -30,6 +30,6 @@ public interface StudentInfoMapper extends BaseMapper<StudentInfo> {
 
     List<GoalInfo> selectStudentRemindList(Integer studentId);
 
-    Page<StuGoalInfoDto> selectStudyHistoryPageList(Page<StuGoalInfoDto> page, StuGoalInfo stuGoalInfo);
+    Page<StuGoalInfoDto> selectStudyHistoryPageList(Page<StuGoalInfoDto> page, StuGoalInfoDto stuGoalInfoDto);
 
 }

+ 3 - 3
education-business/src/main/java/com/education/business/service/education/StudentInfoService.java

@@ -160,11 +160,11 @@ public class StudentInfoService extends BaseService<StudentInfoMapper, StudentIn
         return list;
     }
 
-    public PageInfo<StuGoalInfoDto> selectStudyHistoryPageList(PageParam pageParam, StuGoalInfo stuGoalInfo) {
+    public PageInfo<StuGoalInfoDto> selectStudyHistoryPageList(PageParam pageParam, StuGoalInfoDto stuGoalInfoDto) {
         Page<StuGoalInfoDto> page = new Page<>(pageParam.getPageNumber(), pageParam.getPageSize());
         UserSession userSession = AuthUtil.getSession(LoginEnum.STUDENT.getValue());
-        stuGoalInfo.setStudentId(userSession.getId().intValue());
-        Page<StuGoalInfoDto> resultPage = studentInfoMapper.selectStudyHistoryPageList(page, stuGoalInfo);
+        stuGoalInfoDto.setStudentId(userSession.getId().intValue());
+        Page<StuGoalInfoDto> resultPage = studentInfoMapper.selectStudyHistoryPageList(page, stuGoalInfoDto);
         return selectPage(resultPage);
     }
 }

+ 8 - 7
education-business/src/main/resources/mapper/education/StudentInfoMapper.xml

@@ -53,10 +53,11 @@
         FROM
             goal_info goal
         WHERE
+            goal.publish_flag >0 AND (
             NOT EXISTS ( SELECT 1 FROM stu_goal_info sgi WHERE sgi.student_id = #{studentId} AND sgi.goal_info_id = goal.id )
            OR (
             EXISTS ( SELECT 1 FROM stu_goal_info sg WHERE sg.student_id = #{studentId} AND sg.goal_info_id = goal.id AND sg.correct_status &lt; 2 )
-                AND NOT EXISTS ( SELECT 1 FROM stu_goal_info si WHERE si.student_id = #{studentId} AND si.goal_info_id = goal.id AND si.correct_status >= 2 ))
+                AND NOT EXISTS ( SELECT 1 FROM stu_goal_info si WHERE si.student_id = #{studentId} AND si.goal_info_id = goal.id AND si.correct_status >= 2 )))
         ORDER BY goal.id
     </select>
 
@@ -69,14 +70,14 @@
         left join goal_info goal on student.goal_info_id = goal.id
         left join course_info course on goal.course_id = course.id
         <where>
-            <if test="stuGoalInfo.studentId != null">
-                and student.student_id = #{stuGoalInfo.studentId}
+            <if test="stuGoalInfoDto.studentId != null">
+                and student.student_id = #{stuGoalInfoDto.studentId}
             </if>
-            <if test="stuGoalInfo.goalInfoId != null">
-                and goal.id = #{stuGoalInfo.goalInfoId}
+            <if test="stuGoalInfoDto.goalInfoId != null">
+                and goal.id = #{stuGoalInfoDto.goalInfoId}
             </if>
-            <if test="stuGoalInfo.createDate != null and stuGoalInfo.createDate != ''">
-                AND student.create_date BETWEEN #{stuGoalInfo.startDate} AND #{stuGoalInfo.endDate}
+            <if test="stuGoalInfoDto.createDate != null and stuGoalInfoDto.createDate != ''">
+                AND student.create_date BETWEEN #{stuGoalInfoDto.startDate} AND #{stuGoalInfoDto.endDate}
             </if>
         </where>
         order by student.goal_info_id