package com.its.api.utis.repository;

import com.its.api.utis.model.entity.Rsemst;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface RsemstRepository extends JpaRepository<Rsemst, String>, JpaSpecificationExecutor<Rsemst> {

    @Query("select p from Rsemst p left outer join fetch p.state")
    List<Rsemst> findAllList();

    @Query("select count(p.rseid) as total from Rsemst p")
    Integer findAllListCount();

    @Query("select count(p.rseid) as normal from Rseopstate p, Rsemst m where p.rseid = m.rseid and p.colldt > (sysdate - 30/1440)")
    Integer findAllListNormalCount();
}
