<?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.huiju.estateagents.property.dao.TpShopMapper">

    <select id="getShopList" resultType="com.huiju.estateagents.property.model.TpShop">
        SELECT
            t.id,
            t.shop_name,
            t.sort,
            t.shop_type_id,
            t.shop_status,
            t.update_user,
            t.update_date,
            s.type_name,
            i.img_url,
            u.user_name
        FROM
            tp_shop t
            LEFT JOIN tp_shop_img i ON t.id = i.shop_id AND i.img_type = 1
            LEFT JOIN  tp_shop_type s on t.shop_type_id = s.id
            LEFT JOIN ta_user u on t.update_user = u.user_id
        where 1=1
        and t.org_id = #{tpShop.orgId}
        <if test="tpShop.id != null and tpShop.id != ''">
            and t.id like concat('%',#{tpShop.id},'%')
        </if>
        <if test="tpShop.shopName != null and tpShop.shopName != ''">
            and t.shop_name like concat('%',#{tpShop.shopName},'%')
        </if>
        <if test="tpShop.shopTypeId != null and tpShop.shopTypeId != ''">
            and t.shop_type_id  = #{tpShop.shopTypeId}
        </if>
        <if test="tpShop.shopStatus != null and tpShop.shopStatus != ''">
            and t.shop_status  = #{tpShop.shopStatus}
        </if>
        ORDER BY t.sort desc, t.update_date desc
    </select>

</mapper>
