AccountRepository.java 1.48 KB
Newer Older
manxiaoqiang committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
package tkio.repository;

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;
import tkio.model.Account;

import java.math.BigInteger;
import java.util.Date;
import java.util.List;

@Transactional
public interface AccountRepository extends JpaRepository<Account, Long> {

    @Query(value = "select root_parent from account where id=?1", nativeQuery = true)
    BigInteger findRootParentByAccountId(Long accountId);

    @Query(value = "SELECT * from account where is_super_user is true and `status` = 1 and past_date > ?1", nativeQuery = true)
    List<Account> findRootParentsUnPast(String today);

    @Query(value = "SELECT * from account where is_super_user is true and `status` = 1 and past_date < ?1", nativeQuery = true)
    List<Account> findRootParentsPast(String today);

manxiaoqiang committed
25 26 27
    @Query(value = "SELECT * from account where is_super_user is true and  bussinessman = ?1", nativeQuery = true)
    List<Account> findBussnissMan(List<Integer> bussinussIds);

28 29 30 31 32
    @Query(value = "select * from account where root_parent = ?1", nativeQuery = true)
    List<Account> findByRootParent(Long accountId);

    @Query(value = "select count(*) from account where root_parent = ?1 and create_time > ?2 and create_time < ?3", nativeQuery = true)
    BigInteger countByRootParent(Long accountId, String startDate, String endDate);
manxiaoqiang committed
33
}