<?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.bomaos.settings.mapper.ShopSettingsMapper">

    <!-- 关联查询sql -->
    <sql id="relSelect">
        SELECT a.*
        FROM sys_shop_settings a
        <where>
            <if test="page!=null and page.pageData!=null">
                <if test="page.pageData.id != null">
                    AND a.id = #{page.pageData.id}
                </if>
                <if test="page.pageData.isWindow != null">
                    AND a.is_window = #{page.pageData.isWindow}
                </if>
                <if test="page.pageData.windowText != null">
                    AND a.window_text LIKE CONCAT('%', #{page.pageData.windowText}, '%')
                </if>
                <if test="page.pageData.isBackground != null">
                    AND a.is_background LIKE CONCAT('%', #{page.pageData.isBackground}, '%')
                </if>
                <if test="page.pageData.storeDetails != null">
                    AND a.store_details LIKE CONCAT('%', #{page.pageData.storeDetails}, '%')
                </if>
                <if test="page.pageData.isWxpusher != null">
                    AND a.is_wxpusher = #{page.pageData.isWxpusher}
                </if>
                <if test="page.pageData.appToken != null">
                    AND a.app_token LIKE CONCAT('%', #{page.pageData.appToken}, '%')
                </if>
                <if test="page.pageData.wxpushUid != null">
                    AND a.wxpush_uid LIKE CONCAT('%', #{page.pageData.wxpushUid}, '%')
                </if>
                <if test="page.pageData.isEmail != null">
                    AND a.is_email = #{page.pageData.isEmail}
                </if>
                <if test="page.pageData.qqCustomerService != null">
                    AND a.qq_customer_service = #{page.pageData.qqCustomerService}
                </if>
                <if test="page.pageData.qqGroupQrcode != null">
                    AND a.qq_group_qrcode = #{page.pageData.qqGroupQrcode}
                </if>
                <if test="page.pageData.isClient != null">
                    AND a.is_client = #{page.pageData.isClient}
                </if>
                <if test="page.pageData.crispKey != null">
                    AND a.crisp_key = #{page.pageData.crispKey}
                </if>
                <if test="page.pageData.isModel != null">
                    AND a.is_model = #{page.pageData.isModel}
                </if>
            </if>
        </where>
    </sql>

    <!-- 分页查询 -->
    <select id="listPage" resultType="com.bomaos.settings.entity.ShopSettings">
        <include refid="relSelect"></include>
    </select>

    <!-- 查询全部 -->
    <select id="listAll" resultType="com.bomaos.settings.entity.ShopSettings">
        <include refid="relSelect"></include>
    </select>

</mapper>
