Files
pengchen-exam-java/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperPersonMapper.xml
2025-04-25 15:51:06 +08:00

186 lines
7.3 KiB
XML

<?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="pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperPersonMapper">
<resultMap type="EducationPaperPerson" id="EducationPaperPersonResult">
<result property="taskId" column="task_id" />
<result property="personId" column="person_id" />
<result property="sessionId" column="session_id" />
<result property="batch" column="batch" />
</resultMap>
<sql id="selectEducationPaperPersonVo">
select task_id, person_id, session_id,batch from education_paper_person
</sql>
<select id="selectEducationPaperPersonList" parameterType="EducationPaperPerson" resultMap="EducationPaperPersonResult">
<include refid="selectEducationPaperPersonVo"/>
<where>
<if test="taskId != null and taskId != ''"> and task_id = #{taskId}</if>
<if test="personId != null and personId != ''"> and person_id = #{personId}</if>
<if test="sessionId != null and sessionId != ''"> and session_id = #{sessionId}</if>
<if test="batch != null and batch != ''"> and batch = #{batch}</if>
</where>
</select>
<select id="selectEducationPaperPersonByTaskId" parameterType="String" resultMap="EducationPaperPersonResult">
<include refid="selectEducationPaperPersonVo"/>
where task_id = #{taskId}
</select>
<select id="selectUserById" resultType="pc.exam.pp.module.exam.controller.admin.paper.dto.PersonRepDto">
select * from system_users where id =#{personId}
</select>
<select id="selectUserClassName" resultType="java.lang.String">
select name from exam_class where id =#{classId}
</select>
<select id="selectEducationPaperPersonBySessionId" parameterType="String" resultMap="EducationPaperPersonResult">
<include refid="selectEducationPaperPersonVo"/>
where session_id = #{sessionId}
</select>
<select id="selectEducationPaperPersonByNotInSessionId"
resultType="pc.exam.pp.module.exam.controller.admin.paper.dto.PersonRepDto">
SELECT DISTINCT s.*
FROM system_users s
LEFT JOIN education_paper_person pp ON s.id = pp.person_id
WHERE
s.user_type = #{userType}
AND s.id IN (
SELECT person_id FROM education_paper_person WHERE
session_id ='' and
session_id !=#{sessionId} and task_id =#{taskId}
)
<if test="username != null and username != ''">
AND s.username LIKE CONCAT('%', #{username}, '%')
</if>
<if test="status != null">
AND s.status = #{status}
</if>
<if test="startTime != null and endTime != null">
AND s.create_time BETWEEN #{startTime} AND #{endTime}
</if>
<if test="classId != null and classId != ''">
AND s.class_id = #{classId}
</if>
ORDER BY s.id DESC
</select>
<select id="selectUserClassIdByName" resultType="java.lang.Long">
select id from exam_class where name =#{className} and deleted ='0'
</select>
<select id="selectByTaskIdAndPersonId" resultMap="EducationPaperPersonResult">
<include refid="selectEducationPaperPersonVo"/>
where task_id = #{taskId}
and person_id =#{studentId}
</select>
<select id="selectEducationPaperPersonBySessionIdNotIn"
resultType="pc.exam.pp.module.exam.controller.admin.paper.dto.PersonRepDto">
SELECT DISTINCT s.*
FROM system_users s
LEFT JOIN education_paper_person pp ON s.id = pp.person_id
WHERE
s.user_type = #{userType}
AND s.id NOT IN (
SELECT person_id FROM education_paper_person WHERE task_id =#{taskId}
)
<if test="username != null and username != ''">
AND s.username LIKE CONCAT('%', #{username}, '%')
</if>
<if test="status != null">
AND s.status = #{status}
</if>
<if test="startTime != null and endTime != null">
AND s.create_time BETWEEN #{startTime} AND #{endTime}
</if>
<if test="classId != null and classId != ''">
AND s.class_id = #{classId}
</if>
ORDER BY s.id DESC
</select>
<insert id="insertEducationPaperPerson" parameterType="EducationPaperPerson">
insert into education_paper_person
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="taskId != null">task_id,</if>
<if test="personId != null">person_id,</if>
<if test="sessionId != null">session_id,</if>
<if test="batch != null">batch,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="taskId != null">#{taskId},</if>
<if test="personId != null">#{personId},</if>
<if test="sessionId != null">#{sessionId},</if>
<if test="batch != null">#{batch},</if>
</trim>
</insert>
<insert id="insertEducationPaperPersonList">
insert into education_paper_person (task_id, person_id, session_id, batch) VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.taskId}, #{item.personId}, #{item.sessionId}, #{item.batch}
)
</foreach>
</insert>
<update id="updateEducationPaperPerson" parameterType="EducationPaperPerson">
update education_paper_person
<trim prefix="SET" suffixOverrides=",">
<if test="personId != null">person_id = #{personId},</if>
<if test="sessionId != null">session_id = #{sessionId},</if>
<if test="batch != null">batch = #{batch},</if>
</trim>
where task_id = #{taskId}
</update>
<update id="updateByTaskIdAndStuId">
update education_paper_person set session_id =#{sessionId},batch =#{batch}
where task_id =#{taskId} and person_id=#{personId}
</update>
<delete id="deleteEducationPaperPersonByTaskId" parameterType="String">
delete from education_paper_person where task_id = #{taskId}
</delete>
<delete id="deleteEducationPaperPersonByTaskIds" parameterType="String">
delete from education_paper_person where task_id in
<foreach item="taskId" collection="array" open="(" separator="," close=")">
#{taskId}
</foreach>
</delete>
<delete id="removeSessionStu" >
DELETE FROM education_paper_person
WHERE session_id = #{sessionId}
AND task_id = #{taskId}
AND batch = #{batch}
AND person_id IN
<foreach collection="studentIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<delete id="deleteEducationPaperPersonBySessionkIds">
delete from education_paper_person where education_paper_person.session_id in
<foreach item="sessionId" collection="array" open="(" separator="," close=")">
#{sessionId}
</foreach>
</delete>
<delete id="removeTaskStu">
DELETE FROM education_paper_person
WHERE task_id = #{taskId}
AND person_id IN
<foreach collection="studentIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>