<?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.yami.shop.dao.UserCollectionShopMapper">

  <resultMap id="userCollectionShopMap" type="com.yami.shop.bean.model.UserCollectionShop">
    <id column="collection_id" property="collectionId" />
    <result column="shop_id" property="shopId"/>
    <result column="user_id" property="userId"/>
    <result column="create_time" property="createTime"/>
  </resultMap>
    <select id="getUserCollectionShopPageByUserId"
            resultType="com.yami.shop.bean.app.dto.UserCollectionShopDto">
      SELECT s.shop_name,ucs.collection_id,ucs.create_time,
            s.shop_id,s.shop_logo
      FROM tz_user_collection_shop ucs
      JOIN tz_shop_detail s ON s.shop_id = ucs.shop_id
      <where>
        ucs.user_id = #{userId}
        <if test="shopName != null and shopName != ''">
          AND s.shop_name LIKE concat('%',#{shopName},'%')
        </if>
      </where>
    </select>

</mapper>
