package com.crm.manager.service.impl;

import com.crm.manager.dao.repository.CustomSurveyRepository;
import com.crm.manager.service.CustomSurveyService;
import com.crm.rely.backend.core.dto.custom.survey.CustomSurveyDto;
import com.crm.rely.backend.core.pojo.table.CustomSurveyTable;
import com.crm.rely.backend.exception.ServiceException;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CustomSurveyServiceImpl implements CustomSurveyService {

    @Autowired
    private CustomSurveyRepository customSurveyRepository;

    @Override
    public CustomSurveyDto getByCustomId(Long id) throws ServiceException {
        CustomSurveyTable customSurveyTable = customSurveyRepository.getFirstByCustomId(id);
        if (customSurveyTable == null) {
            return null;
        }
        CustomSurveyDto customSurveyDto = new CustomSurveyDto();

        BeanUtils.copyProperties(customSurveyTable, customSurveyDto);
        return customSurveyDto;
    }
}
