<?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.yonge.cooleshow.biz.dal.mapper.TenantGroupMapper">



    <!-- 表字段 -->
    <sql id="baseColumns">
        t.id_ AS id
        , t.tenant_id_ AS tenantId
        , t.name_ AS name
        , t.admin_id_ AS adminId
        , t.im_group_id_ AS imGroupId
        , t.create_by_ AS createBy
        , t.create_time_ AS createTime
    </sql>

    <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.wrapper.TenantGroupWrapper$TenantGroup">
        SELECT DISTINCT
        <include refid="baseColumns" />
        FROM tenant_group t
        <if test="param.tenantAlbumId != null">
            LEFT JOIN tenant_group_album tga on t.id_ = tga.tenant_group_id_
        </if>
        <where>
            <if test="param.keyword != null and param.keyword.trim() !=''">
               AND t.name_ like concat('%',#{param.keyword},'%')
            </if>
            <if test="param.tenantId != null">
                AND t.tenant_id_ = #{param.tenantId}
            </if>
            <if test="param.adminId != null">
                AND t.admin_id_ = #{param.adminId}
            </if>
            <if test="param.tenantAlbumId != null">
                AND tga.tenant_album_id_ = #{param.tenantAlbumId} AND tga.del_flag_=0 AND tga.status_=1
            </if>
        </where>
        ORDER BY t.id_ DESC
    </select>

</mapper>