package com.eactive.eai.rms.onl.apim.portaluser;

import com.eactive.apim.portal.portaluser.entity.PortalUser;
import org.mapstruct.*;

@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface PortalUserUIMapper {

	@Mapping(source = "portalOrg.id", target = "orgId")
	@Mapping(target = "userStatusDescription", expression = "java(entity.getUserStatus() != null ? entity.getUserStatus().getDescription() : \"\")")
	@Mapping(target = "approvalStatusDescription", expression = "java(entity.getApprovalStatus() != null ? entity.getApprovalStatus().getDescription() : \"\")")
	@Mapping(target = "roleCodeDescription", expression = "java(entity.getRoleCode() != null ? entity.getRoleCode().getDescription() : \"\")")
	PortalUserUI toVo(PortalUser entity);

	@Mapping(target = "portalOrg", ignore = true)
	PortalUser toEntity(PortalUserUI vo);

	@Mapping(target = "portalOrg", ignore = true)
	@BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
	void updateToEntity(PortalUserUI portalUserUI, @MappingTarget PortalUser portalUser);

}
