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

import java.util.Map;

import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import com.eactive.eai.data.entity.onl.bizkey.BizKey;
import com.eactive.eai.data.entity.onl.bizkey.BizKeyId;
import com.eactive.eai.data.mapper.BaseMapperConfig;
import com.eactive.eai.data.mapper.GenericMapper;

@Mapper(config = BaseMapperConfig.class)
public interface FieldExtractInfoUIMapper extends GenericMapper<FieldExtractInfoUI, BizKey> {

	@Mapping(source = "id.eaisvcname", target = "eaiSvcName")
	@Mapping(source = "id.etractdstcd", target = "etractDstcd")
	@Mapping(source = "id.fldprcssno", target = "fldprcssno")

	@Mapping(source = "bzwkfldname", target = "bzwkFldName")
	@Mapping(source = "msgdstcd", target = "msgDstcd")
	@Override
	FieldExtractInfoUI toVo(BizKey entity);

	@InheritInverseConfiguration
	@Override
	BizKey toEntity(FieldExtractInfoUI vo);

	@Mapping(source = "eaiSvcName" , target="id.eaisvcname")
	@Mapping(source = "etractDstcd" , target="id.etractdstcd")
	@Mapping(source = "eaiSvcName" , target="id.eaisvcname")
	
	default BizKey map(Map<String, Object> map) {
		BizKey bizKey = new BizKey();
		BizKeyId bizKeyId = new BizKeyId();
		bizKey.setId(bizKeyId);

		bizKeyId.setEaisvcname((String) map.get("eaiSvcName"));
		bizKeyId.setEtractdstcd((String) map.get("etractDstcd"));
		bizKeyId.setFldprcssno(Integer.parseInt("" + map.get("fldPrcssNo")));

		bizKey.setMsgdstcd((String) map.get("msgDstcd"));
		bizKey.setBzwkfldname((String) map.get("bzwkFldName"));
		bizKey.setEaisevrdstcd((String) map.get("eaiSevrDstcd"));
		bizKey.setModfimgtstusdstcd((String) map.get("modfiMgtStusDstcd"));

		return bizKey;
	}
	
}
