<?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.SjJsjgMapper">
    
    <resultMap type="SjJsjg" id="SjJsjgResult">
        <result property="id"    column="id"    />
        <result property="jh"    column="jh"    />
        <result property="kc"    column="kc"    />
        <result property="ztzj"    column="ztzj"    />
        <result property="js"    column="js"    />
        <result property="ttwj"    column="ttwj"    />
        <result property="ttds"    column="ttds"    />
        <result property="ttxs"    column="ttxs"    />
        <result property="snfg"    column="snfg"    />
        <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="selectSjJsjgVo">
        select id, jh, kc, ztzj, js, ttwj, ttds, ttxs, snfg, bz, created_by, created_time, update_by, update_time from sj_jsjg
    </sql>

    <select id="selectSjJsjgList" parameterType="SjJsjg" resultMap="SjJsjgResult">
        <include refid="selectSjJsjgVo"/>
        <where>  
            <if test="jh != null  and jh != ''"> and jh = #{jh}</if>
            <if test="kc != null  and kc != ''"> and kc = #{kc}</if>
            <if test="ztzj != null "> and ztzj = #{ztzj}</if>
            <if test="js != null "> and js = #{js}</if>
            <if test="ttwj != null "> and ttwj = #{ttwj}</if>
            <if test="ttds != null "> and ttds = #{ttds}</if>
            <if test="ttxs != null "> and ttxs = #{ttxs}</if>
            <if test="snfg != null "> and snfg = #{snfg}</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>
        order by jh ,kc
    </select>
    
    <select id="selectSjJsjgById" parameterType="Long" resultMap="SjJsjgResult">
        <include refid="selectSjJsjgVo"/>
        where id = #{id}
    </select>
    <select id="selectSjJsjgtById" resultType="com.ruoyi.project.zjsgfa.domain.SjJsjgt">
       select * from sj_jsjgt
        where zbid = #{zbid} limit 1
    </select>

    <insert id="insertSjJsjg" parameterType="SjJsjg" useGeneratedKeys="true" keyProperty="id">
        insert into sj_jsjg
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="jh != null">jh,</if>
            <if test="kc != null">kc,</if>
            <if test="ztzj != null">ztzj,</if>
            <if test="js != null">js,</if>
            <if test="ttwj != null">ttwj,</if>
            <if test="ttds != null">ttds,</if>
            <if test="ttxs != null">ttxs,</if>
            <if test="snfg != null">snfg,</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="ztzj != null">#{ztzj},</if>
            <if test="js != null">#{js},</if>
            <if test="ttwj != null">#{ttwj},</if>
            <if test="ttds != null">#{ttds},</if>
            <if test="ttxs != null">#{ttxs},</if>
            <if test="snfg != null">#{snfg},</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="insertSjJsjgBatch">
        insert into sj_jsjg(  jh, kc, ztzj, js, ttwj, ttds, ttxs, snfg, bz) values
        <foreach item="item" index="index" collection="list" separator=",">
            (  #{item.jh}, #{item.kc}, #{item.ztzj}, #{item.js}, #{item.ttwj}, #{item.ttds}, #{item.ttxs}, #{item.snfg}, #{item.bz})
        </foreach>
    </insert>
    <insert id="insertSjJsjgt">
        insert into sj_jsjgt
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="zbid != null">zbid,</if>
            <if test="jsjgt != null">jsjgt,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="zbid != null">#{zbid},</if>
            <if test="jsjgt != null">#{jsjgt},</if>
        </trim>
    </insert>

    <update id="updateSjJsjg" parameterType="SjJsjg">
        update sj_jsjg
        <trim prefix="SET" suffixOverrides=",">
            <if test="jh != null">jh = #{jh},</if>
            <if test="kc != null">kc = #{kc},</if>
            <if test="ztzj != null">ztzj = #{ztzj},</if>
            <if test="js != null">js = #{js},</if>
            <if test="ttwj != null">ttwj = #{ttwj},</if>
            <if test="ttds != null">ttds = #{ttds},</if>
            <if test="ttxs != null">ttxs = #{ttxs},</if>
            <if test="snfg != null">snfg = #{snfg},</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="deleteSjJsjgById" parameterType="Long">
        delete from sj_jsjg where id = #{id}
    </delete>

    <delete id="deleteSjJsjgByIds" parameterType="String">
        delete from sj_jsjg where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <delete id="deleteSjJsjgByJh">
        delete from sj_jsjg where jh = #{jh}
    </delete>
    <delete id="deleteSjJsjgtById">
        delete from sj_jsjgt where zbid = #{zbid}
    </delete>
</mapper>