<?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.qianhe.mapper.SjFybpWhMapper">
    
    <resultMap type="SjFybpWh" id="SjFybpWhResult">
        <result property="id"    column="id"    />
        <result property="fybpId"    column="fybp_id"    />
        <result property="syrq"    column="syrq"    />
        <result property="syje"    column="syje"    />
        <result property="remark"    column="remark"    />
        <result property="yl1"    column="yl1"    />
        <result property="yl2"    column="yl2"    />
        <result property="yl3"    column="yl3"    />
        <result property="yl4"    column="yl4"    />
        <result property="yl5"    column="yl5"    />
        <result property="zbId"    column="zb_id"    />
        <result property="fylx"    column="fylx"    />
    </resultMap>

    <sql id="selectSjFybpWhVo">
        select w.id, w.fybp_id, w.syrq, w.syje, w.remark, w.yl1, w.yl2, w.yl3, w.yl4, w.yl5,
               f.zb_id, f.fylx
        from sj_fybp_wh w
        left join sj_fybp f on w.fybp_id = f.id
    </sql>

    <select id="selectSjFybpWhList" parameterType="SjFybpWh" resultMap="SjFybpWhResult">
        <include refid="selectSjFybpWhVo"/>
        <where>  
            <if test="fybpId != null "> and w.fybp_id = #{fybpId}</if>
            <if test="syrq != null  and syrq != ''"> and w.syrq = #{syrq}</if>
            <if test="syje != null "> and w.syje = #{syje}</if>
            <if test="yl1 != null  and yl1 != ''"> and w.yl1 = #{yl1}</if>
            <if test="yl2 != null  and yl2 != ''"> and w.yl2 = #{yl2}</if>
            <if test="yl3 != null  and yl3 != ''"> and w.yl3 = #{yl3}</if>
            <if test="yl4 != null  and yl4 != ''"> and w.yl4 = #{yl4}</if>
            <if test="yl5 != null  and yl5 != ''"> and w.yl5 = #{yl5}</if>
        </where>
    </select>
    
    <select id="selectSjFybpWhById" parameterType="Long" resultMap="SjFybpWhResult">
        <include refid="selectSjFybpWhVo"/>
        where w.id = #{id}
    </select>
        
    <insert id="insertSjFybpWh" parameterType="SjFybpWh" useGeneratedKeys="true" keyProperty="id">
        insert into sj_fybp_wh
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fybpId != null">fybp_id,</if>
            <if test="syrq != null">syrq,</if>
            <if test="syje != null">syje,</if>
            <if test="remark != null">remark,</if>
            <if test="yl1 != null">yl1,</if>
            <if test="yl2 != null">yl2,</if>
            <if test="yl3 != null">yl3,</if>
            <if test="yl4 != null">yl4,</if>
            <if test="yl5 != null">yl5,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fybpId != null">#{fybpId},</if>
            <if test="syrq != null">#{syrq},</if>
            <if test="syje != null">#{syje},</if>
            <if test="remark != null">#{remark},</if>
            <if test="yl1 != null">#{yl1},</if>
            <if test="yl2 != null">#{yl2},</if>
            <if test="yl3 != null">#{yl3},</if>
            <if test="yl4 != null">#{yl4},</if>
            <if test="yl5 != null">#{yl5},</if>
         </trim>
    </insert>

    <update id="updateSjFybpWh" parameterType="SjFybpWh">
        update sj_fybp_wh
        <trim prefix="SET" suffixOverrides=",">
            <if test="fybpId != null">fybp_id = #{fybpId},</if>
            <if test="syrq != null">syrq = #{syrq},</if>
            <if test="syje != null">syje = #{syje},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="yl1 != null">yl1 = #{yl1},</if>
            <if test="yl2 != null">yl2 = #{yl2},</if>
            <if test="yl3 != null">yl3 = #{yl3},</if>
            <if test="yl4 != null">yl4 = #{yl4},</if>
            <if test="yl5 != null">yl5 = #{yl5},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSjFybpWhById" parameterType="Long">
        delete from sj_fybp_wh where id = #{id}
    </delete>

    <delete id="deleteSjFybpWhByIds" parameterType="String">
        delete from sj_fybp_wh where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>