package com.eactive.eai.common.sessioninfo.mapper;

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

import com.eactive.eai.common.sessioninfo.TerminalInfoVO;
import com.eactive.eai.common.sessioninfo.TerminalInfoVO.Status;
import com.eactive.eai.data.entity.onl.sessioninfo.TerminalInfo;
import com.eactive.eai.data.mapper.GenericMapper;

@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface TerminalInfoMapper extends GenericMapper<TerminalInfoVO, TerminalInfo> {
	@Mapping(source = "terminalNo", target = "terminalNo")
	@Mapping(source = "brnCd", target = "brnCode")
	@Mapping(source = "brnName", target = "brnName")
	@Mapping(source = "createTime", target = "createTime")
	@Mapping(source = "rofcCd", target = "rofcCode")
	@Mapping(source = "socInstance", target = "socInstance")
	@Mapping(source = "socRemoteAddr", target = "socRemoteAddr")
	@Mapping(source = "socSessionStatus", target = "socSessionStatus")
	@Override
	TerminalInfoVO toVo(TerminalInfo entity);

	@InheritInverseConfiguration
	@Mapping(source = "socSessionStatusInfo", target = "socSessionStatus")
	TerminalInfo toEntity(TerminalInfoVO vo);

	default Status mapStatus(String statusString) {
		return Status.inactive.toString().equals(statusString) ? Status.inactive : Status.active;
	}

}
