package com.yn.bftl.thirdparty.common.repository;

import com.yn.bftl.common.modules.account.entity.Account;
import com.yn.bftl.common.modules.account.enums.AccountType;
import com.yn.bftl.common.modules.company.entity.Company;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

/**
 * $AccountRepository
 *
 * @author chendehuihuo
 * @date 2022-07-18 14:10
 * @return
 */
@Repository
public interface AccountRepository extends JpaRepository<Account, Long> {

    Account findFirstByCompanyAndType(Company company, AccountType type);

    @Query(value = "select acc from Account acc " +
            " where acc.company.id = ?1 and acc.type = 'DEPOSIT'" )
    Account findDepositAccount(Long companyId);
}
