<?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.ruoyi.system.mapper.ElPaperMapper">

    <resultMap id="BaseResultMap" type="com.ruoyi.system.domain.paper.ElPaper">
            <id property="id" column="id" jdbcType="VARCHAR"/>
            <result property="userId" column="user_id" jdbcType="BIGINT"/>
            <result property="departId" column="depart_id" jdbcType="BIGINT"/>
            <result property="examId" column="exam_id" jdbcType="VARCHAR"/>
            <result property="title" column="title" jdbcType="VARCHAR"/>
            <result property="totalTime" column="total_time" jdbcType="INTEGER"/>
            <result property="userTime" column="user_time" jdbcType="INTEGER"/>
            <result property="totalScore" column="total_score" jdbcType="INTEGER"/>
            <result property="qualifyScore" column="qualify_score" jdbcType="INTEGER"/>
            <result property="objScore" column="obj_score" jdbcType="INTEGER"/>
            <result property="subjScore" column="subj_score" jdbcType="INTEGER"/>
            <result property="userScore" column="user_score" jdbcType="INTEGER"/>
            <result property="hasSaq" column="has_saq" jdbcType="TINYINT"/>
            <result property="state" column="state" jdbcType="INTEGER"/>
            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
            <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
            <result property="limitTime" column="limit_time" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        id,user_id,depart_id,
        exam_id,title,total_time,
        user_time,total_score,qualify_score,
        obj_score,subj_score,user_score,
        has_saq,state,create_time,
        update_time,limit_time
    </sql>

    <select id="paging" parameterType="com.ruoyi.system.domain.paper.dto.request.PaperListReqDTO" resultType="com.ruoyi.system.domain.paper.dto.response.PaperListRespDTO">
        SELECT pp.*,uc.user_name FROM el_paper pp
        LEFT JOIN ${prefix}sys_user uc ON pp.user_id=uc.user_id
        <trim prefix="where" prefixOverrides="and|or">
            <if test="examId!=null and examId!=''">
                AND pp.exam_id=#{examId}
            </if>
            <if test="userId!=null and userId!=''">
                AND pp.user_id=#{userId}
            </if>
            <if test="departId!=null and departId!=''">
                AND pp.depart_id=#{departId}
            </if>
            <if test="state!=null">
                AND pp.state=#{state}
            </if>
            <if test="userName!=null and userName!=''">
                AND uc.user_name  LIKE CONCAT('%',#{userName},'%')
            </if>
        </trim>
        ORDER BY create_time DESC

    </select>
</mapper>
