From 3bd37d8433e924ca72967272498a5c7a7d915c10 Mon Sep 17 00:00:00 2001
From: xiaoCJ <406612557@qq.com>
Date: Tue, 14 May 2024 14:51:00 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=88=90=E7=BB=A9=E8=AF=A6?=
 =?UTF-8?q?=E6=83=85=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../tea/TeaGradeManageController.java         | 137 ++--
 .../controller/tea/UserController.java        |   2 +-
 .../mapper/StuClassMapper.java                |   2 +
 .../mapper/StuUserMapper.java                 |   2 +
 src/main/resources/mapper/StuClassMapper.xml  |   9 +
 src/main/resources/mapper/StuUserMapper.xml   | 734 +++++++++---------
 6 files changed, 482 insertions(+), 404 deletions(-)

diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaGradeManageController.java b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaGradeManageController.java
index 66f1417..b7d32ea 100644
--- a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaGradeManageController.java
+++ b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaGradeManageController.java
@@ -37,6 +37,8 @@ import java.io.IOException;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
 
 /**
  * @Author xcj
@@ -178,7 +180,7 @@ public class TeaGradeManageController {
 
     }
 
-//    @AnonymousAccess
+    //    @AnonymousAccess
 //    @GetMapping("/test")
 //    @ApiOperation("测试导出")
     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
@@ -319,61 +321,108 @@ public class TeaGradeManageController {
     }
 
 
+//    private List<TeaExamAndUserDto> getTeaExamAndUserDtos(String schoolId, String keyWord, String classId, String examManageId) {
+//        List<TeaExamAndUserDto> list = new ArrayList<>();
+//        List<StuUser> stuUsers = userMapper.selectTeaExamAndUserDtos(schoolId, keyWord, classId, examManageId);
+//        //先拿到用户信息,再用userid查学生分数
+//        for (StuUser stuUser : stuUsers) {
+//            TeaExamAndUserDto teaExamAndUserDto = new TeaExamAndUserDto();
+//            String userid = stuUser.getUserid();
+//            StuStudentExamExample studentExamExample = new StuStudentExamExample();
+//            StuStudentExamExample.Criteria studentExamCriteria = studentExamExample.createCriteria();
+//            studentExamCriteria.andUseridEqualTo(userid);
+//            teaExamAndUserDto.setName(stuUser.getName());
+//            teaExamAndUserDto.setStudentId(stuUser.getStudentId());
+//            StuClass stuClass = stuClassMapper.selectByPrimaryKey(stuUser.getClassId());
+//            teaExamAndUserDto.setClassName(stuClass.getClassName());
+//            if (StringUtils.isNotBlank(examManageId)) {
+//                studentExamCriteria.andExamManageIdEqualTo(examManageId);
+//            }
+//            List<StuStudentExamWithBLOBs> stuStudentExams = studentExamMapper.selectByExampleWithBLOBs(studentExamExample);
+//            if (!stuStudentExams.isEmpty()) {
+//                StuStudentExamWithBLOBs stuStudentExam = stuStudentExams.get(0);
+//                if (stuStudentExam != null) {
+//                    if (stuStudentExam.getObjectiveScore() != null) {
+//                        teaExamAndUserDto.setObjectiveScore(stuStudentExam.getObjectiveScore());
+//                    }
+//                    if (stuStudentExam.getCaseScore() != null) {
+//                        teaExamAndUserDto.setCaseScore(stuStudentExam.getCaseScore());
+//                    }
+//                    if (stuStudentExam.getTotalScore() != null) {
+//                        teaExamAndUserDto.setTotalScore(stuStudentExam.getTotalScore());
+//                    }
+//                }
+//            }
+//            list.add(teaExamAndUserDto);
+//        }
+//        return list;
+//    }
+
+
     private List<TeaExamAndUserDto> getTeaExamAndUserDtos(String schoolId, String keyWord, String classId, String examManageId) {
-        StuUserExample stuUserExample = new StuUserExample();
-        StuUserExample.Criteria stuUserCriteria = stuUserExample.createCriteria();
-        StuUserExample.Criteria stuUserCriteria1 = stuUserExample.createCriteria();
-        stuUserCriteria.andSchoolIdEqualTo(schoolId);
-        stuUserCriteria.andRoleIdEqualTo(4);
-        stuUserCriteria1.andRoleIdEqualTo(4);
-        stuUserCriteria1.andSchoolIdEqualTo(schoolId);
-        List<TeaExamAndUserDto> list = new ArrayList();
-        if (StringUtils.isNotBlank(keyWord)) {
-            stuUserCriteria.andStudentIdEqualTo(keyWord);
-            stuUserCriteria1.andNameEqualTo(keyWord);
-        }
-        if (StringUtils.isNotBlank(classId)) {
-            stuUserCriteria.andClassIdEqualTo(classId);
-            stuUserCriteria1.andClassIdEqualTo(classId);
-        }
-        stuUserExample.or(stuUserCriteria1);
-        List<StuUser> stuUsers = userMapper.selectByExample(stuUserExample);
-        //先拿到用户信息,再用userid查学生分数
+        List<TeaExamAndUserDto> list = new ArrayList<>();
+
+        // 批量查询用户信息
+        List<StuUser> stuUsers = userMapper.selectTeaExamAndUserDtos(schoolId, keyWord, classId, examManageId);
+
+        // 构建用户id列表
+        List<String> userIds = stuUsers.stream()
+                .map(StuUser::getUserid)
+                .collect(Collectors.toList());
+
+        // 构建班级ID列表
+        List<String> classIds = stuUsers.stream()
+                .map(StuUser::getClassId)
+                .collect(Collectors.toList());
+
+        // 批量查询学生分数
+        StuStudentExamExample studentExamExample = new StuStudentExamExample();
+        studentExamExample.createCriteria()
+                .andUseridIn(userIds)
+                .andExamManageIdEqualTo(examManageId);
+
+        List<StuStudentExamWithBLOBs> stuStudentExams = studentExamMapper.selectByExampleWithBLOBs(studentExamExample);
+
+        // 构建用户id和对应的学生分数的映射关系
+        Map<String, StuStudentExamWithBLOBs> userExamMap = stuStudentExams.stream()
+                .collect(Collectors.toMap(StuStudentExamWithBLOBs::getUserid, Function.identity()));
+
+        List<StuClass> stuClass = stuClassMapper.getByPrimaryKeys(classIds);
+
+        // 构建班级ID与班级对象的映射关系
+        Map<String, StuClass> classMap = stuClass.stream()
+                .collect(Collectors.toMap(StuClass::getClassId, Function.identity()));
+
+        // 构建结果列表
         for (StuUser stuUser : stuUsers) {
             TeaExamAndUserDto teaExamAndUserDto = new TeaExamAndUserDto();
-            String userid = stuUser.getUserid();
-            StuStudentExamExample studentExamExample = new StuStudentExamExample();
-            StuStudentExamExample.Criteria studentExamCriteria = studentExamExample.createCriteria();
-            studentExamCriteria.andUseridEqualTo(userid);
             teaExamAndUserDto.setName(stuUser.getName());
             teaExamAndUserDto.setStudentId(stuUser.getStudentId());
-            StuClass stuClass = stuClassMapper.selectByPrimaryKey(stuUser.getClassId());
-            teaExamAndUserDto.setClassName(stuClass.getClassName());
-            if (StringUtils.isNotBlank(examManageId)) {
-                studentExamCriteria.andExamManageIdEqualTo(examManageId);
-            }
-            StuStudentExamExample example = new StuStudentExamExample();
-            example.createCriteria().andUseridEqualTo(userid).andExamManageIdEqualTo(examManageId);
-            List<StuStudentExamWithBLOBs> stuStudentExams = studentExamMapper.selectByExampleWithBLOBs(example);
-            if (!stuStudentExams.isEmpty()) {
-                StuStudentExamWithBLOBs stuStudentExam = stuStudentExams.get(0);
-                if (stuStudentExam != null) {
-                    if (stuStudentExam.getObjectiveScore() != null) {
-                        teaExamAndUserDto.setObjectiveScore(stuStudentExam.getObjectiveScore());
-                    }
-                    if (stuStudentExam.getCaseScore() != null) {
-                        teaExamAndUserDto.setCaseScore(stuStudentExam.getCaseScore());
-                    }
-                    if (stuStudentExam.getTotalScore() != null) {
-                        teaExamAndUserDto.setTotalScore(stuStudentExam.getTotalScore());
-                    }
+
+            // 从映射关系中获取班级对象
+            StuClass classdata = classMap.get(stuUser.getClassId());
+            teaExamAndUserDto.setClassName(classdata.getClassName());
+
+            StuStudentExamWithBLOBs stuStudentExam = userExamMap.get(stuUser.getUserid());
+            if (stuStudentExam != null) {
+                if (stuStudentExam.getObjectiveScore() != null) {
+                    teaExamAndUserDto.setObjectiveScore(stuStudentExam.getObjectiveScore());
+                }
+                if (stuStudentExam.getCaseScore() != null) {
+                    teaExamAndUserDto.setCaseScore(stuStudentExam.getCaseScore());
+                }
+                if (stuStudentExam.getTotalScore() != null) {
+                    teaExamAndUserDto.setTotalScore(stuStudentExam.getTotalScore());
                 }
             }
+
             list.add(teaExamAndUserDto);
         }
+
         return list;
     }
 
+
     @AnonymousAccess
     @PostMapping("/getTrainingInfo")
     @ApiOperation("练习模式--页面展示")
diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/UserController.java b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/UserController.java
index 3e5e563..a3d4aff 100644
--- a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/UserController.java
+++ b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/UserController.java
@@ -201,7 +201,7 @@ public class UserController {
                 continue;
             }
             StuUser stuUser = new StuUser();
-            stuUser.setUserid(IdUtil.randomUUID());
+            stuUser.setUserid(userId);
             stuUser.setStudentId(zyUserInfo.getUsername());
             stuUser.setName(name);
             stuUser.setUsername(username);
diff --git a/src/main/java/com/sztzjy/financial_bigdata/mapper/StuClassMapper.java b/src/main/java/com/sztzjy/financial_bigdata/mapper/StuClassMapper.java
index cb75f63..60da85c 100644
--- a/src/main/java/com/sztzjy/financial_bigdata/mapper/StuClassMapper.java
+++ b/src/main/java/com/sztzjy/financial_bigdata/mapper/StuClassMapper.java
@@ -40,4 +40,6 @@ public interface StuClassMapper {
     String selectClassNameByClassId(@Param("classId")String classId);
 
     List<StuClass> selectByPrimaryKeys(@Param("classIds") Set<String> classIds);
+
+    List<StuClass> getByPrimaryKeys(@Param("classIds") List<String> classIds);
 }
\ No newline at end of file
diff --git a/src/main/java/com/sztzjy/financial_bigdata/mapper/StuUserMapper.java b/src/main/java/com/sztzjy/financial_bigdata/mapper/StuUserMapper.java
index b4f6763..736f891 100644
--- a/src/main/java/com/sztzjy/financial_bigdata/mapper/StuUserMapper.java
+++ b/src/main/java/com/sztzjy/financial_bigdata/mapper/StuUserMapper.java
@@ -65,4 +65,6 @@ public interface StuUserMapper {
             + ")" +
             "</script>")
     List<StuUser> selectByPrimaryKeys(@Param("userIds") List<String> userIds);
+
+    List<StuUser> selectTeaExamAndUserDtos(@Param("schoolId")String schoolId,@Param("keyWord") String keyWord, @Param("classId")String classId, @Param("examManageId")String examManageId);
 }
\ No newline at end of file
diff --git a/src/main/resources/mapper/StuClassMapper.xml b/src/main/resources/mapper/StuClassMapper.xml
index a2234d2..d40b343 100644
--- a/src/main/resources/mapper/StuClassMapper.xml
+++ b/src/main/resources/mapper/StuClassMapper.xml
@@ -208,4 +208,13 @@
             #{classId}
         </foreach>
     </select>
+
+    <select id="getByPrimaryKeys" parameterType="java.util.List" resultMap="BaseResultMap">
+        SELECT *
+        FROM stu_class
+        WHERE class_id IN
+        <foreach collection="classIds" item="classId" open="(" separator="," close=")">
+            #{classId}
+        </foreach>
+    </select>
 </mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/StuUserMapper.xml b/src/main/resources/mapper/StuUserMapper.xml
index f8a05e3..a98e7f6 100644
--- a/src/main/resources/mapper/StuUserMapper.xml
+++ b/src/main/resources/mapper/StuUserMapper.xml
@@ -1,372 +1,376 @@
 <?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.sztzjy.financial_bigdata.mapper.StuUserMapper">
-  <resultMap id="BaseResultMap" type="com.sztzjy.financial_bigdata.entity.StuUser">
-    <id column="userid" jdbcType="VARCHAR" property="userid" />
-    <result column="name" jdbcType="VARCHAR" property="name" />
-    <result column="student_id" jdbcType="VARCHAR" property="studentId" />
-    <result column="class_id" jdbcType="VARCHAR" property="classId" />
-    <result column="username" jdbcType="VARCHAR" property="username" />
-    <result column="password" jdbcType="VARCHAR" property="password" />
-    <result column="phone" jdbcType="VARCHAR" property="phone" />
-    <result column="email" jdbcType="VARCHAR" property="email" />
-    <result column="major" jdbcType="VARCHAR" property="major" />
-    <result column="role_id" jdbcType="INTEGER" property="roleId" />
-    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
-    <result column="school_id" jdbcType="VARCHAR" property="schoolId" />
-    <result column="school_name" jdbcType="VARCHAR" property="schoolName" />
-    <result column="status" jdbcType="INTEGER" property="status" />
-    <result column="exam_status" jdbcType="VARCHAR" property="examStatus" />
-  </resultMap>
-  <sql id="Example_Where_Clause">
-    <where>
-      <foreach collection="oredCriteria" item="criteria" separator="or">
-        <if test="criteria.valid">
-          <trim prefix="(" prefixOverrides="and" suffix=")">
-            <foreach collection="criteria.criteria" item="criterion">
-              <choose>
-                <when test="criterion.noValue">
-                  and ${criterion.condition}
-                </when>
-                <when test="criterion.singleValue">
-                  and ${criterion.condition} #{criterion.value}
-                </when>
-                <when test="criterion.betweenValue">
-                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
-                </when>
-                <when test="criterion.listValue">
-                  and ${criterion.condition}
-                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
-                    #{listItem}
-                  </foreach>
-                </when>
-              </choose>
+    <resultMap id="BaseResultMap" type="com.sztzjy.financial_bigdata.entity.StuUser">
+        <id column="userid" jdbcType="VARCHAR" property="userid"/>
+        <result column="name" jdbcType="VARCHAR" property="name"/>
+        <result column="student_id" jdbcType="VARCHAR" property="studentId"/>
+        <result column="class_id" jdbcType="VARCHAR" property="classId"/>
+        <result column="username" jdbcType="VARCHAR" property="username"/>
+        <result column="password" jdbcType="VARCHAR" property="password"/>
+        <result column="phone" jdbcType="VARCHAR" property="phone"/>
+        <result column="email" jdbcType="VARCHAR" property="email"/>
+        <result column="major" jdbcType="VARCHAR" property="major"/>
+        <result column="role_id" jdbcType="INTEGER" property="roleId"/>
+        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
+        <result column="school_id" jdbcType="VARCHAR" property="schoolId"/>
+        <result column="school_name" jdbcType="VARCHAR" property="schoolName"/>
+        <result column="status" jdbcType="INTEGER" property="status"/>
+        <result column="exam_status" jdbcType="VARCHAR" property="examStatus"/>
+    </resultMap>
+    <sql id="Example_Where_Clause">
+        <where>
+            <foreach collection="oredCriteria" item="criteria" separator="or">
+                <if test="criteria.valid">
+                    <trim prefix="(" prefixOverrides="and" suffix=")">
+                        <foreach collection="criteria.criteria" item="criterion">
+                            <choose>
+                                <when test="criterion.noValue">
+                                    and ${criterion.condition}
+                                </when>
+                                <when test="criterion.singleValue">
+                                    and ${criterion.condition} #{criterion.value}
+                                </when>
+                                <when test="criterion.betweenValue">
+                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                                </when>
+                                <when test="criterion.listValue">
+                                    and ${criterion.condition}
+                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
+                                             separator=",">
+                                        #{listItem}
+                                    </foreach>
+                                </when>
+                            </choose>
+                        </foreach>
+                    </trim>
+                </if>
             </foreach>
-          </trim>
-        </if>
-      </foreach>
-    </where>
-  </sql>
-  <sql id="Update_By_Example_Where_Clause">
-    <where>
-      <foreach collection="example.oredCriteria" item="criteria" separator="or">
-        <if test="criteria.valid">
-          <trim prefix="(" prefixOverrides="and" suffix=")">
-            <foreach collection="criteria.criteria" item="criterion">
-              <choose>
-                <when test="criterion.noValue">
-                  and ${criterion.condition}
-                </when>
-                <when test="criterion.singleValue">
-                  and ${criterion.condition} #{criterion.value}
-                </when>
-                <when test="criterion.betweenValue">
-                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
-                </when>
-                <when test="criterion.listValue">
-                  and ${criterion.condition}
-                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
-                    #{listItem}
-                  </foreach>
-                </when>
-              </choose>
+        </where>
+    </sql>
+    <sql id="Update_By_Example_Where_Clause">
+        <where>
+            <foreach collection="example.oredCriteria" item="criteria" separator="or">
+                <if test="criteria.valid">
+                    <trim prefix="(" prefixOverrides="and" suffix=")">
+                        <foreach collection="criteria.criteria" item="criterion">
+                            <choose>
+                                <when test="criterion.noValue">
+                                    and ${criterion.condition}
+                                </when>
+                                <when test="criterion.singleValue">
+                                    and ${criterion.condition} #{criterion.value}
+                                </when>
+                                <when test="criterion.betweenValue">
+                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                                </when>
+                                <when test="criterion.listValue">
+                                    and ${criterion.condition}
+                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
+                                             separator=",">
+                                        #{listItem}
+                                    </foreach>
+                                </when>
+                            </choose>
+                        </foreach>
+                    </trim>
+                </if>
             </foreach>
-          </trim>
-        </if>
-      </foreach>
-    </where>
-  </sql>
-  <sql id="Base_Column_List">
-    userid, name, student_id, class_id, username, password, phone, email, major, role_id, 
+        </where>
+    </sql>
+    <sql id="Base_Column_List">
+        userid
+        , name, student_id, class_id, username, password, phone, email, major, role_id,
     create_time, school_id, school_name, status, exam_status
-  </sql>
-  <select id="selectByExample" parameterType="com.sztzjy.financial_bigdata.entity.StuUserExample" resultMap="BaseResultMap">
-    select
-    <if test="distinct">
-      distinct
-    </if>
-    <include refid="Base_Column_List" />
-    from stu_userinfo
-    <if test="_parameter != null">
-      <include refid="Example_Where_Clause" />
-    </if>
-    <if test="orderByClause != null">
-      order by ${orderByClause}
-    </if>
-  </select>
-  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
-    select 
-    <include refid="Base_Column_List" />
-    from stu_userinfo
-    where userid = #{userid,jdbcType=VARCHAR}
-  </select>
-  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
-    delete from stu_userinfo
-    where userid = #{userid,jdbcType=VARCHAR}
-  </delete>
-  <delete id="deleteByExample" parameterType="com.sztzjy.financial_bigdata.entity.StuUserExample">
-    delete from stu_userinfo
-    <if test="_parameter != null">
-      <include refid="Example_Where_Clause" />
-    </if>
-  </delete>
-  <insert id="insert" parameterType="com.sztzjy.financial_bigdata.entity.StuUser">
-    insert into stu_userinfo (userid, name, student_id, 
-      class_id, username, password, 
-      phone, email, major, 
-      role_id, create_time, school_id, 
-      school_name, status, exam_status
-      )
-    values (#{userid,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{studentId,jdbcType=VARCHAR}, 
-      #{classId,jdbcType=VARCHAR}, #{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, 
-      #{phone,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{major,jdbcType=VARCHAR}, 
-      #{roleId,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{schoolId,jdbcType=VARCHAR}, 
-      #{schoolName,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, #{examStatus,jdbcType=VARCHAR}
-      )
-  </insert>
-  <insert id="insertSelective" parameterType="com.sztzjy.financial_bigdata.entity.StuUser">
-    insert into stu_userinfo
-    <trim prefix="(" suffix=")" suffixOverrides=",">
-      <if test="userid != null">
-        userid,
-      </if>
-      <if test="name != null">
-        name,
-      </if>
-      <if test="studentId != null">
-        student_id,
-      </if>
-      <if test="classId != null">
-        class_id,
-      </if>
-      <if test="username != null">
-        username,
-      </if>
-      <if test="password != null">
-        password,
-      </if>
-      <if test="phone != null">
-        phone,
-      </if>
-      <if test="email != null">
-        email,
-      </if>
-      <if test="major != null">
-        major,
-      </if>
-      <if test="roleId != null">
-        role_id,
-      </if>
-      <if test="createTime != null">
-        create_time,
-      </if>
-      <if test="schoolId != null">
-        school_id,
-      </if>
-      <if test="schoolName != null">
-        school_name,
-      </if>
-      <if test="status != null">
-        status,
-      </if>
-      <if test="examStatus != null">
-        exam_status,
-      </if>
-    </trim>
-    <trim prefix="values (" suffix=")" suffixOverrides=",">
-      <if test="userid != null">
-        #{userid,jdbcType=VARCHAR},
-      </if>
-      <if test="name != null">
-        #{name,jdbcType=VARCHAR},
-      </if>
-      <if test="studentId != null">
-        #{studentId,jdbcType=VARCHAR},
-      </if>
-      <if test="classId != null">
-        #{classId,jdbcType=VARCHAR},
-      </if>
-      <if test="username != null">
-        #{username,jdbcType=VARCHAR},
-      </if>
-      <if test="password != null">
-        #{password,jdbcType=VARCHAR},
-      </if>
-      <if test="phone != null">
-        #{phone,jdbcType=VARCHAR},
-      </if>
-      <if test="email != null">
-        #{email,jdbcType=VARCHAR},
-      </if>
-      <if test="major != null">
-        #{major,jdbcType=VARCHAR},
-      </if>
-      <if test="roleId != null">
-        #{roleId,jdbcType=INTEGER},
-      </if>
-      <if test="createTime != null">
-        #{createTime,jdbcType=TIMESTAMP},
-      </if>
-      <if test="schoolId != null">
-        #{schoolId,jdbcType=VARCHAR},
-      </if>
-      <if test="schoolName != null">
-        #{schoolName,jdbcType=VARCHAR},
-      </if>
-      <if test="status != null">
-        #{status,jdbcType=INTEGER},
-      </if>
-      <if test="examStatus != null">
-        #{examStatus,jdbcType=VARCHAR},
-      </if>
-    </trim>
-  </insert>
-  <select id="countByExample" parameterType="com.sztzjy.financial_bigdata.entity.StuUserExample" resultType="java.lang.Long">
-    select count(*) from stu_userinfo
-    <if test="_parameter != null">
-      <include refid="Example_Where_Clause" />
-    </if>
-  </select>
-  <update id="updateByExampleSelective" parameterType="map">
-    update stu_userinfo
-    <set>
-      <if test="record.userid != null">
-        userid = #{record.userid,jdbcType=VARCHAR},
-      </if>
-      <if test="record.name != null">
+    </sql>
+    <select id="selectByExample" parameterType="com.sztzjy.financial_bigdata.entity.StuUserExample"
+            resultMap="BaseResultMap">
+        select
+        <if test="distinct">
+            distinct
+        </if>
+        <include refid="Base_Column_List"/>
+        from stu_userinfo
+        <if test="_parameter != null">
+            <include refid="Example_Where_Clause"/>
+        </if>
+        <if test="orderByClause != null">
+            order by ${orderByClause}
+        </if>
+    </select>
+    <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List"/>
+        from stu_userinfo
+        where userid = #{userid,jdbcType=VARCHAR}
+    </select>
+    <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
+        delete
+        from stu_userinfo
+        where userid = #{userid,jdbcType=VARCHAR}
+    </delete>
+    <delete id="deleteByExample" parameterType="com.sztzjy.financial_bigdata.entity.StuUserExample">
+        delete from stu_userinfo
+        <if test="_parameter != null">
+            <include refid="Example_Where_Clause"/>
+        </if>
+    </delete>
+    <insert id="insert" parameterType="com.sztzjy.financial_bigdata.entity.StuUser">
+        insert into stu_userinfo (userid, name, student_id,
+                                  class_id, username, password,
+                                  phone, email, major,
+                                  role_id, create_time, school_id,
+                                  school_name, status, exam_status)
+        values (#{userid,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{studentId,jdbcType=VARCHAR},
+                #{classId,jdbcType=VARCHAR}, #{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR},
+                #{phone,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{major,jdbcType=VARCHAR},
+                #{roleId,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{schoolId,jdbcType=VARCHAR},
+                #{schoolName,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, #{examStatus,jdbcType=VARCHAR})
+    </insert>
+    <insert id="insertSelective" parameterType="com.sztzjy.financial_bigdata.entity.StuUser">
+        insert into stu_userinfo
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="userid != null">
+                userid,
+            </if>
+            <if test="name != null">
+                name,
+            </if>
+            <if test="studentId != null">
+                student_id,
+            </if>
+            <if test="classId != null">
+                class_id,
+            </if>
+            <if test="username != null">
+                username,
+            </if>
+            <if test="password != null">
+                password,
+            </if>
+            <if test="phone != null">
+                phone,
+            </if>
+            <if test="email != null">
+                email,
+            </if>
+            <if test="major != null">
+                major,
+            </if>
+            <if test="roleId != null">
+                role_id,
+            </if>
+            <if test="createTime != null">
+                create_time,
+            </if>
+            <if test="schoolId != null">
+                school_id,
+            </if>
+            <if test="schoolName != null">
+                school_name,
+            </if>
+            <if test="status != null">
+                status,
+            </if>
+            <if test="examStatus != null">
+                exam_status,
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="userid != null">
+                #{userid,jdbcType=VARCHAR},
+            </if>
+            <if test="name != null">
+                #{name,jdbcType=VARCHAR},
+            </if>
+            <if test="studentId != null">
+                #{studentId,jdbcType=VARCHAR},
+            </if>
+            <if test="classId != null">
+                #{classId,jdbcType=VARCHAR},
+            </if>
+            <if test="username != null">
+                #{username,jdbcType=VARCHAR},
+            </if>
+            <if test="password != null">
+                #{password,jdbcType=VARCHAR},
+            </if>
+            <if test="phone != null">
+                #{phone,jdbcType=VARCHAR},
+            </if>
+            <if test="email != null">
+                #{email,jdbcType=VARCHAR},
+            </if>
+            <if test="major != null">
+                #{major,jdbcType=VARCHAR},
+            </if>
+            <if test="roleId != null">
+                #{roleId,jdbcType=INTEGER},
+            </if>
+            <if test="createTime != null">
+                #{createTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="schoolId != null">
+                #{schoolId,jdbcType=VARCHAR},
+            </if>
+            <if test="schoolName != null">
+                #{schoolName,jdbcType=VARCHAR},
+            </if>
+            <if test="status != null">
+                #{status,jdbcType=INTEGER},
+            </if>
+            <if test="examStatus != null">
+                #{examStatus,jdbcType=VARCHAR},
+            </if>
+        </trim>
+    </insert>
+    <select id="countByExample" parameterType="com.sztzjy.financial_bigdata.entity.StuUserExample"
+            resultType="java.lang.Long">
+        select count(*) from stu_userinfo
+        <if test="_parameter != null">
+            <include refid="Example_Where_Clause"/>
+        </if>
+    </select>
+    <update id="updateByExampleSelective" parameterType="map">
+        update stu_userinfo
+        <set>
+            <if test="record.userid != null">
+                userid = #{record.userid,jdbcType=VARCHAR},
+            </if>
+            <if test="record.name != null">
+                name = #{record.name,jdbcType=VARCHAR},
+            </if>
+            <if test="record.studentId != null">
+                student_id = #{record.studentId,jdbcType=VARCHAR},
+            </if>
+            <if test="record.classId != null">
+                class_id = #{record.classId,jdbcType=VARCHAR},
+            </if>
+            <if test="record.username != null">
+                username = #{record.username,jdbcType=VARCHAR},
+            </if>
+            <if test="record.password != null">
+                password = #{record.password,jdbcType=VARCHAR},
+            </if>
+            <if test="record.phone != null">
+                phone = #{record.phone,jdbcType=VARCHAR},
+            </if>
+            <if test="record.email != null">
+                email = #{record.email,jdbcType=VARCHAR},
+            </if>
+            <if test="record.major != null">
+                major = #{record.major,jdbcType=VARCHAR},
+            </if>
+            <if test="record.roleId != null">
+                role_id = #{record.roleId,jdbcType=INTEGER},
+            </if>
+            <if test="record.createTime != null">
+                create_time = #{record.createTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="record.schoolId != null">
+                school_id = #{record.schoolId,jdbcType=VARCHAR},
+            </if>
+            <if test="record.schoolName != null">
+                school_name = #{record.schoolName,jdbcType=VARCHAR},
+            </if>
+            <if test="record.status != null">
+                status = #{record.status,jdbcType=INTEGER},
+            </if>
+            <if test="record.examStatus != null">
+                exam_status = #{record.examStatus,jdbcType=VARCHAR},
+            </if>
+        </set>
+        <if test="_parameter != null">
+            <include refid="Update_By_Example_Where_Clause"/>
+        </if>
+    </update>
+    <update id="updateByExample" parameterType="map">
+        update stu_userinfo
+        set userid = #{record.userid,jdbcType=VARCHAR},
         name = #{record.name,jdbcType=VARCHAR},
-      </if>
-      <if test="record.studentId != null">
         student_id = #{record.studentId,jdbcType=VARCHAR},
-      </if>
-      <if test="record.classId != null">
         class_id = #{record.classId,jdbcType=VARCHAR},
-      </if>
-      <if test="record.username != null">
         username = #{record.username,jdbcType=VARCHAR},
-      </if>
-      <if test="record.password != null">
         password = #{record.password,jdbcType=VARCHAR},
-      </if>
-      <if test="record.phone != null">
         phone = #{record.phone,jdbcType=VARCHAR},
-      </if>
-      <if test="record.email != null">
         email = #{record.email,jdbcType=VARCHAR},
-      </if>
-      <if test="record.major != null">
         major = #{record.major,jdbcType=VARCHAR},
-      </if>
-      <if test="record.roleId != null">
         role_id = #{record.roleId,jdbcType=INTEGER},
-      </if>
-      <if test="record.createTime != null">
         create_time = #{record.createTime,jdbcType=TIMESTAMP},
-      </if>
-      <if test="record.schoolId != null">
         school_id = #{record.schoolId,jdbcType=VARCHAR},
-      </if>
-      <if test="record.schoolName != null">
         school_name = #{record.schoolName,jdbcType=VARCHAR},
-      </if>
-      <if test="record.status != null">
         status = #{record.status,jdbcType=INTEGER},
-      </if>
-      <if test="record.examStatus != null">
-        exam_status = #{record.examStatus,jdbcType=VARCHAR},
-      </if>
-    </set>
-    <if test="_parameter != null">
-      <include refid="Update_By_Example_Where_Clause" />
-    </if>
-  </update>
-  <update id="updateByExample" parameterType="map">
-    update stu_userinfo
-    set userid = #{record.userid,jdbcType=VARCHAR},
-      name = #{record.name,jdbcType=VARCHAR},
-      student_id = #{record.studentId,jdbcType=VARCHAR},
-      class_id = #{record.classId,jdbcType=VARCHAR},
-      username = #{record.username,jdbcType=VARCHAR},
-      password = #{record.password,jdbcType=VARCHAR},
-      phone = #{record.phone,jdbcType=VARCHAR},
-      email = #{record.email,jdbcType=VARCHAR},
-      major = #{record.major,jdbcType=VARCHAR},
-      role_id = #{record.roleId,jdbcType=INTEGER},
-      create_time = #{record.createTime,jdbcType=TIMESTAMP},
-      school_id = #{record.schoolId,jdbcType=VARCHAR},
-      school_name = #{record.schoolName,jdbcType=VARCHAR},
-      status = #{record.status,jdbcType=INTEGER},
-      exam_status = #{record.examStatus,jdbcType=VARCHAR}
-    <if test="_parameter != null">
-      <include refid="Update_By_Example_Where_Clause" />
-    </if>
-  </update>
-  <update id="updateByPrimaryKeySelective" parameterType="com.sztzjy.financial_bigdata.entity.StuUser">
-    update stu_userinfo
-    <set>
-      <if test="name != null">
-        name = #{name,jdbcType=VARCHAR},
-      </if>
-      <if test="studentId != null">
-        student_id = #{studentId,jdbcType=VARCHAR},
-      </if>
-      <if test="classId != null">
-        class_id = #{classId,jdbcType=VARCHAR},
-      </if>
-      <if test="username != null">
-        username = #{username,jdbcType=VARCHAR},
-      </if>
-      <if test="password != null">
-        password = #{password,jdbcType=VARCHAR},
-      </if>
-      <if test="phone != null">
-        phone = #{phone,jdbcType=VARCHAR},
-      </if>
-      <if test="email != null">
-        email = #{email,jdbcType=VARCHAR},
-      </if>
-      <if test="major != null">
-        major = #{major,jdbcType=VARCHAR},
-      </if>
-      <if test="roleId != null">
-        role_id = #{roleId,jdbcType=INTEGER},
-      </if>
-      <if test="createTime != null">
-        create_time = #{createTime,jdbcType=TIMESTAMP},
-      </if>
-      <if test="schoolId != null">
-        school_id = #{schoolId,jdbcType=VARCHAR},
-      </if>
-      <if test="schoolName != null">
-        school_name = #{schoolName,jdbcType=VARCHAR},
-      </if>
-      <if test="status != null">
-        status = #{status,jdbcType=INTEGER},
-      </if>
-      <if test="examStatus != null">
-        exam_status = #{examStatus,jdbcType=VARCHAR},
-      </if>
-    </set>
-    where userid = #{userid,jdbcType=VARCHAR}
-  </update>
-  <update id="updateByPrimaryKey" parameterType="com.sztzjy.financial_bigdata.entity.StuUser">
-    update stu_userinfo
-    set name = #{name,jdbcType=VARCHAR},
-      student_id = #{studentId,jdbcType=VARCHAR},
-      class_id = #{classId,jdbcType=VARCHAR},
-      username = #{username,jdbcType=VARCHAR},
-      password = #{password,jdbcType=VARCHAR},
-      phone = #{phone,jdbcType=VARCHAR},
-      email = #{email,jdbcType=VARCHAR},
-      major = #{major,jdbcType=VARCHAR},
-      role_id = #{roleId,jdbcType=INTEGER},
-      create_time = #{createTime,jdbcType=TIMESTAMP},
-      school_id = #{schoolId,jdbcType=VARCHAR},
-      school_name = #{schoolName,jdbcType=VARCHAR},
-      status = #{status,jdbcType=INTEGER},
-      exam_status = #{examStatus,jdbcType=VARCHAR}
-    where userid = #{userid,jdbcType=VARCHAR}
-  </update>
+        exam_status = #{record.examStatus,jdbcType=VARCHAR}
+        <if test="_parameter != null">
+            <include refid="Update_By_Example_Where_Clause"/>
+        </if>
+    </update>
+    <update id="updateByPrimaryKeySelective" parameterType="com.sztzjy.financial_bigdata.entity.StuUser">
+        update stu_userinfo
+        <set>
+            <if test="name != null">
+                name = #{name,jdbcType=VARCHAR},
+            </if>
+            <if test="studentId != null">
+                student_id = #{studentId,jdbcType=VARCHAR},
+            </if>
+            <if test="classId != null">
+                class_id = #{classId,jdbcType=VARCHAR},
+            </if>
+            <if test="username != null">
+                username = #{username,jdbcType=VARCHAR},
+            </if>
+            <if test="password != null">
+                password = #{password,jdbcType=VARCHAR},
+            </if>
+            <if test="phone != null">
+                phone = #{phone,jdbcType=VARCHAR},
+            </if>
+            <if test="email != null">
+                email = #{email,jdbcType=VARCHAR},
+            </if>
+            <if test="major != null">
+                major = #{major,jdbcType=VARCHAR},
+            </if>
+            <if test="roleId != null">
+                role_id = #{roleId,jdbcType=INTEGER},
+            </if>
+            <if test="createTime != null">
+                create_time = #{createTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="schoolId != null">
+                school_id = #{schoolId,jdbcType=VARCHAR},
+            </if>
+            <if test="schoolName != null">
+                school_name = #{schoolName,jdbcType=VARCHAR},
+            </if>
+            <if test="status != null">
+                status = #{status,jdbcType=INTEGER},
+            </if>
+            <if test="examStatus != null">
+                exam_status = #{examStatus,jdbcType=VARCHAR},
+            </if>
+        </set>
+        where userid = #{userid,jdbcType=VARCHAR}
+    </update>
+    <update id="updateByPrimaryKey" parameterType="com.sztzjy.financial_bigdata.entity.StuUser">
+        update stu_userinfo
+        set name        = #{name,jdbcType=VARCHAR},
+            student_id  = #{studentId,jdbcType=VARCHAR},
+            class_id    = #{classId,jdbcType=VARCHAR},
+            username    = #{username,jdbcType=VARCHAR},
+            password    = #{password,jdbcType=VARCHAR},
+            phone       = #{phone,jdbcType=VARCHAR},
+            email       = #{email,jdbcType=VARCHAR},
+            major       = #{major,jdbcType=VARCHAR},
+            role_id     = #{roleId,jdbcType=INTEGER},
+            create_time = #{createTime,jdbcType=TIMESTAMP},
+            school_id   = #{schoolId,jdbcType=VARCHAR},
+            school_name = #{schoolName,jdbcType=VARCHAR},
+            status      = #{status,jdbcType=INTEGER},
+            exam_status = #{examStatus,jdbcType=VARCHAR}
+        where userid = #{userid,jdbcType=VARCHAR}
+    </update>
     <insert id="batchInsertStudents" parameterType="java.util.List">
         INSERT INTO stu_userinfo (userid, name, student_id, class_id, username, password, phone,
         email,major,
@@ -380,15 +384,15 @@
 
 
     <resultMap id="UserDtoMap" type="com.sztzjy.financial_bigdata.entity.stu_dto.StuUserDto">
-        <result column="school_name" jdbcType="VARCHAR" property="schoolName" />
-        <result column="class_name" jdbcType="VARCHAR" property="className" />
-        <result column="name" jdbcType="VARCHAR" property="name" />
-        <result column="student_id" jdbcType="VARCHAR" property="studentId" />
-        <result column="phone" jdbcType="VARCHAR" property="phone" />
-        <result column="email" jdbcType="VARCHAR" property="email" />
-        <result column="score" jdbcType="VARCHAR" property="score" />
-        <result column="chapter_name" jdbcType="VARCHAR" property="chapterName" />
-        <result column="report_id" jdbcType="VARCHAR" property="reportId" />
+        <result column="school_name" jdbcType="VARCHAR" property="schoolName"/>
+        <result column="class_name" jdbcType="VARCHAR" property="className"/>
+        <result column="name" jdbcType="VARCHAR" property="name"/>
+        <result column="student_id" jdbcType="VARCHAR" property="studentId"/>
+        <result column="phone" jdbcType="VARCHAR" property="phone"/>
+        <result column="email" jdbcType="VARCHAR" property="email"/>
+        <result column="score" jdbcType="VARCHAR" property="score"/>
+        <result column="chapter_name" jdbcType="VARCHAR" property="chapterName"/>
+        <result column="report_id" jdbcType="VARCHAR" property="reportId"/>
     </resultMap>
 
     <select id="selectByCondition" resultMap="UserDtoMap">
@@ -411,6 +415,18 @@
         ORDER BY r.teacher_score DESC
     </select>
 
+    <select id="selectTeaExamAndUserDtos" resultMap="BaseResultMap">
+        select * from stu_userinfo u
+        where
+        u.role_id = 4
+        AND u.school_id = #{schoolId}
+        <if test="keyWord != null and keyWord!=''">
+            AND (u.name = #{keyWord} OR u.student_id = #{keyWord})
+        </if>
+        <if test="classId != null and classId !=''">
+            AND u.class_id = #{classId}
+        </if>
+    </select>
 
     <select id="getAllUsersByExamManageId" resultType="java.lang.Integer">
         SELECT SUM(user_count) AS total_user_count