<?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="className != null"> and class_name = #{className} </if> <if test="studentNumber != null"> and student_number =#{studentNumber} </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>