package com.YuyeTech.TPlat.repository;

import com.YuyeTech.TPlat.dataobject.FcInfo;
import com.YuyeTech.TPlat.dataobject.GameInfo;
import org.springframework.data.domain.Page;
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;

/**
 * @author:slambb
 * @date:2020/1/10
 */
public interface FcInfoRepository extends JpaRepository<FcInfo,Integer> , JpaSpecificationExecutor<FcInfo> {
    /**
     * In查询，根据参数列表顺序返回对象顺序
     * @param fcIdList
     * @return
     */
    @Query(value = "select * from fc_info where `fc_id` in :fcIdList order by FIELD(`fc_id`,:fcIdList)" , nativeQuery = true)
    List<FcInfo> GIRepFindByFcIdInOrderByField(List<Integer> fcIdList);

    /**
     * In查询，根据参数列表返回对象列表
     * @param fcIdList
     * @return
     */
    @Query(value = "select * from fc_info where `fc_id` in :fcIdList" , nativeQuery = true)
    List<FcInfo> GIRepFindByFcIdIn(List<Integer> fcIdList);

    /**
     * 获取游戏详情
     * @param gameId
     * @return
     */
    FcInfo findByFcId(Integer gameId);

    /**
     * 根据类目查找列表
     * @param categoryType
     * @param pageable
     * @return
     */
    List<FcInfo> findByFcType(Integer categoryType, Pageable pageable);

    /**
     * 根据类目查找列表
     * @param categoryType
     * @param pageable
     * @return
     */
    Page<FcInfo> findPageByFcType(Integer categoryType, Pageable pageable);

    Page<FcInfo> findAllByFcRankingShow(Integer rankingShow, Pageable pageable);
}
