<?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="io.dataease.base.mapper.ext.ExtBaseMapper">


    <sql id="orders">
        <if test="request.orders != null and request.orders.size() > 0">
            order by
            <foreach collection="request.orders" separator="," item="order">
                ${order.name} ${order.type}
            </foreach>
        </if>
    </sql>

    <sql id="condition">
        <choose>
            <when test='${object}.operator == "like"'>
                like CONCAT('%', #{${object}.value},'%')
            </when>
            <when test='${object}.operator == "not like"'>
                not like CONCAT('%', #{${object}.value},'%')
            </when>
            <when test='${object}.operator == "in"'>
                in
                <foreach collection="${object}.value" item="v" separator="," open="(" close=")">
                    #{v}
                </foreach>
            </when>
            <when test='${object}.operator == "not in"'>
                not in
                <foreach collection="${object}.value" item="v" separator="," open="(" close=")">
                    #{v}
                </foreach>
            </when>
            <when test='${object}.operator == "between"'>
                between #{${object}.value[0]} and #{${object}.value[1]}
            </when>
            <when test='${object}.operator == "gt"'>
                &gt; #{${object}.value}
            </when>
            <when test='${object}.operator == "lt"'>
                &lt; #{${object}.value}
            </when>
            <when test='${object}.operator == "ge"'>
                &gt;= #{${object}.value}
            </when>
            <when test='${object}.operator == "le"'>
                &lt;= #{${object}.value}
            </when>
            <when test='${object}.operator == "current user"'>
                = '${@io.metersphere.commons.utils.SessionUtils@getUserId()}'
            </when>
            <otherwise>
                = #{${object}.value}
            </otherwise>
        </choose>
    </sql>

</mapper>
