<?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.crm.web.dao.mapper.WebInformationMapper">

    <select id="countList" resultType="integer"
            parameterType="com.crm.rely.backend.model.entity.web.information.WebInformationSearchListEntity">

        select count(*)
        from web_information
        <where>
            <if test="valid!=null">
                and `valid`=#{valid}
            </if>
            <if test="title!=null and title!=''">
                and `title` like concat("%",#{title},"%")
            </if>
            <if test="topping!=null">
                and topping=#{topping}
            </if>
            <if test="time != null">
                and #{time}>start_time
            </if>
            <if test="time != null">
                and end_time>#{time}
            </if>
            <if test="startDate != null">
                and add_time <![CDATA[ >= ]]> #{startDate}
            </if>
            <if test="endDate != null">
                and add_time <![CDATA[ < ]]> #{endDate}
            </if>
        </where>

    </select>

    <select id="pageList" resultType="com.crm.rely.backend.model.pojo.table.WebInformationTable"
            parameterType="com.crm.rely.backend.model.entity.web.information.WebInformationSearchListEntity">

        select *
        from web_information
        <where>
            <if test="valid!=null">
                and `valid`=#{valid}
            </if>
            <if test="title!=null and title!=''">
                and `title` like concat("%",#{title},"%")
            </if>
            <if test="topping!=null">
                and topping=#{topping}
            </if>
            <if test="time != null">
                and #{time}>start_time
            </if>
            <if test="time != null">
                and end_time>#{time}
            </if>
            <if test="startDate != null">
                and add_time <![CDATA[ >= ]]> #{startDate}
            </if>
            <if test="endDate != null">
                and add_time <![CDATA[ < ]]> #{endDate}
            </if>
        </where>
        order by
        <if test="sortType!=null and sortName!=null and sortName !=''">
            <if test="sortType==1">
                web_information.${sortName},
            </if>
            <if test="sortType==2">
                web_information.${sortName} desc,
            </if>
        </if>
        web_information.topping desc, web_information.start_time desc
        <if test="page!=null">
            limit #{page.offset},#{page.row}
        </if>
    </select>
</mapper>