<?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.engine.organization.mapper.resource.ResourceMapper">
    <resultMap id="BaseResultMap" type="com.engine.organization.entity.hrmresource.po.HrmResourcePO">
    </resultMap>

    <!-- 表字段 -->
    <sql id="baseColumns">
        id,last_name,department_id,company_id,mobile,telephone,manager_id
    </sql>

    <select id="listAll" resultType="com.engine.organization.entity.hrmresource.vo.HrmResourceVO">
        SELECT t.last_name as lastName,d.dept_name as departmentName,
        c.comp_name as companyName,t.mobile,t.telephone,t1.last_name as managerName
        from jcl_org_hrmresource t
        left join JCL_ORG_DEPT d on t.department_id = d.id
        left join jcl_org_comp c on t.company_id = c.id
        left join jcl_org_hrmresource t1 on t.manager_id = t1.id
        where 1 = 1
        <if test="ids != null and ids.size > 0" >
            AND t.id IN
            <foreach collection="ids" open="(" item="id" separator="," close=")">
                #{id}
            </foreach>
        </if>

        <!--<include refid="likeSql"/>-->
        <!--<if test="param.departmentId != null and param.departmentId != ''">-->
            <!--and t.department_id = #{param.departmentId}-->
        <!--</if>-->
        <!--<if test="param.companyId != null and param.companyId != ''">-->
            <!--and t.company_id = #{param.companyId}-->
        <!--</if>-->
        <!--<if test="param.mobile != null and param.mobile != ''">-->
            <!--and t.mobile = #{param.mobile}-->
        <!--</if>-->
        <!--<if test="param.telephone != null and param.telephone != ''">-->
            <!--and t.telephone = #{param.telephone}-->
        <!--</if>-->
        <!--<if test="param.managerId != null and param.managerId != ''">-->
            <!--and t.manager_id = #{param.managerId}-->
        <!--</if>-->
        <!--<if test="param.mobileCall != null and param.mobileCall != ''">-->
            <!--and t.mobile_call = #{param.mobileCall}-->
        <!--</if>-->
        <!--<if test="param.jobTitle != null and param.jobTitle != ''">-->
            <!--and t.job_title = #{param.jobTitle}-->
        <!--</if>-->
        order by t.id asc;
    </select>

    <sql id="likeSql">
        <if test="param.lastName != null and param.lastName != ''">
            AND t.last_name like CONCAT('%',#{param.lastName},'%')
        </if>
    </sql>
    <sql id="likeSql" databaseId="oracle">
        <if test="param.lastName != null and param.lastName != ''">
            AND t.last_name  like '%'||#{param.lastName}||'%'
        </if>
    </sql>
    <sql id="likeSql" databaseId="sqlserver">
        <if test="param.lastName != null and param.lastName != ''">
            AND t.last_name like '%'+#{param.lastName}+'%'
        </if>
    </sql>



</mapper>