<?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="cn.ezhizao.project.tenant.mapper.BizUserTenantMapper">

    <resultMap type="cn.ezhizao.project.tenant.domain.BizUserTenant" id="BizUserTenantResult">
        <id column="id" property="id"/>
    </resultMap>


    <select id="getList" parameterType="BizUserTenant" resultMap="BizUserTenantResult">
        SELECT t1.*,
               t2.org_name,t2.org_nature,t2.org_crt_code,t2.legal_name,t2.ent_prefix,t2.province,t2.city,t2.county,t2.org_addr
        FROM biz_user_tenant t1
               LEFT JOIN biz_tenant t2 ON t1.tenant_id = t2.id  AND t2.deleted = 0
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            t1.deleted = 0
            <if test="orgName != null and orgName != '' "> AND t2.org_name LIKE concat('%',#{orgName},'%')</if>
            <if test="isAdmin != null "> AND t1.is_admin = #{isAdmin}</if>
            <if test="userId != null "> AND t1.user_id = #{userId}</if>
            <if test="tenantId != null "> AND t1.tenant_id = #{tenantId}</if>
            <if test="status != null "> AND t1.status = #{status}</if>
        </trim>
    </select>

    <delete id="physicalDelete">
        DELETE FROM biz_user_tenant
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            <if test="id != null">
                id = #{id} AND
            </if>
       <!-- 删除条件为其他外键可以在这里加 -->
        </trim>
    </delete>
</mapper>
