package com.jkcredit.invoice.hub.service.searchInvoiceResult;

import com.jkcredit.invoice.hub.mapper.SearchInvoiceResultMapper;
import com.jkcredit.invoice.hub.model.dto.searchInvoiceResult.SearchInvoiceResultDto;
import com.jkcredit.invoice.hub.model.po.searchInvoiceResult.SearchInvoiceResultPo;
import com.jkcredit.invoice.hub.service.base.BaseService;
import com.jkcredit.invoice.hub.spi.lang.exception.ServiceException;
import com.jkcredit.invoice.hub.util.BeanUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @description:
 * @author: xusonglin
 * @create: 2020/1/18 20:52
 * @version: V1.0
 **/
@Slf4j
@Service
public class SearchInvoiceResultServiceImpl extends BaseService implements SearchInvoiceResultService {
    @Resource
    SearchInvoiceResultMapper mapper;

    @Override
    public void saveSearchInvoiceResult(SearchInvoiceResultDto dto) {
        SearchInvoiceResultPo po = new SearchInvoiceResultPo();
        BeanUtil.copyProperties(po, dto);
        po.setCreateTime(new Date());
        try {
            mapper.insert(po);
        } catch (Exception e) {
            log.error("插入发票数据失败，失败原因：{}", e.getMessage());
            throw new ServiceException("插入发票数据失败");
        }
    }
}
