package common.repository;

import common.model.TkioFlow;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

public interface TkioFlowRepository  extends JpaRepository<TkioFlow, Long> {

    @Query(value = "select sum(flow) from tkio_flow where email = ?1 and contract_code = ?2", nativeQuery = true)
    Long sumFlowByEmailAndContractCode(String email, String contractCode);

    @Transactional
    @Modifying
    @Query(value = "delete from tkio_flow where email = ?1", nativeQuery = true)
    void deleteByEmail(String email);
}
