<?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.qianhe.mapper.SjGfjsLbzdbfJgMapper">
    
    <resultMap type="SjGfjsLbzdbfJg" id="SjGfjsLbzdbfJgResult">
        <result property="id"    column="id"    />
        <result property="zbId"    column="zb_id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="jg1"    column="jg1"    />
        <result property="jg2"    column="jg2"    />
        <result property="jg3"    column="jg3"    />
        <result property="jg4"    column="jg4"    />
        <result property="jg5"    column="jg5"    />
        <result property="jg6"    column="jg6"    />
        <result property="jg7"    column="jg7"    />
        <result property="jg8"    column="jg8"    />
        <result property="jg9"    column="jg9"    />
        <result property="jg10"    column="jg10"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
        <result property="yl1"    column="yl1"    />
        <result property="yl2"    column="yl2"    />
        <result property="yl3"    column="yl3"    />
        <result property="yl4"    column="yl4"    />
        <result property="yl5"    column="yl5"    />
        <result property="deptName"    column="dept_name"    />
    </resultMap>

    <sql id="selectSjGfjsLbzdbfJgVo">
        select a.id, a.zb_id, a.dept_id, a.jg1, a.jg2, a.jg3, a.jg4, a.jg5, a.jg6, a.jg7, a.jg8, a.jg9, a.jg9,
        a.create_by, a.create_time, a.update_by, a.update_time, a.remark, a.yl1, a.yl2, a.yl3, a.yl4, a.yl5,
          CONCAT(p.dept_name,'/',d.dept_name) dept_name
        from sj_gfjs_lbzdbf_jg a
        left join sys_dept d on a.dept_id=d.dept_id
        LEFT JOIN  sys_dept p on d.parent_id = p.dept_id
    </sql>

    <select id="selectSjGfjsLbzdbfJgList" parameterType="SjGfjsLbzdbfJg" resultMap="SjGfjsLbzdbfJgResult">
        <include refid="selectSjGfjsLbzdbfJgVo"/>
        <where>  
            <if test="zbId != null "> and zb_id = #{zbId}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="jg1 != null "> and jg1 = #{jg1}</if>
            <if test="jg2 != null "> and jg2 = #{jg2}</if>
            <if test="jg3 != null "> and jg3 = #{jg3}</if>
            <if test="jg4 != null "> and jg4 = #{jg4}</if>
            <if test="jg5 != null "> and jg5 = #{jg5}</if>
            <if test="jg6 != null "> and jg6 = #{jg6}</if>
            <if test="jg7 != null "> and jg7 = #{jg7}</if>
            <if test="jg8 != null "> and jg8 = #{jg8}</if>
            <if test="jg9 != null "> and jg9 = #{jg9}</if>
            <if test="jg10 != null "> and jg10 = #{jg10}</if>
            <if test="yl1 != null  and yl1 != ''"> and yl1 = #{yl1}</if>
            <if test="yl2 != null  and yl2 != ''"> and yl2 = #{yl2}</if>
            <if test="yl3 != null  and yl3 != ''"> and yl3 = #{yl3}</if>
            <if test="yl4 != null  and yl4 != ''"> and yl4 = #{yl4}</if>
            <if test="yl5 != null  and yl5 != ''"> and yl5 = #{yl5}</if>
        </where>
    </select>
    
    <select id="selectSjGfjsLbzdbfJgById" parameterType="Long" resultMap="SjGfjsLbzdbfJgResult">
        <include refid="selectSjGfjsLbzdbfJgVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSjGfjsLbzdbfJg" parameterType="SjGfjsLbzdbfJg" useGeneratedKeys="true" keyProperty="id">
        insert into sj_gfjs_lbzdbf_jg
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="zbId != null">zb_id,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="jg1 != null">jg1,</if>
            <if test="jg2 != null">jg2,</if>
            <if test="jg3 != null">jg3,</if>
            <if test="jg4 != null">jg4,</if>
            <if test="jg5 != null">jg5,</if>
            <if test="jg6 != null">jg6,</if>
            <if test="jg7 != null">jg7,</if>
            <if test="jg8 != null">jg8,</if>
            <if test="jg9 != null">jg9,</if>
            <if test="jg10 != null">jg10,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
            <if test="yl1 != null">yl1,</if>
            <if test="yl2 != null">yl2,</if>
            <if test="yl3 != null">yl3,</if>
            <if test="yl4 != null">yl4,</if>
            <if test="yl5 != null">yl5,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="zbId != null">#{zbId},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="jg1 != null">#{jg1},</if>
            <if test="jg2 != null">#{jg2},</if>
            <if test="jg3 != null">#{jg3},</if>
            <if test="jg4 != null">#{jg4},</if>
            <if test="jg5 != null">#{jg5},</if>
            <if test="jg6 != null">#{jg6},</if>
            <if test="jg7 != null">#{jg7},</if>
            <if test="jg8 != null">#{jg8},</if>
            <if test="jg9 != null">#{jg9},</if>
            <if test="jg10 != null">#{jg10},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
            <if test="yl1 != null">#{yl1},</if>
            <if test="yl2 != null">#{yl2},</if>
            <if test="yl3 != null">#{yl3},</if>
            <if test="yl4 != null">#{yl4},</if>
            <if test="yl5 != null">#{yl5},</if>
         </trim>
    </insert>

    <update id="updateSjGfjsLbzdbfJg" parameterType="SjGfjsLbzdbfJg">
        update sj_gfjs_lbzdbf_jg
        <trim prefix="SET" suffixOverrides=",">
            <if test="zbId != null">zb_id = #{zbId},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="jg1 != null">jg1 = #{jg1},</if>
            <if test="jg2 != null">jg2 = #{jg2},</if>
            <if test="jg3 != null">jg3 = #{jg3},</if>
            <if test="jg4 != null">jg4 = #{jg4},</if>
            <if test="jg5 != null">jg5 = #{jg5},</if>
            <if test="jg6 != null">jg6 = #{jg6},</if>
            <if test="jg7 != null">jg7 = #{jg7},</if>
            <if test="jg8 != null">jg8 = #{jg8},</if>
            <if test="jg9 != null">jg9 = #{jg9},</if>
            <if test="jg10 != null">jg10 = #{jg10},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="yl1 != null">yl1 = #{yl1},</if>
            <if test="yl2 != null">yl2 = #{yl2},</if>
            <if test="yl3 != null">yl3 = #{yl3},</if>
            <if test="yl4 != null">yl4 = #{yl4},</if>
            <if test="yl5 != null">yl5 = #{yl5},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSjGfjsLbzdbfJgById" parameterType="Long">
        delete from sj_gfjs_lbzdbf_jg where id = #{id}
    </delete>

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