<?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.gxwebsoft.apps.mapper.HualalaCartFoodMapper">

    <!-- 关联查询sql -->
    <sql id="selectSql">
        SELECT a.*
        FROM apps_hualala_cart_food a
        <where>
            <if test="param.id != null">
                AND a.id = #{param.id}
            </if>
            <if test="param.userId != null">
                AND a.user_id = #{param.userId}
            </if>
            <if test="param.foodId != null">
                AND a.food_id = #{param.foodId}
            </if>
            <if test="param.foodName != null">
                AND a.food_name LIKE CONCAT('%', #{param.foodName}, '%')
            </if>
            <if test="param.skuId != null">
                AND a.sku_id LIKE CONCAT('%', #{param.skuId}, '%')
            </if>
            <if test="param.shopId != null">
                AND a.shop_id = #{param.shopId}
            </if>
            <if test="param.shopName != null">
                AND a.shop_name LIKE CONCAT('%', #{param.shopName}, '%')
            </if>
            <if test="param.shopLogo != null">
                AND a.shop_logo LIKE CONCAT('%', #{param.shopLogo}, '%')
            </if>
            <if test="param.coverUrl != null">
                AND a.cover_url LIKE CONCAT('%', #{param.coverUrl}, '%')
            </if>
            <if test="param.sellPrice != null">
                AND a.sell_price = #{param.sellPrice}
            </if>
            <if test="param.stock != null">
                AND a.stock = #{param.stock}
            </if>
            <if test="param.createTimeStart != null">
                AND a.create_time &gt;= #{param.createTimeStart}
            </if>
            <if test="param.createTimeEnd != null">
                AND a.create_time &lt;= #{param.createTimeEnd}
            </if>
        </where>
    </sql>

    <!-- 分页查询 -->
    <select id="selectPageRel" resultType="com.gxwebsoft.apps.entity.HualalaCartFood">
        <include refid="selectSql"></include>
    </select>

    <!-- 查询全部 -->
    <select id="selectListRel" resultType="com.gxwebsoft.apps.entity.HualalaCartFood">
        <include refid="selectSql"></include>
    </select>

</mapper>
