deason преди 1 година
родител
ревизия
28c3b71ce7

+ 7 - 4
src/main/java/com/qmth/exam/reserve/dao/StudentDao.java

@@ -1,13 +1,16 @@
 package com.qmth.exam.reserve.dao;
 
-import java.util.List;
-
-import org.apache.ibatis.annotations.Param;
-
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.qmth.exam.reserve.bean.student.StudentInfo;
 import com.qmth.exam.reserve.entity.StudentEntity;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 public interface StudentDao extends BaseMapper<StudentEntity> {
 
     List<StudentEntity> listNoFinishStudent(@Param("taskId") Long taskId, @Param("cancel") Boolean cancel);
+
+    StudentInfo findInfoById(@Param("studentId") Long studentId);
+
 }

+ 2 - 22
src/main/java/com/qmth/exam/reserve/service/impl/StudentServiceImpl.java

@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.boot.core.exception.StatusException;
-import com.qmth.exam.reserve.bean.category.CategoryCacheBean;
 import com.qmth.exam.reserve.bean.student.StudentInfo;
 import com.qmth.exam.reserve.bean.student.WechatBindReq;
 import com.qmth.exam.reserve.cache.impl.CategoryCacheService;
@@ -84,30 +83,11 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
 
     @Override
     public StudentInfo findInfoByStudentId(Long studentId) {
-        StudentEntity entity = baseMapper.selectById(studentId);
-        if (entity == null) {
+        StudentInfo info = baseMapper.findInfoById(studentId);
+        if (info == null) {
             throw new StatusException("学生信息不存在");
         }
 
-        StudentInfo info = new StudentInfo();
-        info.setId(entity.getId());
-        info.setName(entity.getName());
-        info.setStudentCode(entity.getStudentCode());
-        info.setIdentityNumber(entity.getIdentityNumber());
-        info.setPhotoPath(entity.getPhotoPath());
-        info.setGender(entity.getGender());
-        info.setApplyNumber(entity.getApplyNumber());
-        info.setOpenId(entity.getOpenId());
-        info.setUid(entity.getUid());
-        info.setOrgId(entity.getOrgId());
-        info.setApplyTaskId(entity.getApplyTaskId());
-        info.setCategoryId(entity.getCategoryId());
-
-        CategoryCacheBean category = categoryCacheService.getCategoryById(entity.getCategoryId());
-        if (category != null) {
-            info.setCategoryName(category.getName());
-        }
-
         return info;
     }
 

+ 29 - 10
src/main/resources/mapper/StudentMapper.xml

@@ -1,15 +1,34 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.qmth.exam.reserve.dao.StudentDao">
-	<select id="listNoFinishStudent" resultType="com.qmth.exam.reserve.entity.StudentEntity">
-		SELECT
-		 	s.* 
-		FROM
-			t_student s
-			LEFT JOIN ( SELECT student_id, count( 1 ) nums FROM t_student_apply a WHERE a.cancel =#{cancel}  GROUP BY student_id ) ts ON ts.student_id = s.id 
-		WHERE
-			apply_task_id =#{taskId} 
-			AND s.apply_number - ifnull( ts.nums, 0 )> 0
-	</select>
+    <select id="listNoFinishStudent" resultType="com.qmth.exam.reserve.entity.StudentEntity">
+        SELECT s.*
+        FROM t_student s
+                 LEFT JOIN (SELECT student_id, count(1) nums
+                            FROM t_student_apply a
+                            WHERE a.cancel = #{cancel}
+                            GROUP BY student_id) ts ON ts.student_id = s.id
+        WHERE apply_task_id = #{taskId}
+          AND s.apply_number - ifnull(ts.nums, 0) > 0
+    </select>
+
+    <select id="findInfoById" resultType="com.qmth.exam.reserve.bean.student.StudentInfo">
+        select stu.id,
+               stu.name,
+               stu.student_code,
+               stu.identity_number,
+               stu.photo_path,
+               stu.gender,
+               stu.apply_number,
+               stu.open_id,
+               stu.uid,
+               stu.org_id,
+               stu.apply_task_id,
+               stu.category_id,
+               c.name category_name
+        from t_student stu
+                 left join t_category c on c.id = stu.category_id
+        where stu.id = #{studentId}
+    </select>
 
 </mapper>