<?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.cms.mapper.WebsiteMapper">

    <!-- 关联查询sql -->
    <sql id="selectSql">
        SELECT a.*
        FROM cms_website a
        <where>
            <if test="param.websiteId != null">
                AND a.website_id = #{param.websiteId}
            </if>
            <if test="param.websiteName != null">
                AND a.website_name LIKE CONCAT('%', #{param.websiteName}, '%')
            </if>
            <if test="param.websiteCode != null">
                AND a.website_code LIKE CONCAT('%', #{param.websiteCode}, '%')
            </if>
            <if test="param.websiteIcon != null">
                AND a.website_icon LIKE CONCAT('%', #{param.websiteIcon}, '%')
            </if>
            <if test="param.websiteLogo != null">
                AND a.website_logo LIKE CONCAT('%', #{param.websiteLogo}, '%')
            </if>
            <if test="param.websiteType != null">
                AND a.website_type LIKE CONCAT('%', #{param.websiteType}, '%')
            </if>
            <if test="param.domain != null">
                AND a.domain LIKE CONCAT('%', #{param.domain}, '%')
            </if>
            <if test="param.expirationTime != null">
                AND a.expiration_time LIKE CONCAT('%', #{param.expirationTime}, '%')
            </if>
            <if test="param.templateId != null">
                AND a.template_id = #{param.templateId}
            </if>
            <if test="param.industryParent != null">
                AND a.industry_parent LIKE CONCAT('%', #{param.industryParent}, '%')
            </if>
            <if test="param.industryChild != null">
                AND a.industry_child LIKE CONCAT('%', #{param.industryChild}, '%')
            </if>
            <if test="param.companyId != null">
                AND a.company_id = #{param.companyId}
            </if>
            <if test="param.country != null">
                AND a.country LIKE CONCAT('%', #{param.country}, '%')
            </if>
            <if test="param.province != null">
                AND a.province LIKE CONCAT('%', #{param.province}, '%')
            </if>
            <if test="param.city != null">
                AND a.city LIKE CONCAT('%', #{param.city}, '%')
            </if>
            <if test="param.region != null">
                AND a.region LIKE CONCAT('%', #{param.region}, '%')
            </if>
            <if test="param.address != null">
                AND a.address LIKE CONCAT('%', #{param.address}, '%')
            </if>
            <if test="param.longitude != null">
                AND a.longitude LIKE CONCAT('%', #{param.longitude}, '%')
            </if>
            <if test="param.latitude != null">
                AND a.latitude LIKE CONCAT('%', #{param.latitude}, '%')
            </if>
            <if test="param.comments != null">
                AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
            </if>
            <if test="param.recommend != null">
                AND a.recommend = #{param.recommend}
            </if>
            <if test="param.status != null">
                AND a.status = #{param.status}
            </if>
            <if test="param.sortNumber != null">
                AND a.sort_number = #{param.sortNumber}
            </if>
            <if test="param.userId != null">
                AND a.user_id = #{param.userId}
            </if>
            <if test="param.merchantId != null">
              AND a.merchant_id = #{param.merchantId}
            </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.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.cms.entity.Website">
        <include refid="selectSql"></include>
    </select>

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

</mapper>
