<?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="cn.timer.api.dao.zzgl.ZzglBmgwMMapper">

    <resultMap id="BaseResultMap" type="cn.timer.api.bean.zzgl.ZzglBmgwM" >
                <id column="id" property="id" />
                <result column="org_code" property="orgCode" />
                <result column="up_id" property="upId" />
                <result column="name" property="name" />
                <result column="sts" property="sts" />
                <result column="is_admin" property="isAdmin" />
                <result column="is_update" property="isUpdate" />
                <result column="type" property="type" />
                <result column="remark" property="remark" />
                <result column="update_time" property="updateTime" />
                <result column="create_time" property="createTime" />
    </resultMap>

    <sql id="Base_Column_List">
                a.id,
                a.org_code,
                a.up_id,
                a.name,
                a.sts,
                a.is_admin,
                a.is_update,
                a.type,
                a.remark,
                a.update_time,
                a.create_time
    </sql>
    
    <sql id="Base_Column_List_Alias">
                id ZzglBmgwM_id,
                org_code ZzglBmgwM_org_code,
                up_id ZzglBmgwM_up_id,
                name ZzglBmgwM_name,
                sts ZzglBmgwM_sts,
                is_admin ZzglBmgwM_is_admin,
                is_update ZzglBmgwM_is_update,
                type ZzglBmgwM_type,
                remark ZzglBmgwM_remark,
                update_time ZzglBmgwM_update_time,
                create_time ZzglBmgwM_create_time
    </sql>



	<select id="selectListByDepts" resultType="cn.timer.api.dto.zzgl.ZzglBmgwMEmpDto" parameterType="list">
        SELECT 
        	<include refid="Base_Column_List" />,b.name username
        FROM 
            zzgl_bmgw_m a,yggl_main_emp b
        WHERE 
        	b.bmgw_id = a.id 
        	<if test="list != null">
        		and a.id in 
	        	<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
	        		#{item}
				</foreach>  
        	</if>
    </select>
    
	<select id="selectOtherListByOrgCode" resultType="cn.timer.api.dto.zzgl.ZzglBmgwMEmpDto">
        SELECT 
        	<include refid="Base_Column_List" />,b.name username
        FROM 
        	zzgl_bmgw_m a,yggl_main_emp b
        WHERE 
        	b.bmgw_id = a.id and
        	a.org_code = #{orgCode} and
        	a.id not in (#{id})
    </select>

	<!-- 

    <insert id="insert" useGeneratedKeys="true" keyColumn="id" parameterType="cn.timer.api.bean.zzgl.ZzglBmgwM">
        INSERT INTO zzgl_bmgw_m
        <trim prefix="(" suffix=")" suffixOverrides=",">
                        <if test ='null != orgCode'>
                        org_code,
                        </if>
                        <if test ='null != upId'>
                        up_id,
                        </if>
                        <if test ='null != name'>
                        name,
                        </if>
                        <if test ='null != sts'>
                        sts,
                        </if>
                        <if test ='null != isAdmin'>
                        is_admin,
                        </if>
                        <if test ='null != isUpdate'>
                        is_update,
                        </if>
                        <if test ='null != type'>
                        type,
                        </if>
                        <if test ='null != remark'>
                        remark,
                        </if>
                        <if test ='null != updateTime'>
                        update_time,
                        </if>
                        <if test ='null != createTime'>
                        create_time
                        </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                        <if test ='null != orgCode'>
                        #{orgCode},
                        </if>
                        <if test ='null != upId'>
                        #{upId},
                        </if>
                        <if test ='null != name'>
                        #{name},
                        </if>
                        <if test ='null != sts'>
                        #{sts},
                        </if>
                        <if test ='null != isAdmin'>
                        #{isAdmin},
                        </if>
                        <if test ='null != isUpdate'>
                        #{isUpdate},
                        </if>
                        <if test ='null != type'>
                        #{type},
                        </if>
                        <if test ='null != remark'>
                        #{remark},
                        </if>
                        <if test ='null != updateTime'>
                        #{updateTime},
                        </if>
                        <if test ='null != createTime'>
                        #{createTime}
                        </if>
        </trim>
    </insert>

    <delete id="delete" >
        DELETE FROM zzgl_bmgw_m
        WHERE id = #{id}
    </delete>

    <update id="update" parameterType="cn.timer.api.bean.zzgl.ZzglBmgwM">
        UPDATE zzgl_bmgw_m
        <set>
                    <if test ='null != orgCode'>org_code = #{orgCode},</if>
                    <if test ='null != upId'>up_id = #{upId},</if>
                    <if test ='null != name'>name = #{name},</if>
                    <if test ='null != sts'>sts = #{sts},</if>
                    <if test ='null != isAdmin'>is_admin = #{isAdmin},</if>
                    <if test ='null != isUpdate'>is_update = #{isUpdate},</if>
                    <if test ='null != type'>type = #{type},</if>
                    <if test ='null != remark'>remark = #{remark},</if>
                    <if test ='null != updateTime'>update_time = #{updateTime},</if>
                    <if test ='null != createTime'>create_time = #{createTime}</if>
        </set>
        WHERE id = #{id}
    </update>


    <select id="load" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />
        FROM zzgl_bmgw_m
        WHERE id = #{id}
    </select>

    <select id="pageList" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />
        FROM zzgl_bmgw_m
        LIMIT #{offset}, #{pageSize}
    </select>

    <select id="pageListCount" resultType="java.lang.Integer">
        SELECT count(1)
        FROM zzgl_bmgw_m
    </select>

	 -->

</mapper>