package com.eactive.eai.rms.common.acl.user.mapper;

import com.eactive.apim.portal.user.entity.UserInfo;
import com.eactive.eai.rms.common.acl.user.ui.UserUI;
import org.mapstruct.BeanMapping;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.NullValuePropertyMappingStrategy;
import org.mapstruct.ReportingPolicy;

import com.eactive.eai.data.mapper.GenericMapper;

@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface UserUIMapper extends GenericMapper<UserUI, UserInfo> {

	@Override
	@Mapping(source = "userid", target = "userId")
	@Mapping(source = "username", target = "userName")
	@Mapping(source = "teamname", target = "teamName")
	@Mapping(source = "lastamndyms", target = "LASTAMNDYMS")
	@Mapping(source = "secondmentbrncd", target = "SECONDMENTBRNCD")
	@Mapping(source = "secondmentstdt", target = "SECONDMENTSTDT")
	@Mapping(source = "secondmentendt", target = "SECONDMENTENDT")
	@Mapping(source = "allowip", target = "allowIp")
	UserUI toVo(UserInfo entity);

	@Override
	@InheritInverseConfiguration
	UserInfo toEntity(UserUI vo);

	@InheritInverseConfiguration
	@BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
	void updateToEntity(UserUI userUI, @MappingTarget UserInfo userInfo);

}
