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

    <!-- 关联查询sql -->
    <sql id="selectSql">
        SELECT a.*
        FROM cms_design a
        <where>
            <if test="param.pageId != null">
                AND a.page_id = #{param.pageId}
            </if>
            <if test="param.name != null">
                AND a.name LIKE CONCAT('%', #{param.name}, '%')
            </if>
            <if test="param.categoryId != null">
                AND a.category_id = #{param.categoryId}
            </if>
            <if test="param.keywords != null">
                AND a.keywords LIKE CONCAT('%', #{param.keywords}, '%')
            </if>
            <if test="param.description != null">
                AND a.description LIKE CONCAT('%', #{param.description}, '%')
            </if>
            <if test="param.photo != null">
                AND a.photo LIKE CONCAT('%', #{param.photo}, '%')
            </if>
            <if test="param.buyUrl != null">
                AND a.buy_url LIKE CONCAT('%', #{param.buyUrl}, '%')
            </if>
            <if test="param.style != null">
                AND a.style LIKE CONCAT('%', #{param.style}, '%')
            </if>
            <if test="param.content != null">
                AND a.content LIKE CONCAT('%', #{param.content}, '%')
            </if>
            <if test="param.showLayout != null">
                AND a.show_layout = #{param.showLayout}
            </if>
            <if test="param.layout != null">
                AND a.layout LIKE CONCAT('%', #{param.layout}, '%')
            </if>
            <if test="param.parentId != null">
                AND a.parent_id = #{param.parentId}
            </if>
            <if test="param.userId != null">
                AND a.user_id = #{param.userId}
            </if>
            <if test="param.home != null">
                AND a.home = #{param.home}
            </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.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.CmsDesign">
        <include refid="selectSql"></include>
    </select>

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

</mapper>
