<?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="org.springblade.modules.wgr.check.mapper.CheckMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="checkResultMap" type="org.springblade.modules.wgr.check.entity.CheckEntity">
        <result column="id" property="id"/>
        <result column="wgr_id" property="wgrId"/>
        <result column="zjhm_sfbg" property="zjhmSfbg"/>
        <result column="zjhm_bgqk" property="zjhmBgqk"/>
        <result column="qzzl" property="qzzl"/>
        <result column="zcjz" property="zcjz"/>
        <result column="zsdjxx" property="zsdjxx"/>
        <result column="zzzxzt" property="zzzxzt"/>
        <result column="zzzxqk" property="zzzxqk"/>
        <result column="dthdqk" property="dthdqk"/>
        <result column="bz" property="bz"/>
        <result column="hyzp" property="hyzp"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
    </resultMap>


    <select id="selectCheckPage" resultType="org.springblade.modules.wgr.check.vo.CheckVO">
        SELECT
            *
        FROM
            wgr_check
        WHERE
            is_deleted = 0
          AND wgr_id = #{params.wgrId} :: int8
        ORDER BY
            create_time DESC
    </select>

    <select id="getChecked" resultType="org.springblade.modules.wgr.check.vo.CheckVO">
        SELECT
            wc.id,
            wi.ywxm,
            wi.xb,
            wi.lxdh,
            wi.zjzl,
            wi.zjhm,
            wi.gjdq,
            wi.jzddz,
            wc.create_time
        FROM
            wgr_check wc
        LEFT JOIN wgr_info wi ON wi.id = wc.wgr_id
        WHERE
            wc.is_deleted = 0
          AND wi.is_deleted = 0
          AND wc.create_user = #{params.userId} :: int8
        ORDER BY
            wc.create_time DESC
    </select>

    <select id="exportCheck" resultType="org.springblade.modules.wgr.check.excel.CheckExcel">
        SELECT * FROM wgr_check ${ew.customSqlSegment}
    </select>

</mapper>
