<?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.fwFz.mapper.FwFzMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="fwFzResultMap" type="org.springblade.modules.rhzf.fwFz.entity.FwFzEntity">
        <result column="id" property="id"/>
        <result column="fw_id" property="fwId"/>
        <result column="type" property="type"/>
        <result column="fz_xm" property="fzXm"/>
        <result column="fz_sfzh" property="fzSfzh"/>
        <result column="fz_dh" property="fzDh"/>
        <result column="fz_dw" property="fzDw"/>
        <result column="fz_jzd" property="fzJzd"/>
        <result column="sfzcjz" property="sfzcjz"/>
        <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="selectFwFzPage" resultMap="fwFzResultMap">
        select * from rhzf_fw_fz where is_deleted = 0
    </select>


    <select id="exportFwFz" resultType="org.springblade.modules.rhzf.fwFz.excel.FwFzExcel">
        SELECT * FROM rhzf_fw_fz ${ew.customSqlSegment}
    </select>

    <select id="getFzList" resultType="org.springblade.modules.rhzf.fwFz.entity.FwFzEntity">
        SELECT
            *
        FROM
            rhzf_fw_fz
        WHERE
            is_deleted = 0
          AND fw_id = #{params.fwId} :: int8
        ORDER BY update_time DESC
        LIMIT 1
    </select>

    <select id="getFzById" resultMap="fwFzResultMap">
        SELECT
            *
        FROM
            rhzf_fw_fz
        WHERE
            is_deleted = 0
        AND fw_id = #{id}
        LIMIT 1
    </select>

    <update id="updateFzByFwId" parameterType="org.springblade.modules.rhzf.fwFz.entity.FwFzEntity">
        UPDATE jdrh.rhzf_fw_fz
        <set>
            update_time = now(),
            <if test="type != null and type != ''">type = #{type},</if>
            <if test="fzXm != null and fzXm != ''">fz_xm = #{fzXm},</if>
            <if test="fzSfzh != null and fzSfzh != ''">fz_sfzh = #{fzSfzh},</if>
            <if test="fzDh != null and fzDh != ''">fz_dh = #{fzDh},</if>
            <if test="fzDw != null and fzDw != ''">fz_dw = #{fzDw},</if>
            <if test="fzJzd != null and fzJzd != ''">fz_jzd = #{fzJzd},</if>
            <if test="sfzcjz != null and sfzcjz != ''">sfzcjz = #{sfzcjz},</if>
            <if test="vx != null and vx != ''">vx = #{vx},</if>
            <if test="hjdz != null and hjdz != ''">hjdz = #{hjdz},</if>
            <if test="tsqk != null">tsqk = #{tsqk},</if>
            <if test="mjId != null and mjId != ''">mj_id = #{mjId},</if>
            <if test="zjzl != null and zjzl != ''">zjzl = #{zjzl},</if>
        </set>
        WHERE is_deleted = 0 AND fw_id = #{fwId}
    </update>
</mapper>
