<?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.lframework.xingyun.template.inner.mappers.TenantMapper">
  <sql id="Tenant_sql">
    SELECT
           tb.*
    FROM tenant AS tb
  </sql>
  <select id="query" resultType="com.lframework.xingyun.template.inner.entity.Tenant">
    <include refid="Tenant_sql"/>
    <where>
      <if test="vo != null">
        <if test="vo.tenantId != null and vo.tenantId != ''">
            AND tb.id = #{vo.tenantId}
        </if>
        <if test="vo.name != null and vo.name != ''">
            AND tb.name LIKE CONCAT('%', #{vo.name}, '%')
        </if>
        <if test="vo.available != null">
          AND tb.available = #{vo.available}
        </if>
      </if>
    </where>
    ORDER BY tb.id
  </select>
  <select id="selector" resultType="com.lframework.xingyun.template.inner.entity.Tenant">
    <include refid="Tenant_sql"/>
    <where>
      <if test="vo != null">
        <if test="vo.tenantId != null and vo.tenantId != ''">
          AND tb.id = #{vo.tenantId}
        </if>
        <if test="vo.name != null and vo.name != ''">
          AND tb.name LIKE CONCAT('%', #{vo.name}, '%')
        </if>
        <if test="vo.available != null">
          AND tb.available = #{vo.available}
        </if>
      </if>
    </where>
    ORDER BY tb.id
  </select>
</mapper>