<?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.rhzf.fwqz.mapper.RhzfFwqzMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="rhzfFwqzResultMap" type="org.springblade.modules.rhzf.fwqz.pojo.entity.RhzfFwqzEntity">
        <result column="fw_id" property="fwId"/>
        <result column="dzbm" property="dzbm"/>
        <result column="fwlx" property="fwlx"/>
        <result column="xm" property="xm"/>
        <result column="sfzh" property="sfzh"/>
        <result column="blyw" property="blyw"/>
        <result column="swtrxm" property="swtrxm"/>
        <result column="swtrsfzh" property="swtrsfzh"/>
        <result column="fj" property="fj"/>
        <result column="smyy" property="smyy"/>
        <result column="yydd" property="yydd"/>
        <result column="yysj" property="yysj"/>
    </resultMap>

    <select id="selectRhzfFwqzPage" resultMap="rhzfFwqzResultMap">
        SELECT
            rf.*
        FROM
            jdrh.rhzf_fwqz rf
        LEFT JOIN jdrh.blade_dept bd ON bd.id = rf.create_dept
        WHERE
            rf.is_deleted = 0
        AND rf.fwlx = #{params.fwlx}
        AND (bd.parent_id = #{params.pcsId} :: int8 OR bd.ancestors LIKE '%' || #{params.deptId} || '%')
    </select>

    <select id="exportRhzfFwqz" resultType="org.springblade.modules.rhzf.fwqz.excel.RhzfFwqzExcel">
        SELECT * FROM rhzf_fwqz ${ew.customSqlSegment}
    </select>

    <select id="getByDzbm" resultType="org.springblade.modules.rhzf.fwqz.pojo.entity.RhzfFwqzEntity">
        SELECT * FROM jdrh.rhzf_fwqz WHERE is_deleted = 0 AND dzbm = #{params.dzbm} ORDER BY update_time DESC
    </select>
</mapper>
