package com.eactive.eai.rms.onl.manage.serviceinfo.routingeaimsg;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.eactive.eai.rms.common.base.BaseService;
import com.eactive.eai.rms.data.entity.onl.eaimsg.EAIMessageService;
import com.eactive.eai.rms.data.entity.onl.eaimsg.RoutingEaiMsgDto;
import com.eactive.eai.rms.data.entity.onl.eaimsg.RoutingEaiMsgSearch;

@Service
@Transactional
public class RoutingEaiMsgManService extends BaseService {

	private EAIMessageService eaiMessageService;

	@Autowired
	public RoutingEaiMsgManService(EAIMessageService eaiMessageService) {
		this.eaiMessageService = eaiMessageService;
	}

	public Page<RoutingEaiMsgUI> selectList(Pageable pageable, RoutingEaiMsgSearch routingEaiMsgSearch) {
		Page<RoutingEaiMsgDto> page = eaiMessageService.findAll(pageable, routingEaiMsgSearch);
		return page.map(this::convertToRoutingEaiMsgUI);
	}

	private RoutingEaiMsgUI convertToRoutingEaiMsgUI(RoutingEaiMsgDto routingEaiMsgDto) {

		RoutingEaiMsgUI ui = new RoutingEaiMsgUI();

		ui.setEaiSvcName(routingEaiMsgDto.getEaiSvcName());
		ui.setEaiSevrInstncName(routingEaiMsgDto.getEaiSevrInstncName());
		ui.setSvcMotivUsedStcd(routingEaiMsgDto.getSvcMotivUsedStcd());
		ui.setPsvIntfacDsticName(routingEaiMsgDto.getPsvIntfacDsticName());
		ui.setTot(routingEaiMsgDto.getTot());
		ui.setFlowCtrlRoutName(routingEaiMsgDto.getFlowCtrlRoutName());
		ui.setNonMotivRoutUriName(routingEaiMsgDto.getNonMotivRoutUriName());
		ui.setEaiBzwkDstcd(routingEaiMsgDto.getEaiBzwkDstcd());

		return ui;
	}

}
