package com.bizzan.bitrade.dao;

import com.bizzan.bitrade.dao.base.BaseDao;
import com.bizzan.bitrade.entity.AppBanner;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * APP Banner 数据访问层
 */
public interface AppBannerDao extends BaseDao<AppBanner> {

    /**
     * 查询当前生效的Banner列表（状态启用 + 在时间范围内），按排序值和ID降序
     */
    @Query(value = "select * from app_banner where status = 1 " +
            "and (start_time is null or start_time <= NOW()) " +
            "and (end_time is null or end_time >= NOW()) " +
            "order by sort desc, id desc",
            nativeQuery = true)
    List<AppBanner> findActiveBanners();
}
