package com.izouma.nineth.repo.rewardpoints;

import com.izouma.nineth.domain.DrawLotteryHistory;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface DrawLotteryHistoryRepo extends JpaRepository<DrawLotteryHistory, Long>, JpaSpecificationExecutor<DrawLotteryHistory> {

    @Query(value = "select new DrawLotteryHistory(t.userName,t.awardName,t.status,t.trackingNumber) from " +
            "DrawLotteryHistory t where t.del = false and t.activityId = ?1 and t.awardType != 'EMPTY' order by t.createdAt desc")
    List<DrawLotteryHistory> findByActivityIdLimit50(Long activityId, Pageable pageable);
}
