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

    <!-- 关联查询sql -->
    <sql id="relSelect">
        SELECT a.*
        FROM sys_website 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.websiteName != null">
                    AND a.website_name LIKE CONCAT('%', #{page.pageData.websiteName}, '%')
                </if>
                <if test="page.pageData.websiteUrl != null">
                    AND a.website_url LIKE CONCAT('%', #{page.pageData.websiteUrl}, '%')
                </if>
                <if test="page.pageData.websiteLogo != null">
                    AND a.website_logo LIKE CONCAT('%', #{page.pageData.websiteLogo}, '%')
                </if>
                <if test="page.pageData.contact != null">
                    AND a.contact LIKE CONCAT('%', #{page.pageData.contact}, '%')
                </if>
                <if test="page.pageData.beianIcp != null">
                    AND a.beian_icp LIKE CONCAT('%', #{page.pageData.beianIcp}, '%')
                </if>
                <if test="page.pageData.keywords != null">
                    AND a.keywords LIKE CONCAT('%', #{page.pageData.keywords}, '%')
                </if>
                <if test="page.pageData.description != null">
                    AND a.description LIKE CONCAT('%', #{page.pageData.description}, '%')
                </if>
                <if test="page.pageData.favicon != null">
                    AND a.favicon LIKE CONCAT('%', #{page.pageData.favicon}, '%')
                </if>
            </if>
        </where>
    </sql>

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

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

</mapper>
