package com.uas.finance.dao;

import com.uas.finance.model.Receipt;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 发票dao层
 * created by shicr on 2018/1/27
 **/
@Repository
public interface ReceiptDao extends JpaRepository<Receipt,Long>{

    /**
     * 删除某出账下的所有发票
     * @param aaid
     * @return
     */
    @Transactional
    @Modifying
    @Query(value = "delete from receipt where aa_id = ?1",nativeQuery = true)
    void deleteByAa_id(Long aaid);

    /**
     * 找到出账单下的所有发票
     * @param aaid
     * @return
     */
    @Query(value = "select * from receipt where aa_id = ?1",nativeQuery = true)
    List<Receipt> findByAa_id(Long aaid);
}
