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

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

import com.eactive.eai.common.usedate.UseDateControlVO;
import com.eactive.eai.data.entity.onl.useDate.UseDateControl;
import com.eactive.eai.data.mapper.BaseMapperConfig;
import com.eactive.eai.data.mapper.BooleanToStringMapper;
import com.eactive.eai.data.mapper.GenericMapper;
import com.eactive.eai.data.mapper.StringToBooleanMapper;

@Mapper(config = BaseMapperConfig.class)
public interface UseDateControlMapper extends GenericMapper<UseDateControlVO, UseDateControl> {
	@Mapping(source = "id.name", target = "name")
	@Mapping(source = "startdate", target = "startDate")
	@Mapping(source = "enddate", target = "endDate")
	@Mapping(source = "useyn", target = "activate", qualifiedBy = StringToBooleanMapper.class)
	@Override
	UseDateControlVO toVo(UseDateControl entity);

	@Mapping(target = "id.type", constant = "01")
	@Mapping(target = "id.name", source = "name")
	@Mapping(target = "startdate", source = "startDate")
	@Mapping(target = "enddate", source = "endDate")
	@Mapping(target = "useyn", source = "activate", qualifiedBy = BooleanToStringMapper.class)
	UseDateControl toEntity(UseDateControlVO vo);
}
