package cn.hnthyy.thmz.service.impl.thmz;

import cn.hnthyy.thmz.entity.thmz.Receipt;
import cn.hnthyy.thmz.mapper.thmz.ReceiptMapper;
import cn.hnthyy.thmz.service.thmz.ReceiptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class ReceiptServiceImpl implements ReceiptService {
    @SuppressWarnings("all")
    @Autowired
    private ReceiptMapper receiptMapper;
    @Override
    public int saveReceipt(Receipt receipt) {
        receipt.setUpdateDate(new Date());
        if(receipt.getId()==null){
            return receiptMapper.insertReceipt(receipt);
        }
        return receiptMapper.updateReceipt(receipt);
    }

    @Override
    public Receipt queryByUserIdCode(String userIdCode) {
        return receiptMapper.selectByUserIdCode(userIdCode);
    }

    @Override
    public int modifyReceipt(Receipt receipt) {
        return receiptMapper.updateReceipt(receipt);
    }
}
