package com.izouma.nineth.repo;

import com.izouma.nineth.domain.MetaBonusScene;
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 MetaBonusSceneRepo extends JpaRepository<MetaBonusScene, Long>, JpaSpecificationExecutor<MetaBonusScene> {

    List<MetaBonusScene> findAllByUserId(Long userId);

    MetaBonusScene findByUserIdAndButton(Long userId, int button);

    @Query(nativeQuery = true, value = "select count(*) from (select count(*) num from meta_bonus_scene group by user_id )a where a.num >= 15")
    long countNum();
}
