<?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.iocoder.mall.product.dao.UserProductSpuCollectionsMapper">

    <sql id="FIELDS">
        id, user_id, nickname, spu_id, spu_name,
        spu_image,sell_point,price, create_time, update_time,
        deleted
    </sql>

    <select id="selectById" parameterType="Integer" resultType="UserProductSpuCollectionsDO">
        SELECT
            <include refid="FIELDS" />
        FROM user_spu_collections
        WHERE id = #{id}
        AND deleted = 0
    </select>


    <select id="selectListByUser" resultType="UserProductSpuCollectionsDO">
        SELECT
            <include refid="FIELDS" />
        FROM user_spu_collections
        <where>
            user_id = #{userId} AND deleted = 0
        </where>
        <if test="offset != null and limit != null">
            LIMIT #{offset}, #{limit}
        </if>
    </select>

    <select id="selectCountByUser" resultType="Integer">
        SELECT
            COUNT(1)
        FROM user_spu_collections
        <where>
            user_id = #{userId} AND deleted = 0
        </where>
    </select>

</mapper>
