package com.crm.custom.service.impl;

import com.crm.custom.dao.repository.CustomFundHistoryRepository;
import com.crm.custom.service.CustomFundHistoryService;
import com.crm.rely.backend.core.exception.ServiceException;
import com.crm.rely.backend.model.entity.custom.fund.history.CustomFundHistoryAddEntity;
import com.crm.rely.backend.model.pojo.table.CustomFundHistoryTable;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class CustomFundHistoryServiceImpl implements CustomFundHistoryService {

    @Autowired
    private CustomFundHistoryRepository customFundHistoryRepository;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void add(CustomFundHistoryAddEntity entity) throws ServiceException {
        CustomFundHistoryTable customFundHistoryTable = new CustomFundHistoryTable();
        BeanUtils.copyProperties(entity, customFundHistoryTable);
        customFundHistoryRepository.save(customFundHistoryTable);
    }
}
