<?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.didi.carrera.console.dao.mapper.custom.ConsumeGroupCustomMapper">

    <select id="selectByCondition" resultMap="com.didi.carrera.console.dao.mapper.ConsumeGroupMapper.BaseResultMap">
        select
        <include refid="com.didi.carrera.console.dao.mapper.ConsumeGroupMapper.Base_Column_List"/>
        from consume_group
        where
        is_delete = 0
        <if test="contacters != null and contacters != ''">
            AND contacters LIKE #{contacters}
        </if>

        <if test="text != null and text != ''">
            AND (
            group_name LIKE #{text}
            OR department LIKE #{text}
            OR contacters LIKE #{text}
            )
        </if>
        ORDER BY create_time DESC
        <if test="limit != null and limit >= 0 ">
            limit #{limit}
        </if>
        <if test="limit != null and limit >= 0 and size != null and size >= 0">
            , #{size}
        </if>
    </select>

    <select id="selectCountByCondition" resultType="java.lang.Integer">
        select
        count(*)
        from consume_group
        where
        is_delete = 0
        <if test="contacters != null and contacters != ''">
            AND contacters LIKE #{contacters}
        </if>
        <if test="text != null and text != ''">
            AND (
            group_name LIKE #{text}
            OR department LIKE #{text}
            OR contacters LIKE #{text}
            )
        </if>
    </select>


</mapper>