TkioFlowRepository.java 1.39 KB
Newer Older
lzxry committed
1 2 3 4 5 6 7 8
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;

lzxry committed
9
import java.math.BigDecimal;
lzxry committed
10
import java.util.ArrayList;
lzxry committed
11

kangxiaoshan committed
12
public interface TkioFlowRepository extends JpaRepository<TkioFlow, Long> {
lzxry committed
13 14

    @Query(value = "select sum(flow) from tkio_flow where email = ?1 and contract_code = ?2", nativeQuery = true)
lzxry committed
15
    BigDecimal sumFlowByEmailAndContractCode(String email, String contractCode);
lzxry committed
16 17 18 19 20

    @Transactional
    @Modifying
    @Query(value = "delete from tkio_flow where email = ?1", nativeQuery = true)
    void deleteByEmail(String email);
lzxry committed
21 22 23

    @Query(value = "select sum(flow) from tkio_flow where contract_code = ?1 and ds >= ?2 and ds <= ?3", nativeQuery = true)
    BigDecimal sumFlowByContractCodeAndDs(String code, String startDate, String endDate);
lzxry committed
24 25 26

    @Query(value = "select sum(flow) from tkio_flow where contract_code in ?3 and ds >= ?1 and ds <= ?2", nativeQuery = true)
    BigDecimal sumFlowByDsAndContractCodes(String startDate, String endDate, ArrayList<String> contractCode);
kangxiaoshan committed
27 28 29 30 31

    @Transactional
    @Modifying
    @Query(value = "delete from tkio_flow where email = ?1 and ds = ?2", nativeQuery = true)
    void deleteByEmailDs(String email, String yesterday);
lzxry committed
32
}