package com.uas.finance.service.Impl;

import com.uas.finance.dao.AccountApplyDao;
import com.uas.finance.dao.ReceiptDao;
import com.uas.finance.model.Receipt;
import com.uas.finance.service.ReceiptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 发票保存接口实现层
 * created by shicr on 2018/1/27
 **/
@Service
public class ReceiptServiceImpl implements ReceiptService {

    @Autowired
    private ReceiptDao dao;

    @Autowired
    private AccountApplyDao accountApplyDao;

    /**
     * 发票保存
     *
     * @param receipts
     * @return
     */
    @Override
    public List<Receipt> save(List<Receipt> receipts) {

        ArrayList<Receipt> list = new ArrayList<Receipt>();
        for (Receipt receipt : receipts) {
            Receipt receipt1 = dao.save(receipt);
            list.add(receipt1);
        }
        return list;
    }

    /**
     * 删除某出账下面的所有发票
     *
     * @param id
     * @return
     */
    public void delete(Long id) {
       dao.delete(id);
    }

    /**
     * 找到某出账单下的所有发票
     *
     * @param aaid
     * @return
     */
    @Override
    public List<Receipt> findByAaid(Long aaid) {
        return dao.findByAa_id(aaid);
    }
}
