package com.softwarebr.nunu.dao.oper;

import com.softwarebr.nunu.entity.oper.Advertisement;
import com.brframework.commondb.core.CommonRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @date 2020-02-18 10:58:32
 * @author lilin
 */

@Repository
public interface AdvertisementDao extends CommonRepository<Long, Advertisement> {

    /**
     * 查询时间区间上架广告信息
     * @param status 状态
     * @param newTime 时间
     * @param position 广告位置
     * @return
     */
    @Query("from Advertisement where position = :position and status = :status and :newTime between startDate and endDate order by sortValue asc ")
    List<Advertisement> findByStatusDateOrderBySortValue(@Param("status") Integer status, @Param("newTime") LocalDateTime newTime, @Param("position") Integer position);

}