<?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.GgFjbMapper">
    
    <resultMap type="GgFjb" id="GgFjbResult">
        <result property="ID"    column="ID"    />
        <result property="YWID"    column="YWID"    />
        <result property="FJMC"    column="FJMC"    />
        <result property="FJDZ"    column="FJDZ"    />
        <result property="MKMC"    column="MKMC"    />
        <result property="FJLX"    column="FJLX"    />
        <result property="CJR"    column="CJR"    />
        <result property="CJSJ"    column="CJSJ"    />
        <result property="XGR"    column="XGR"    />
        <result property="XGSJ"    column="XGSJ"    />
    </resultMap>

    <sql id="selectGgFjbVo">
        select ID, YWID, FJMC, FJDZ, MKMC, FJLX, CJR, CJSJ, XGR, XGSJ
        from gg_fjb
    </sql>
    <select id="selectGgFjbList" parameterType="GgFjb" resultMap="GgFjbResult">
        <include refid="selectGgFjbVo"/>
        <where>  
            <if test="YWID != null  and YWID != ''"> and YWID = #{YWID}</if>
            <if test="FJMC != null  and FJMC != ''"> and FJMC = #{FJMC}</if>
            <if test="FJDZ != null  and FJDZ != ''"> and FJDZ = #{FJDZ}</if>
            <if test="MKMC != null  and MKMC != ''"> and MKMC = #{MKMC}</if>
            <if test="FJLX != null  and FJLX != ''"> and FJLX = #{FJLX}</if>
            <if test="CJR != null  and CJR != ''"> and CJR = #{CJR}</if>
            <if test="CJSJ != null  and CJSJ != ''"> and CJSJ = #{CJSJ}</if>
            <if test="XGR != null  and XGR != ''"> and XGR = #{XGR}</if>
            <if test="XGSJ != null  and XGSJ != ''"> and XGSJ = #{XGSJ}</if>
        </where>
    </select>
    <select id="selectGgFjbByID" parameterType="Long" resultMap="GgFjbResult">
        <include refid="selectGgFjbVo"/>
        where ID = #{ID}
    </select>
        
    <insert id="insertGgFjb" parameterType="GgFjb" useGeneratedKeys="true" keyProperty="ID">
        insert into gg_fjb
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="YWID != null">YWID,</if>
            <if test="FJMC != null">FJMC,</if>
            <if test="FJDZ != null">FJDZ,</if>
            <if test="MKMC != null">MKMC,</if>
            <if test="FJLX != null">FJLX,</if>
            <if test="CJR != null">CJR,</if>
            <if test="CJSJ != null">CJSJ,</if>
            <if test="XGR != null">XGR,</if>
            <if test="XGSJ != null">XGSJ,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="YWID != null">#{YWID},</if>
            <if test="FJMC != null">#{FJMC},</if>
            <if test="FJDZ != null">#{FJDZ},</if>
            <if test="MKMC != null">#{MKMC},</if>
            <if test="FJLX != null">#{FJLX},</if>
            <if test="CJR != null">#{CJR},</if>
            <if test="CJSJ != null">#{CJSJ},</if>
            <if test="XGR != null">#{XGR},</if>
            <if test="XGSJ != null">#{XGSJ},</if>
         </trim>
    </insert>
    <update id="updateGgFjb" parameterType="GgFjb">
        update gg_fjb
        <trim prefix="SET" suffixOverrides=",">
            <if test="YWID != null">YWID = #{YWID},</if>
            <if test="FJMC != null">FJMC = #{FJMC},</if>
            <if test="FJDZ != null">FJDZ = #{FJDZ},</if>
            <if test="MKMC != null">MKMC = #{MKMC},</if>
            <if test="FJLX != null">FJLX = #{FJLX},</if>
            <if test="CJR != null">CJR = #{CJR},</if>
            <if test="CJSJ != null">CJSJ = #{CJSJ},</if>
            <if test="XGR != null">XGR = #{XGR},</if>
            <if test="XGSJ != null">XGSJ = #{XGSJ},</if>
        </trim>
        where ID = #{ID}
    </update>

    <delete id="deleteGgFjbByID" parameterType="Long">
        delete from gg_fjb where ID = #{ID}
    </delete>
    <delete id="deleteGgFjbByIDs" parameterType="String">
        delete from gg_fjb where ID in 
        <foreach item="ID" collection="array" open="(" separator="," close=")">
            #{ID}
        </foreach>
    </delete>




    <insert id="insertFj" parameterType="GgFjb">
        insert into gg_fjb
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="YWID != null">YWID,</if>
            <if test="FJMC != null">FJMC,</if>
            <if test="FJDZ != null">FJDZ,</if>
            <if test="MKMC != null">MKMC,</if>
            <if test="FJLX != null">FJLX,</if>
            <if test="CJR != null">CJR,</if>
            <if test="CJSJ != null">CJSJ,</if>
            <if test="XGR != null">XGR,</if>
            <if test="XGSJ != null">XGSJ,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="YWID != null">#{YWID},</if>
            <if test="FJMC != null">#{FJMC},</if>
            <if test="FJDZ != null">#{FJDZ},</if>
            <if test="MKMC != null">#{MKMC},</if>
            <if test="FJLX != null">#{FJLX},</if>
            <if test="CJR != null">#{CJR},</if>
            <if test="CJSJ != null">#{CJSJ},</if>
            <if test="XGR != null">#{XGR},</if>
            <if test="XGSJ != null">#{XGSJ},</if>
        </trim>
    </insert>
    <delete id="deleteFjByYwid" parameterType="GgFjb">
        delete from gg_fjb where YWID = #{YWID} AND FJLX =#{FJLX} AND MKMC =#{MKMC}
    </delete>
    <select id="selectFj" resultMap="GgFjbResult">
        select * from gg_fjb where YWID = #{id} and MKMC = #{mkmc};
    </select>
    <select id="selectFjByMk" resultMap="GgFjbResult">
        select * from gg_fjb where  MKMC = #{mkmc};
    </select>

</mapper>