<?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.thinkgem.jeesite.modules.homepage.dao.AdvDao">

    <select id="getAdvList" resultType="com.thinkgem.jeesite.modules.homepage.entity.AdvEntity">
        SELECT
            a.id,
            a.code,
            a.type,
            a.title,
            a.href,
            a.target,
            a.picture,
            a.weight,
            a.status,
            a.clicks,
            a.expire_time AS expireTime,
            a.begin_time AS beginTime,
            a.create_date AS created,
            a.create_by AS createdUser,
            a.update_date AS modified,
            a.update_by AS modifiedUser
        FROM youka_adv a
        WHERE a.status = 1
            <![CDATA[ AND (a.begin_time <= NOW() OR a.begin_time IS NULL)]]>
            <![CDATA[ AND (a.expire_time >= NOW() OR a.expire_time IS NULL)]]>
            AND a.type='A'
        ORDER BY a.weight DESC
    </select>
</mapper>