Explorar el Código

feat(student): 添加学生提醒列表和学习记录功能

- 在 StudentInfoController 中添加了 selectStudentRemindList 和 selectStudyHistoryPageList 方法
- 在 StudentInfoMapper 中添加了 selectStudentRemindList 和 selectStudyHistoryPageList 方法
- 在 StudentInfoService 中实现了 selectStudentRemindList 和 selectStudyHistoryPageList 方法
- 新增了 StuGoalInfoDto 类,用于学习记录的数据传输
lzxing hace 4 meses
padre
commit
3ea1e5a070

+ 19 - 1
education-api/src/main/java/com/education/api/controller/student/StudentInfoController.java

@@ -4,7 +4,6 @@ import com.education.auth.AuthUtil;
 import com.education.auth.LoginToken;
 import com.education.business.service.education.StudentInfoService;
 import com.education.business.session.StudentSession;
-import com.education.business.session.UserSessionContext;
 import com.education.common.annotation.Param;
 import com.education.common.annotation.ParamsType;
 import com.education.common.annotation.ParamsValidate;
@@ -15,7 +14,9 @@ import com.education.common.utils.RegexUtils;
 import com.education.common.utils.Result;
 import com.education.common.utils.ResultCode;
 import com.education.model.dto.StudentInfoDto;
+import com.education.model.entity.StuGoalInfo;
 import com.education.model.entity.StudentInfo;
+import com.education.model.request.PageParam;
 import com.education.model.request.UserLoginRequest;
 import org.springframework.web.bind.annotation.*;
 
@@ -94,5 +95,22 @@ public class StudentInfoController extends BaseController {
         return Result.success(studentInfoService.selectStudentInfo());
     }
 
+    /**
+     * 根据缓存学生id查询学生提醒列表
+     */
+    @GetMapping("selectStudentRemindList")
+    public Result selectStudentRemindList() {
+        return Result.success(studentInfoService.selectStudentRemindList());
+    }
+
+    /**
+     * 根据缓存学生id学生查询学习记录
+     */
+    @GetMapping("selectStudyHistoryPageList")
+    public Result selectStudyHistoryPageList(PageParam pageParam, StuGoalInfo stuGoalInfo) {
+        return Result.success(studentInfoService.selectStudyHistoryPageList(pageParam, stuGoalInfo));
+    }
+
+
 
 }

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

@@ -2,10 +2,15 @@ package com.education.business.mapper.education;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.education.model.dto.StuGoalInfoDto;
 import com.education.model.dto.StudentInfoDto;
+import com.education.model.entity.GoalInfo;
+import com.education.model.entity.StuGoalInfo;
 import com.education.model.entity.StudentInfo;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 /**
  * @author zengjintao
  * @version 1.0
@@ -22,4 +27,9 @@ public interface StudentInfoMapper extends BaseMapper<StudentInfo> {
     Page<StudentInfoDto> selectPageList(Page<StudentInfoDto> page, StudentInfo studentInfo);
 
     StudentInfoDto selectById(@Param("id") Integer id);
+
+    List<GoalInfo> selectStudentRemindList(Integer studentId);
+
+    Page<StuGoalInfoDto> selectStudyHistoryPageList(Page<StuGoalInfoDto> page, StuGoalInfo stuGoalInfo);
+
 }

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

@@ -1,38 +1,29 @@
 package com.education.business.service.education;
 
-import cn.hutool.core.util.StrUtil;
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.education.auth.AuthUtil;
-import com.education.auth.LoginToken;
+
+import com.education.auth.session.UserSession;
 import com.education.business.mapper.education.StudentInfoMapper;
 import com.education.business.service.BaseService;
 import com.education.business.service.system.WebsiteConfigService;
-import com.education.business.session.StudentSession;
 import com.education.business.session.UserSessionContext;
-import com.education.common.constants.AuthConstants;
-import com.education.common.constants.CacheKey;
-import com.education.common.constants.CacheTime;
-import com.education.common.exception.BusinessException;
+import com.education.common.enums.LoginEnum;
 import com.education.common.model.JwtToken;
 import com.education.common.model.PageInfo;
 import com.education.common.model.StudentInfoImport;
 import com.education.common.utils.*;
+import com.education.model.dto.StuGoalInfoDto;
 import com.education.model.dto.StudentInfoDto;
-import com.education.model.entity.GradeInfo;
-import com.education.model.entity.StudentInfo;
-import com.education.model.entity.WebsiteConfig;
+import com.education.model.entity.*;
 import com.education.model.request.PageParam;
-import com.education.model.request.UserLoginRequest;
-import com.jfinal.kit.Kv;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import javax.servlet.http.HttpServletResponse;
 import java.util.*;
 
 /**
@@ -162,4 +153,18 @@ public class StudentInfoService extends BaseService<StudentInfoMapper, StudentIn
     public StudentInfoDto selectStudentInfo() {
         return studentInfoMapper.selectById(UserSessionContext.getStudentId());
     }
+
+    public List<GoalInfo> selectStudentRemindList() {
+        UserSession userSession = AuthUtil.getSession(LoginEnum.STUDENT.getValue());
+        List<GoalInfo> list = studentInfoMapper.selectStudentRemindList(userSession.getId().intValue());
+        return list;
+    }
+
+    public PageInfo<StuGoalInfoDto> selectStudyHistoryPageList(PageParam pageParam, StuGoalInfo stuGoalInfo) {
+        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);
+        return selectPage(resultPage);
+    }
 }

+ 36 - 0
education-business/src/main/resources/mapper/education/StudentInfoMapper.xml

@@ -46,4 +46,40 @@
             si.id = #{id}
     </select>
 
+    <!-- 提醒列表 -->
+    <select id="selectStudentRemindList" resultType="goalInfo">
+        SELECT
+            goal.*
+        FROM
+            goal_info goal
+        WHERE
+            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 ))
+        ORDER BY goal.id
+    </select>
+
+    <!-- 学习记录列表 -->
+    <select id="selectStudyHistoryPageList" resultType="com.education.model.dto.StuGoalInfoDto">
+        select student.student_id as studentId, student.create_date as createDate,
+        student.goal_info_id as goalInfoId, course.id as courseId, course.name as courseName,
+        goal.g_oriented as goalContent
+        from stu_goal_info student
+        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>
+            <if test="stuGoalInfo.goalInfoId != null">
+                and goal.id = #{stuGoalInfo.goalInfoId}
+            </if>
+            <if test="stuGoalInfo.createDate != null and stuGoalInfo.createDate != ''">
+                AND student.create_date BETWEEN #{stuGoalInfo.startDate} AND #{stuGoalInfo.endDate}
+            </if>
+        </where>
+        order by student.goal_info_id
+    </select>
+
 </mapper>

+ 87 - 1
education-model/src/main/java/com/education/model/dto/StuGoalInfoDto.java

@@ -2,6 +2,8 @@ package com.education.model.dto;
 
 import com.education.model.entity.StuGoalInfo;
 
+import java.util.Date;
+
 /**
  * @author zhangj
  * @version 1.0
@@ -9,6 +11,90 @@ import com.education.model.entity.StuGoalInfo;
  */
 public class StuGoalInfoDto extends StuGoalInfo {
 
-    // 可以添加额外的字段,如果有需要的话
+    /*
+    *  学生id
+     */
+    private Integer studentId;
+
+    /*
+     *  导向目标id
+     */
+    private Integer goalInfoId;
+
+    /*
+     *  课程id
+     */
+    private Integer courseId;
+
+    /*
+     *  创建时间
+     */
+    private Date createDate;
+
+    /*
+     *  课程名称
+     */
+    private String courseName ;
+
+    /*
+     *  目标内容
+     */
+    private String goalContent;
+
+
+    @Override
+    public Integer getStudentId() {
+        return studentId;
+    }
+
+    @Override
+    public void setStudentId(Integer studentId) {
+        this.studentId = studentId;
+    }
+
+    @Override
+    public Integer getGoalInfoId() {
+        return goalInfoId;
+    }
+
+    @Override
+    public void setGoalInfoId(Integer goalInfoId) {
+        this.goalInfoId = goalInfoId;
+    }
+
+    public Integer getCourseId() {
+        return courseId;
+    }
+
+    public void setCourseId(Integer courseId) {
+        this.courseId = courseId;
+    }
+
+    @Override
+    public Date getCreateDate() {
+        return createDate;
+    }
+
+    @Override
+    public void setCreateDate(Date createDate) {
+        this.createDate = createDate;
+    }
+
+    public String getCourseName() {
+        return courseName;
+    }
+
+    public void setCourseName(String courseName) {
+        this.courseName = courseName;
+    }
+
+    public String getGoalContent() {
+        return goalContent;
+    }
+
+    public void setGoalContent(String goalContent) {
+        this.goalContent = goalContent;
+    }
+
 
 }