<?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.SjGztzMapper">
    
    <resultMap type="SjGztz" id="SjGztzResult">
        <result property="id"    column="id"    />
        <result property="jh"    column="jh"    />
        <result property="gzlx"    column="gzlx"    />
        <result property="lj"    column="lj"    />
        <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="selectSjGztzVo">
        select id, jh, gzlx, lj, bz, created_by, created_time, update_by, update_time from sj_gztz
    </sql>

    <select id="selectSjGztzList" parameterType="SjGztz" resultMap="SjGztzResult">
        <include refid="selectSjGztzVo"/>
        <where>  
            <if test="jh != null  and jh != ''"> and jh = #{jh}</if>
            <if test="gzlx != null  and gzlx != ''"> and gzlx = #{gzlx}</if>
            <if test="lj != null  and lj != ''"> and lj = #{lj}</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="selectSjGztzById" parameterType="Long" resultMap="SjGztzResult">
        <include refid="selectSjGztzVo"/>
        where id = #{id}
    </select>

    <insert id="insertSjGztz" parameterType="SjGztz" useGeneratedKeys="true" keyProperty="id">
        insert into sj_gztz
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="jh != null">jh,</if>
            <if test="gzlx != null">gzlx,</if>
            <if test="lj != null">lj,</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="gzlx != null">#{gzlx},</if>
            <if test="lj != null">#{lj},</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="insertSjGztzBatch">
        INSERT INTO sj_gztz
        (jh, gzlx, lj, bz)
        VALUES
        <foreach collection="list" item="item" separator=",">
            (
            #{item.jh},
            #{item.gzlx},
            #{item.lj},
            #{item.bz}
            )
        </foreach>
    </insert>

    <update id="updateSjGztz" parameterType="SjGztz">
        update sj_gztz
        <trim prefix="SET" suffixOverrides=",">
            <if test="jh != null">jh = #{jh},</if>
            <if test="gzlx != null">gzlx = #{gzlx},</if>
            <if test="lj != null">lj = #{lj},</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="deleteSjGztzById" parameterType="Long">
        delete from sj_gztz where id = #{id}
    </delete>

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