package com.YuyeTech.TPlat.game.gameInfo.repository;

import com.YuyeTech.TPlat.common.repository.CommonRepository;
import com.YuyeTech.TPlat.game.gameInfo.projo.GamePicture;
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.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

/**
 * @author:slambb
 * @date:2020/1/16
 */
// extends JpaRepository<GamePicture,Integer>
@Repository
public interface GamePicturesRepository extends CommonRepository<GamePicture,Integer> {

    //根据游戏id 查找对应的图片信息id
    List<GamePicture> findByGameId(String gameId);

    Page<GamePicture> findByGameId(String gameId, Pageable pageable);

    Optional<GamePicture> findByGpTypeAndGameId(Integer type,String gameId);

    @Query(value = "select picture_id from game_picture where game_id = :gameId " , nativeQuery = true)
    List<Integer> findPictureIdListByGameId(String gameId);

    void deleteAllByGpTypeAndGameId(Integer type,String gameId);

}
