package cn.com.qmth.stmms.ms.core.repository;

import cn.com.qmth.stmms.ms.core.domain.Level;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by zhengmin on 2016/9/24.
 */
public interface LevelRepo extends JpaRepository<Level, Long> {

    List<Level> findByWorkId(Long workId);

    Level findByWorkIdAndCode(Long workId, String code);

    @Query("select max(l.code) from Level l where l.workId = ?1")
    String findMaxCodeByWorkId(Long workId);

    List<Level> findByWorkIdAndCodeNotIn(Long workId, List<String> levelList);

    long countByWorkIdAndCodeIn(Long workId, List<String> levelList);

    List<Level> findByWorkIdOrderByCode(Long workId);
}
