<?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.employee.EmployeeMapper">

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

    <select id="getEmployeeNameById" resultType="string">
        select t.lastname
        from hrmresource t
        where id in
        <foreach collection="ids" open="(" item="id" separator="," close=")">
            #{id}
        </foreach>
    </select>


    <select id="getResourceIds" resultType="long">
        select t.id
        from hrmresource t
        where 1 = 1
        <include refid="likeSql"/>
    </select>


    <select id="getBrowserDatas" resultType="java.util.Map">
        select
        lastname as "name",
        id as "id"
        from hrmresource
        WHERE id IN
        <foreach collection="ids" open="(" item="id" separator="," close=")">
            #{id}
        </foreach>
    </select>
    <select id="getResourceIdsByName" resultType="java.lang.Long">
        select t.id
        from hrmresource t
        where t.lastname = #{lastName}
    </select>

</mapper>