package com.viettel.campaign.service.impl;

import com.viettel.campaign.model.acd_full.Agents;
import com.viettel.campaign.repository.acd_full.AgentsRepository;
import com.viettel.campaign.service.AgentsService;
import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.web.dto.ResultDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AgentsServiceImpl implements AgentsService {

    @Autowired
    AgentsRepository agentsRepository;

    @Override
    public ResultDTO getAgentsByAgentId(String agentId) {
        ResultDTO result = new ResultDTO();

        Agents data = agentsRepository.getByAgentId(agentId);

        if (data != null) {
            result.setErrorCode(Constants.ApiErrorCode.SUCCESS);
            result.setDescription("agents data");
            result.setData(data);

        } else {
            result.setErrorCode(Constants.ApiErrorCode.ERROR);
            result.setDescription("agents data null");
        }

        return result;
    }
}
