<?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.SjLjsmMapper">
    
    <resultMap type="SjLjsm" id="SjLjsmResult">
        <result property="id"    column="id"    />
        <result property="jh"    column="jh"    />
        <result property="js"    column="js"    />
        <result property="cs"    column="cs"    />
        <result property="bjjh"    column="bjjh"    />
        <result property="bjsjly"    column="bjsjly"    />
        <result property="bjjs"    column="bjjs"    />
        <result property="bjcs"    column="bjcs"    />
        <result property="bjzjjl"    column="bjzjjl"    />
        <result property="bjsmj"    column="bjsmj"    />
        <result property="bjyj"    column="bjyj"    />
        <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="selectSjLjsmVo">
        select id, jh, js, cs, bjjh, bjsjly, bjjs, bjcs, bjzjjl, bjsmj, bjyj, bz, created_by, created_time, update_by, update_time from sj_ljsm
    </sql>

    <select id="selectSjLjsmList" parameterType="SjLjsm" resultMap="SjLjsmResult">
        <include refid="selectSjLjsmVo"/>
        <where>  
            <if test="jh != null  and jh != ''"> and jh = #{jh}</if>
            <if test="js != null "> and js = #{js}</if>
            <if test="cs != null "> and cs = #{cs}</if>
            <if test="bjjh != null  and bjjh != ''"> and bjjh = #{bjjh}</if>
            <if test="bjsjly != null  and bjsjly != ''"> and bjsjly = #{bjsjly}</if>
            <if test="bjjs != null "> and bjjs = #{bjjs}</if>
            <if test="bjcs != null "> and bjcs = #{bjcs}</if>
            <if test="bjzjjl != null "> and bjzjjl = #{bjzjjl}</if>
            <if test="bjsmj != null "> and bjsmj = #{bjsmj}</if>
            <if test="bjyj != null "> and bjyj = #{bjyj}</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="selectSjLjsmById" parameterType="Long" resultMap="SjLjsmResult">
        <include refid="selectSjLjsmVo"/>
        where id = #{id}
    </select>

    <insert id="insertSjLjsm" parameterType="SjLjsm" useGeneratedKeys="true" keyProperty="id">
        insert into sj_ljsm
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="jh != null">jh,</if>
            <if test="js != null">js,</if>
            <if test="cs != null">cs,</if>
            <if test="bjjh != null">bjjh,</if>
            <if test="bjsjly != null">bjsjly,</if>
            <if test="bjjs != null">bjjs,</if>
            <if test="bjcs != null">bjcs,</if>
            <if test="bjzjjl != null">bjzjjl,</if>
            <if test="bjsmj != null">bjsmj,</if>
            <if test="bjyj != null">bjyj,</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="js != null">#{js},</if>
            <if test="cs != null">#{cs},</if>
            <if test="bjjh != null">#{bjjh},</if>
            <if test="bjsjly != null">#{bjsjly},</if>
            <if test="bjjs != null">#{bjjs},</if>
            <if test="bjcs != null">#{bjcs},</if>
            <if test="bjzjjl != null">#{bjzjjl},</if>
            <if test="bjsmj != null">#{bjsmj},</if>
            <if test="bjyj != null">#{bjyj},</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="insertSjLjsmBatch">
        INSERT INTO sj_ljsm
        (jh, js, cs, bjjh, bjsjly, bjjs, bjcs, bjzjjl, bjsmj, bjyj, bz)
        VALUES
        <foreach collection="list" item="item" separator=",">
            (
            #{item.jh},
            #{item.js},
            #{item.cs},
            #{item.bjjh},
            #{item.bjsjly},
            #{item.bjjs},
            #{item.bjcs},
            #{item.bjzjjl},
            #{item.bjsmj},
            #{item.bjyj},
            #{item.bz}
            )
        </foreach>
    </insert>

    <update id="updateSjLjsm" parameterType="SjLjsm">
        update sj_ljsm
        <trim prefix="SET" suffixOverrides=",">
            <if test="jh != null">jh = #{jh},</if>
            <if test="js != null">js = #{js},</if>
            <if test="cs != null">cs = #{cs},</if>
            <if test="bjjh != null">bjjh = #{bjjh},</if>
            <if test="bjsjly != null">bjsjly = #{bjsjly},</if>
            <if test="bjjs != null">bjjs = #{bjjs},</if>
            <if test="bjcs != null">bjcs = #{bjcs},</if>
            <if test="bjzjjl != null">bjzjjl = #{bjzjjl},</if>
            <if test="bjsmj != null">bjsmj = #{bjsmj},</if>
            <if test="bjyj != null">bjyj = #{bjyj},</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="deleteSjLjsmById" parameterType="Long">
        delete from sj_ljsm where id = #{id}
    </delete>

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