<?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.jianshui.invoice.mapper.SkDyjMapper">

    <resultMap type="SkDyj" id="SkDyjResult">
        <result property="id"    column="id"    />
        <result property="fpzlDm"    column="fpzl_dm"    />
        <result property="nsrsbh"    column="nsrsbh"    />
        <result property="mc"    column="mc"    />
        <result property="sbj"    column="sbj"    />
        <result property="zbj"    column="zbj"    />
        <result property="qybz"    column="qybz"    />
        <result property="sjzt"    column="sjzt"    />
        <result property="cjr"    column="cjr"    />
        <result property="cjsj"    column="cjsj"    />
        <result property="bjr"    column="bjr"    />
        <result property="bjsj"    column="bjsj"    />
        <result property="nsrmc"    column="nsrmc"    />
    </resultMap>

    <sql id="selectSkDyjVo">
        select id, fpzl_dm, nsrsbh, mc, sbj, zbj, qybz, sjzt, cjr, cjsj, bjr, bjsj, nsrmc from sk_dyj
    </sql>

    <select id="selectSkDyjList" parameterType="SkDyj" resultMap="SkDyjResult">
        <include refid="selectSkDyjVo"/>
        <where>
            <if test="fpzlDm != null  and fpzlDm != ''"> and fpzl_dm = #{fpzlDm}</if>
            <if test="nsrsbh != null  and nsrsbh != ''"> and nsrsbh = #{nsrsbh}</if>
            <if test="mc != null  and mc != ''"> and mc = #{mc}</if>
            <if test="sbj != null "> and sbj = #{sbj}</if>
            <if test="zbj != null "> and zbj = #{zbj}</if>
            <if test="qybz != null "> and qybz = #{qybz}</if>
            <if test="sjzt != null "> and sjzt = #{sjzt}</if>
            <if test="cjr != null  and cjr != ''"> and cjr = #{cjr}</if>
            <if test="cjsj != null "> and cjsj = #{cjsj}</if>
            <if test="bjr != null  and bjr != ''"> and bjr = #{bjr}</if>
            <if test="bjsj != null "> and bjsj = #{bjsj}</if>
            <if test="nsrmc != null  and nsrmc != ''"> and nsrmc = #{nsrmc}</if>
        </where>
    </select>

    <select id="selectSkDyjById" parameterType="Long" resultMap="SkDyjResult">
        <include refid="selectSkDyjVo"/>
        where id = #{id}
    </select>

    <insert id="insertSkDyj" parameterType="SkDyj" useGeneratedKeys="true" keyProperty="id">
        insert into sk_dyj
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fpzlDm != null">fpzl_dm,</if>
            <if test="nsrsbh != null">nsrsbh,</if>
            <if test="mc != null">mc,</if>
            <if test="sbj != null">sbj,</if>
            <if test="zbj != null">zbj,</if>
            <if test="qybz != null">qybz,</if>
            <if test="sjzt != null">sjzt,</if>
            <if test="cjr != null">cjr,</if>
            <if test="cjsj != null">cjsj,</if>
            <if test="bjr != null">bjr,</if>
            <if test="bjsj != null">bjsj,</if>
            <if test="nsrmc != null and nsrmc != ''">nsrmc,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fpzlDm != null">#{fpzlDm},</if>
            <if test="nsrsbh != null">#{nsrsbh},</if>
            <if test="mc != null">#{mc},</if>
            <if test="sbj != null">#{sbj},</if>
            <if test="zbj != null">#{zbj},</if>
            <if test="qybz != null">#{qybz},</if>
            <if test="sjzt != null">#{sjzt},</if>
            <if test="cjr != null">#{cjr},</if>
            <if test="cjsj != null">#{cjsj},</if>
            <if test="bjr != null">#{bjr},</if>
            <if test="bjsj != null">#{bjsj},</if>
            <if test="nsrmc != null and nsrmc != ''">#{nsrmc},</if>
         </trim>
    </insert>

    <update id="updateSkDyj" parameterType="SkDyj">
        update sk_dyj
        <trim prefix="SET" suffixOverrides=",">
            <if test="fpzlDm != null">fpzl_dm = #{fpzlDm},</if>
            <if test="nsrsbh != null">nsrsbh = #{nsrsbh},</if>
            <if test="mc != null">mc = #{mc},</if>
            <if test="sbj != null">sbj = #{sbj},</if>
            <if test="zbj != null">zbj = #{zbj},</if>
            <if test="qybz != null">qybz = #{qybz},</if>
            <if test="sjzt != null">sjzt = #{sjzt},</if>
            <if test="cjr != null">cjr = #{cjr},</if>
            <if test="cjsj != null">cjsj = #{cjsj},</if>
            <if test="bjr != null">bjr = #{bjr},</if>
            <if test="bjsj != null">bjsj = #{bjsj},</if>
            <if test="nsrmc != null and nsrmc != ''">nsrmc = #{nsrmc},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSkDyjById" parameterType="Long">
        delete from sk_dyj where id = #{id}
    </delete>

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