package com.ssj.dao.sys.photoscroll.dao;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import com.ssj.bean.sys.photoscroll.bean.Photoscroll;

import java.util.List;

@Repository
public interface PhotoscrollDao extends JpaRepository<Photoscroll, String> {

    public Page<Photoscroll> findAll(Specification<Photoscroll> specification, Pageable page);

    @Query(nativeQuery = true, value = "select * from  tb_photo_scroll where is_valid = 'Y' and phone_type = ?1 order by photo_order asc ")
    List<Photoscroll> getPhotoList(String phoneType);

    @Query(nativeQuery = true, value = "update tb_photo_scroll set photo_order = ?2 where id =?1 ")
    @Modifying
    Integer updatePhotoOrder(String id,int photo_order);
}
