<?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.ruoyi.project.zjsgfa.mapper.SjTgTgzMapper">
    
    <resultMap type="SjTgTgz" id="SjTgTgzResult">
        <result property="id"    column="id"    />
        <result property="jh"    column="jh"    />
        <result property="kc"    column="kc"    />
        <result property="jd"    column="jd"    />
        <result property="wj"    column="wj"    />
        <result property="gj"    column="gj"    />
        <result property="bh"    column="bh"    />
        <result property="kx"    column="kx"    />
        <result property="zjsknj"    column="zjsknj"    />
        <result property="cd"    column="cd"    />
        <result property="zjymd"    column="zjymd"    />
        <result property="bz"    column="bz"    />
        <result property="createdBy"    column="created_by"    />
        <result property="createdTime"    column="created_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectSjTgTgzVo">
        select id, jh, kc, jd, wj, gj, bh, kx, zjsknj, cd, zjymd, bz, created_by, created_time, update_by, update_time from sj_tg_tgz
    </sql>

    <select id="selectSjTgTgzList" parameterType="SjTgTgz" resultMap="SjTgTgzResult">
        <include refid="selectSjTgTgzVo"/>
        <where>  
            <if test="jh != null  and jh != ''"> and jh = #{jh}</if>
            <if test="kc != null  and kc != ''"> and kc = #{kc}</if>
            <if test="jd != null  and jd != ''"> and jd = #{jd}</if>
            <if test="wj != null "> and wj = #{wj}</if>
            <if test="gj != null  and gj != ''"> and gj = #{gj}</if>
            <if test="bh != null "> and bh = #{bh}</if>
            <if test="kx != null  and kx != ''"> and kx = #{kx}</if>
            <if test="zjsknj != null "> and zjsknj = #{zjsknj}</if>
            <if test="cd != null "> and cd = #{cd}</if>
            <if test="zjymd != null "> and zjymd = #{zjymd}</if>
            <if test="bz != null  and bz != ''"> and bz = #{bz}</if>
            <if test="createdBy != null  and createdBy != ''"> and created_by = #{createdBy}</if>
            <if test="createdTime != null "> and created_time = #{createdTime}</if>
        </where>
    </select>
    
    <select id="selectSjTgTgzById" parameterType="Long" resultMap="SjTgTgzResult">
        <include refid="selectSjTgTgzVo"/>
        where id = #{id}
    </select>

    <insert id="insertSjTgTgz" parameterType="SjTgTgz" useGeneratedKeys="true" keyProperty="id">
        insert into sj_tg_tgz
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="jh != null">jh,</if>
            <if test="kc != null">kc,</if>
            <if test="jd != null">jd,</if>
            <if test="wj != null">wj,</if>
            <if test="gj != null">gj,</if>
            <if test="bh != null">bh,</if>
            <if test="kx != null">kx,</if>
            <if test="zjsknj != null">zjsknj,</if>
            <if test="cd != null">cd,</if>
            <if test="zjymd != null">zjymd,</if>
            <if test="bz != null">bz,</if>
            <if test="createdBy != null">created_by,</if>
            <if test="createdTime != null">created_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="jh != null">#{jh},</if>
            <if test="kc != null">#{kc},</if>
            <if test="jd != null">#{jd},</if>
            <if test="wj != null">#{wj},</if>
            <if test="gj != null">#{gj},</if>
            <if test="bh != null">#{bh},</if>
            <if test="kx != null">#{kx},</if>
            <if test="zjsknj != null">#{zjsknj},</if>
            <if test="cd != null">#{cd},</if>
            <if test="zjymd != null">#{zjymd},</if>
            <if test="bz != null">#{bz},</if>
            <if test="createdBy != null">#{createdBy},</if>
            <if test="createdTime != null">#{createdTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>
    <insert id="insertSjTgTgzBatch">
        INSERT INTO sj_tg_tgz
        (jh, kc, jd, wj, gj, bh, kx, zjsknj, cd, zjymd, bz)
        VALUES
        <foreach collection="list" item="item" separator=",">
            (
            #{item.jh},
            #{item.kc},
            #{item.jd},
            #{item.wj},
            #{item.gj},
            #{item.bh},
            #{item.kx},
            #{item.zjsknj},
            #{item.cd},
            #{item.zjymd},
            #{item.bz}
            )
        </foreach>
    </insert>

    <update id="updateSjTgTgz" parameterType="SjTgTgz">
        update sj_tg_tgz
        <trim prefix="SET" suffixOverrides=",">
            <if test="jh != null">jh = #{jh},</if>
            <if test="kc != null">kc = #{kc},</if>
            <if test="jd != null">jd = #{jd},</if>
            <if test="wj != null">wj = #{wj},</if>
            <if test="gj != null">gj = #{gj},</if>
            <if test="bh != null">bh = #{bh},</if>
            <if test="kx != null">kx = #{kx},</if>
            <if test="zjsknj != null">zjsknj = #{zjsknj},</if>
            <if test="cd != null">cd = #{cd},</if>
            <if test="zjymd != null">zjymd = #{zjymd},</if>
            <if test="bz != null">bz = #{bz},</if>
            <if test="createdBy != null">created_by = #{createdBy},</if>
            <if test="createdTime != null">created_time = #{createdTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSjTgTgzById" parameterType="Long">
        delete from sj_tg_tgz where id = #{id}
    </delete>

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