<?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.system.mapper.SysDeptCbMapper">
    
    <resultMap type="SysDeptCb" id="SysDeptCbResult">
        <result property="id"    column="id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="nd"    column="nd"    />
        <result property="dwlx"    column="dwlx"    />
        <result property="jyqlhjysr"    column="jyqlhjysr"    />
        <result property="jcrysl"    column="jcrysl"    />
        <result property="jcdwsl"    column="jcdwsl"    />
        <result property="yxbzsl"    column="yxbzsl"    />
    </resultMap>

    <sql id="selectSysDeptCbVo">
        select id, dept_id, nd, dwlx, jyqlhjysr, jcrysl, jcdwsl, yxbzsl from sys_dept_cb
    </sql>

    <select id="selectSysDeptCbList" parameterType="SysDeptCb" resultMap="SysDeptCbResult">
        <include refid="selectSysDeptCbVo"/>
        <where>  
            <if test="deptId != null  and deptId != ''"> and dept_id = #{deptId}</if>
            <if test="nd != null  and nd != ''"> and nd = #{nd}</if>
            <if test="dwlx != null  and dwlx != ''"> and dwlx = #{dwlx}</if>
            <if test="jyqlhjysr != null "> and jyqlhjysr = #{jyqlhjysr}</if>
            <if test="jcrysl != null "> and jcrysl = #{jcrysl}</if>
            <if test="jcdwsl != null "> and jcdwsl = #{jcdwsl}</if>
            <if test="yxbzsl != null "> and yxbzsl = #{yxbzsl}</if>
        </where>
    </select>
    
    <select id="selectSysDeptCbById" parameterType="Long" resultMap="SysDeptCbResult">
        <include refid="selectSysDeptCbVo"/>
        where id = #{id}
    </select>
    <select id="getInfoBydeptId" resultMap="SysDeptCbResult">
        <include refid="selectSysDeptCbVo"/>
        where dept_id = #{deptId} and nd = #{nd}
    </select>

    <insert id="insertSysDeptCb" parameterType="SysDeptCb" useGeneratedKeys="true" keyProperty="id">
        insert into sys_dept_cb
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="deptId != null">dept_id,</if>
            <if test="nd != null">nd,</if>
            <if test="dwlx != null">dwlx,</if>
            <if test="jyqlhjysr != null">jyqlhjysr,</if>
            <if test="jcrysl != null">jcrysl,</if>
            <if test="jcdwsl != null">jcdwsl,</if>
            <if test="yxbzsl != null">yxbzsl,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="deptId != null">#{deptId},</if>
            <if test="nd != null">#{nd},</if>
            <if test="dwlx != null">#{dwlx},</if>
            <if test="jyqlhjysr != null">#{jyqlhjysr},</if>
            <if test="jcrysl != null">#{jcrysl},</if>
            <if test="jcdwsl != null">#{jcdwsl},</if>
            <if test="yxbzsl != null">#{yxbzsl},</if>
         </trim>
    </insert>

    <update id="updateSysDeptCb" parameterType="SysDeptCb">
        update sys_dept_cb
        <trim prefix="SET" suffixOverrides=",">
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="nd != null">nd = #{nd},</if>
            <if test="dwlx != null">dwlx = #{dwlx},</if>
            <if test="jyqlhjysr != null">jyqlhjysr = #{jyqlhjysr},</if>
            <if test="jcrysl != null">jcrysl = #{jcrysl},</if>
            <if test="jcdwsl != null">jcdwsl = #{jcdwsl},</if>
            <if test="yxbzsl != null">yxbzsl = #{yxbzsl},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysDeptCbById" parameterType="Long">
        delete from sys_dept_cb where id = #{id}
    </delete>

    <delete id="deleteSysDeptCbByIds" parameterType="String">
        delete from sys_dept_cb where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <delete id="deleteSysDeptCbByDeptId">
        delete from sys_dept_cb where dept_id = #{deptId} and nd = #{nd}
    </delete>
</mapper>