package com.crm.custom.service.impl;

import com.crm.custom.dao.repository.CustomFileHistoryRepository;
import com.crm.custom.service.CustomFileHistoryService;
import com.crm.rely.backend.model.entity.custom.file.history.CustomFileHistoryAddEntity;
import com.crm.rely.backend.core.pojo.table.CustomFileHistoryTable;
import com.crm.rely.backend.core.exception.ServiceException;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @description:
 * @author: houn
 * @create: 2020-07-19 16:57
 **/
@Service
public class CustomFileHistoryServiceImpl implements CustomFileHistoryService {

    @Autowired
    private CustomFileHistoryRepository customFileHistoryRepository;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void add(CustomFileHistoryAddEntity entity) throws ServiceException {
        CustomFileHistoryTable customFileHistoryTable = new CustomFileHistoryTable();

        BeanUtils.copyProperties(entity, customFileHistoryTable);

        customFileHistoryRepository.save(customFileHistoryTable);

    }
}
