StudentDetailMapper.xml
3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?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.jevon.mapper.StudentDetailMapper" >
<resultMap id="BaseResultMap" type="com.jevon.model.StudentDetail" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="open_id" property="analyseId" jdbcType="INTEGER" />
<result column="school_name" property="schoolName" jdbcType="VARCHAR" />
<result column="class_name" property="className" jdbcType="VARCHAR" />
<result column="student_name" property="studentName" jdbcType="VARCHAR" />
<result column="student_number" property="studentNumber" jdbcType="VARCHAR" />
<result column="analyse_id" property="analyseId" jdbcType="INTEGER" />
<result column="exam_number" property="examNumber" jdbcType="VARCHAR" />
<result column="score" property="score" jdbcType="FLOAT" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="correct" property="correct" jdbcType="INTEGER" />
</resultMap>
<insert id="insertBatch" parameterType="java.util.List">
insert into sz_learn_student_detail (school_name, class_name,student_name,
student_number,analyse_id,exam_number,score,create_time,correct)
values
<foreach collection="list" item="emp" separator=",">
(#{emp.schoolName},#{emp.className},#{emp.studentName},
#{emp.studentNumber},#{emp.analyseId},#{emp.examNumber},#{emp.score},#{emp.createTime},#{emp.correct})
</foreach>
</insert>
<select id="selectSumScore" parameterType="com.jevon.model.StudentDetail" resultType="java.lang.Double">
SELECT sum(score) FROM sz_learn_student_detail
<where>
<if test="analyseId != 0">
and analyse_id = #{analyseId}
</if>
<if test="schoolName != null">
and school_name = #{schoolName}
</if>
<if test="examNumber != null">
and exam_number = #{examNumber}
</if>
<if test="schoolNames != null and schoolNames.size()>0">
AND school_name IN
<foreach item="item" index="index" collection="schoolNames" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="examNumbers != null and examNumbers.size()>0">
AND exam_number IN
<foreach item="item" index="index" collection="examNumbers" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectTrueByExamNumber" parameterType="com.jevon.model.StudentDetail" resultType="java.lang.Integer">
select count(*) from sz_learn_student_detail
<where>
<if test="analyseId != 0">
and analyse_id = #{analyseId}
</if>
<if test="schoolName != null">
and school_name = #{schoolName}
</if>
<if test="examNumber != null">
and exam_number = #{examNumber}
</if>
<if test="studentNumbers != null and studentNumbers.size()>0">
AND student_number IN
<foreach item="item" index="index" collection="studentNumbers" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="schoolNames != null and schoolNames.size()>0">
AND school_name IN
<foreach item="item" index="index" collection="schoolNames" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="examNumbers != null and examNumbers.size()>0">
AND exam_number IN
<foreach item="item" index="index" collection="examNumbers" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
and correct = 1
</select>
</mapper>