<?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.wgz.mapper.WgzReissueacardMapper">

    <resultMap type="com.ruoyi.wgz.domain.WgzReissueacard" id="WgzReissueacardResult">
        <result property="id" column="id"/>
        <result property="recruitId" column="recruit_id"/>
        <result property="userId" column="user_id"/>
        <result property="attendanceId" column="attendance_id"/>
        <result property="type" column="type"/>
        <result property="recruitName" column="recruit_name"/>
        <result property="rawTime" column="raw_time"/>
        <result property="nowTime" column="now_time"/>
        <result property="reason" column="reason"/>
        <result property="auditorUserId" column="auditor_user_id"/>
        <result property="auditorType" column="auditor_type"/>
        <result property="auditorOpinion" column="auditor_opinion"/>
        <result property="auditorTime" column="auditor_time"/>
        <result property="delFlag" column="del_flag"/>
        <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"/>
    </resultMap>

    <select id="userReplacementCardRecordListPage" resultType="com.ruoyi.wgz.bo.res.WgzReplacementCardRecordRes">
        SELECT
            a.*,
            b.username,
            b.avatar_name,
            c.username as userName
        FROM
            wgz_reissueacard a
                LEFT JOIN bgt_user b ON (a.auditor_user_id = b.user_id and b.del_flag = 0)
                LEFT JOIN wgz_user c ON (a.user_id = c.user_id and c.del_flag = 0)
        WHERE
            a.user_id = #{userId} and a.del_flag = 0
        ORDER BY
            a.id DESC
    </select>


    <select id="appQueryPageList" resultType="com.ruoyi.wgz.bo.res.WgzReplacementCardRecordRes">
        SELECT
            a.*,
            b.username,
            b.avatar_name,
            c.username as userName
        FROM
            wgz_reissueacard a
                LEFT JOIN bgt_user b ON (a.auditor_user_id = b.user_id and b.del_flag = 0)
                LEFT JOIN wgz_user c ON (a.user_id = c.user_id and c.del_flag = 0)
        WHERE
            a.auditor_user_id = #{dto.auditorUserId}
            and a.recruit_id in (select id from bgt_project_recruit where task_id = #{dto.taskId})
        <if test="dto.auditorType != null and dto.auditorType != ''">
            and w.auditor_type = #{dto.auditorType}
        </if>
        <if test="dto.nowTime != null">
            and w.now_time = #{dto.nowTime}
        </if>
        ORDER BY
            a.id DESC
    </select>

</mapper>
