<?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.HualalaFoodCategoryMapper">

    <!-- 关联查询sql -->
    <sql id="selectSql">
        SELECT a.*
        FROM apps_hualala_food_category a
        <where>
            <if test="param.id != null">
                AND a.id = #{param.id}
            </if>
            <if test="param.type != null">
                AND a.type = #{param.type}
            </if>
            <if test="param.foodCategoryName != null">
                AND a.food_category_name LIKE CONCAT('%', #{param.foodCategoryName}, '%')
            </if>
            <if test="param.foodSubjectName != null">
                AND a.food_subject_name LIKE CONCAT('%', #{param.foodSubjectName}, '%')
            </if>
            <if test="param.foodKey != null">
                AND a.food_key LIKE CONCAT('%', #{param.foodKey}, '%')
            </if>
            <if test="param.foodCount != null">
                AND a.food_count LIKE CONCAT('%', #{param.foodCount}, '%')
            </if>
            <if test="param.foodCategoryId != null">
                AND a.food_category_id LIKE CONCAT('%', #{param.foodCategoryId}, '%')
            </if>
            <if test="param.foodCategoryGroupName != null">
                AND a.food_category_group_name LIKE CONCAT('%', #{param.foodCategoryGroupName}, '%')
            </if>
            <if test="param.foodCategoryKey != null">
                AND a.food_category_key LIKE CONCAT('%', #{param.foodCategoryKey}, '%')
            </if>
            <if test="param.action != null">
                AND a.action LIKE CONCAT('%', #{param.action}, '%')
            </if>
            <if test="param.settlementProportion != null">
                AND a.settlement_proportion LIKE CONCAT('%', #{param.settlementProportion}, '%')
            </if>
            <if test="param.isActive != null">
                AND a.is_active = #{param.isActive}
            </if>
            <if test="param.isBatching != null">
                AND a.is_batching = #{param.isBatching}
            </if>
            <if test="param.isSingleSale != null">
                AND a.is_single_sale = #{param.isSingleSale}
            </if>
            <if test="param.sortIndex != null">
                AND a.sort_index = #{param.sortIndex}
            </if>
            <if test="param.adsId != null">
                AND a.ads_id = #{param.adsId}
            </if>
            <if test="param.shopId != null">
                AND a.shop_id LIKE CONCAT('%', #{param.shopId}, '%')
            </if>
            <if test="param.image != null">
                AND a.image LIKE CONCAT('%', #{param.image}, '%')
            </if>
            <if test="param.content != null">
                AND a.content LIKE CONCAT('%', #{param.content}, '%')
            </if>
            <if test="param.sortNumber != null">
                AND a.sort_number = #{param.sortNumber}
            </if>
            <if test="param.comments != null">
                AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
            </if>
            <if test="param.status != null">
                AND a.status = #{param.status}
            </if>
            <if test="param.deleted != null">
                AND a.deleted = #{param.deleted}
            </if>
            <if test="param.deleted == null">
                AND a.deleted = 0
            </if>
            <if test="param.merchantCode != null">
                AND a.merchant_code LIKE CONCAT('%', #{param.merchantCode}, '%')
            </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.HualalaFoodCategory">
        <include refid="selectSql"></include>
    </select>

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

</mapper>
