<?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.gkhy.exam.system.mapper.ExPaperStudentMapper">
|
<resultMap type="com.gkhy.exam.system.domain.ExPaperStudent" id="ExPaperStudentResult">
|
<result property="id" column="id" />
|
<result property="paperId" column="paper_id" />
|
<result property="studentId" column="student_id" />
|
<result property="score" column="score" />
|
<result property="passed" column="passed" />
|
<result property="useTime" column="use_time" />
|
<result property="completed" column="completed" />
|
<result property="version" column="version" />
|
<result property="createBy" column="create_by" />
|
<result property="createTime" column="create_time" />
|
<result property="updateBy" column="update_by" />
|
<result property="updateTime" column="update_time" />
|
<result property="remark" column="remark" />
|
<result property="studentName" column="student_name" />
|
<result property="studentPhone" column="student_phone" />
|
<result property="paperName" column="paper_name" />
|
<collection property="singleQuestions" ofType="com.gkhy.exam.system.domain.ExQuestion" select="getQuestionByPaperId" column="{paperId=paper_id,studentId=student_id,completed=completed,questionType=1}"/>
|
<collection property="multiQuestions" ofType="com.gkhy.exam.system.domain.ExQuestion" select="getQuestionByPaperId" column="{paperId=paper_id,studentId=student_id,completed=completed,questionType=2}"/>
|
<collection property="judgeQuestions" ofType="com.gkhy.exam.system.domain.ExQuestion" select="getQuestionByPaperId" column="{paperId=paper_id,studentId=student_id,completed=completed,questionType=3}"/>
|
</resultMap>
|
|
<resultMap type="com.gkhy.exam.system.domain.ExQuestion" id="ExQuestionResult">
|
<result property="id" column="id" />
|
<association property="studentAnswer" javaType="com.gkhy.exam.system.domain.ExStudentAnswer" resultMap="studentAnswerResult" />
|
</resultMap>
|
|
<resultMap id="studentAnswerResult" type="com.gkhy.exam.system.domain.ExStudentAnswer">
|
<result property="id" column="answer_id" />
|
<result property="paperId" column="answer_paper_id" />
|
<result property="studentId" column="answer_student_id" />
|
<result property="questionId" column="answer_question_id" />
|
<result property="answer" column="answer_answer" />
|
<result property="passed" column="answer_passed" />
|
</resultMap>
|
|
<insert id="batchInsert">
|
insert into ex_paper_student(paper_id,student_id) values
|
<foreach collection="list" item="item" index="index" separator=",">
|
(#{item.paperId},#{item.studentId})
|
</foreach>
|
</insert>
|
|
<select id="countByPaperId" resultType="java.lang.Integer">
|
select count(1) from ex_paper_student where paper_id=#{paperId}
|
</select>
|
|
<select id="selectCountByPaperStudentId" resultType="java.lang.Integer">
|
select count(1) from ex_paper_student where paper_id=#{paperId} and student_id=#{studentId}
|
</select>
|
|
<select id="selectPaperStudentList" resultType="com.gkhy.exam.system.domain.ExPaperStudent">
|
select a.*,b.id as student_id,b.phone as student_phone,b.name as student_name,c.name as paperName from ex_paper_student a
|
left join ex_student b on a.student_id=b.id
|
left join ex_exam_paper c on c.id=a.paper_id
|
<where>
|
<if test="paperId!=null'">
|
and a.paper_id=#{paperId}
|
</if>
|
<if test="studentName!=null and studentName!=''">
|
and b.name like concat('%',#{studentName},'%')
|
</if>
|
<if test="phone!=null and phone!=''">
|
and b.phone like concat('%',#{phone},'%')
|
</if>
|
<if test="studentId!=null">
|
and a.student_id = #{studentId}
|
</if>
|
</where>
|
order by a.id desc
|
</select>
|
|
<select id="selectPaperStudentById" resultMap="ExPaperStudentResult">
|
select a.*,b.id as student_id,b.phone as student_phone,b.name as student_name,c.name as paperName from ex_paper_student a
|
left join ex_student b on a.student_id=b.id
|
left join ex_exam_paper c on c.id=a.paper_id
|
where a.id=#{paperStudentId}
|
</select>
|
|
<select id="selectByPaperStudentId" resultType="com.gkhy.exam.system.domain.ExPaperStudent">
|
select a.*,b.id as student_id,b.phone as student_phone,b.name as student_name from ex_paper_student a
|
left join ex_student b on a.student_id=b.id
|
left join ex_exam_paper c on c.id=a.paper_id
|
where a.paper_id=#{paperId} and a.student_id=#{studentId}
|
</select>
|
|
<select id="getQuestionByPaperId" resultType="com.gkhy.exam.system.domain.ExQuestion">
|
select a.id,a.question_type,a.bank_id,a.company_id,a.status,
|
<if test="completed!=null and completed=1">
|
a.answer,
|
</if>
|
a.title,a.privatize,a.content,
|
c.id as answer_id,c.paper_id as answer_paper_id,c.student_id as answer_student_id,c.question_id as answer_question_id,c.answer as answer_answer,
|
<if test="completed!=null and completed=1">
|
c.passed as answer_passed
|
</if>
|
from ex_question a
|
inner join ex_paper_question b on a.id=b.question_id
|
left join ex_student_answer c on c.question_id=a.id and c.student_id=#{studentId} and c.paper_id=#{paperId}
|
where b.paper_id=#{paperId} and a.question_type=#{questionType}
|
</select>
|
</mapper>
|