<?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.qyzx.QyzxEmpEntAssoMapper">

    <resultMap id="BaseResultMap" type="cn.timer.api.bean.qyzx.QyzxEmpEntAsso" >
                <id column="id" property="id" />
                <result column="emp_num" property="empNum" />
                <result column="org_code" property="orgCode" />
                <result column="user_type" property="userType" />
    </resultMap>

    <sql id="Base_Column_List">
                id,
                emp_num,
                org_code,
                user_type
    </sql>

    <resultMap id="adminlistdto" type="cn.timer.api.dto.qyzx.AdminListDto" >
        <result column="emp_num" property="empNum" />
        <result column="user_type" property="userType" />
        <result column="status" property="status" />
        <result column="org_id" property="orgId" />
        <result column="email" property="email" />
        <result column="reg_time" property="regTime" />
        <result column="head_url" property="headUrl" />
        <result column="phone" property="phone" />
        <result column="username" property="username" />
        <result column="name" property="empName" />
        <result column="english_name" property="enName" />
        <result column="bmgw_id" property="bmgwId" />
        <result column="sex" property="sex" />
        <result column="job_num" property="jobNum" />
    </resultMap>

    <select id="adminlist"
        resultMap="adminlistdto" ><!-- b.email,b.end_time,b.reg_time, -->
        select a.emp_num,a.user_type,a.status,b.org_id,b.email,b.reg_time,b.head_url,b.phone,b.username,c.name,c.sex,c.job_num,c.english_name,c.bmgw_id
         from qyzx_emp_ent_asso a 
        left join qyzx_emp_login b on a.emp_num = b.id 
        left join yggl_main_emp c on a.emp_num = c.emp_num and a.org_code = c.org_code
        where a.org_code = #{org_code} 
    </select>

	<!-- 

    <insert id="insert" useGeneratedKeys="true" keyColumn="id" parameterType="cn.timer.api.bean.qyzx.QyzxEmpEntAsso">
        INSERT INTO qyzx_emp_ent_asso
        <trim prefix="(" suffix=")" suffixOverrides=",">
                        <if test ='null != empNum'>
                        emp_num,
                        </if>
                        <if test ='null != orgCode'>
                        org_code,
                        </if>
                        <if test ='null != userType'>
                        user_type
                        </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                        <if test ='null != empNum'>
                        #{empNum},
                        </if>
                        <if test ='null != orgCode'>
                        #{orgCode},
                        </if>
                        <if test ='null != userType'>
                        #{userType}
                        </if>
        </trim>
    </insert>

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

    <update id="update" parameterType="cn.timer.api.bean.qyzx.QyzxEmpEntAsso">
        UPDATE qyzx_emp_ent_asso
        <set>
                    <if test ='null != empNum'>emp_num = #{empNum},</if>
                    <if test ='null != orgCode'>org_code = #{orgCode},</if>
                    <if test ='null != userType'>user_type = #{userType}</if>
        </set>
        WHERE id = #{id}
    </update>


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

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

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

	 -->

</mapper>