<?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.SjZlyqMapper">
    
    <resultMap type="SjZlyq" id="SjZlyqResult">
        <result property="id"    column="id"    />
        <result property="jh"    column="jh"    />
        <result property="jd"    column="jd"    />
        <result property="jxj"    column="jxj"    />
        <result property="qjbhl"    column="qjbhl"    />
        <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="selectSjZlyqVo">
        select id, jh, jd, jxj, qjbhl, bz, created_by, created_time, update_by, update_time from sj_zlyq
    </sql>

    <select id="selectSjZlyqList" parameterType="SjZlyq" resultMap="SjZlyqResult">
        <include refid="selectSjZlyqVo"/>
        <where>  
            <if test="jh != null  and jh != ''"> and jh = #{jh}</if>
            <if test="jd != null  and jd != ''"> and jd = #{jd}</if>
            <if test="jxj != null "> and jxj = #{jxj}</if>
            <if test="qjbhl != null "> and qjbhl = #{qjbhl}</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="selectSjZlyqById" parameterType="Long" resultMap="SjZlyqResult">
        <include refid="selectSjZlyqVo"/>
        where id = #{id}
    </select>

    <insert id="insertSjZlyq" parameterType="SjZlyq" useGeneratedKeys="true" keyProperty="id">
        insert into sj_zlyq
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="jh != null">jh,</if>
            <if test="jd != null">jd,</if>
            <if test="jxj != null">jxj,</if>
            <if test="qjbhl != null">qjbhl,</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="jd != null">#{jd},</if>
            <if test="jxj != null">#{jxj},</if>
            <if test="qjbhl != null">#{qjbhl},</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="insertSjZlyqBatch">
        INSERT INTO sj_zlyq
        (jh, jd, jxj, qjbhl, bz)
        VALUES
        <foreach collection="list" item="item" separator=",">
            (
            #{item.jh},
            #{item.jd},
            #{item.jxj},
            #{item.qjbhl},
            #{item.bz}
            )
        </foreach>
    </insert>

    <update id="updateSjZlyq" parameterType="SjZlyq">
        update sj_zlyq
        <trim prefix="SET" suffixOverrides=",">
            <if test="jh != null">jh = #{jh},</if>
            <if test="jd != null">jd = #{jd},</if>
            <if test="jxj != null">jxj = #{jxj},</if>
            <if test="qjbhl != null">qjbhl = #{qjbhl},</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="deleteSjZlyqById" parameterType="Long">
        delete from sj_zlyq where id = #{id}
    </delete>

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