package com.izouma.jmrh.repo;

import com.izouma.jmrh.domain.Setting;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.util.List;

public interface SettingRepo extends JpaRepository<Setting, Long>, JpaSpecificationExecutor<Setting> {

    List<Setting> findAllByFlag(int flag);

    List<Setting> findAllByFlagIn(Iterable<Integer> flags);

    @Query(nativeQuery = true, value = "SELECT ifnull(max(flag + 1),1) FROM setting")
    int nextFlag();


    @Query(nativeQuery = true, value = "SELECT ifnull(max(sort + 1),1) FROM setting")
    int nextSort();
}