package com.qsoft.rs.sincoar.dominio.mapper;

import com.qsoft.rs.sincoar.model.MdApplicationfiles;
import com.qsoft.rs.sincoar.dto.MdApplicationfilesDTO;
import com.qsoft.rs.sincoar.dto.MdColumnsDTO;
import com.qsoft.rs.sincoar.model.MdColumns;
import org.mapstruct.AfterMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.factory.Mappers;

@Mapper
public interface MdApplicationfilesMapper {

    MdApplicationfilesMapper INSTANCE = Mappers.getMapper(MdApplicationfilesMapper.class);

    @Mapping(source = "applicationsIdFk", target = "applicationsIdFk.id")
    MdApplicationfiles getEntidad(MdApplicationfilesDTO mdApplicationfiles);

    @Mapping(target = "applicationsIdFk", source = "applicationsIdFk.id")
    MdApplicationfilesDTO getDto(MdApplicationfiles mdApplicationfiles);
    @AfterMapping
    default void validaNulos(MdApplicationfilesDTO mdApplicationfilesDto, @MappingTarget MdApplicationfiles mdApplicationfiles) {
        if (mdApplicationfiles.getApplicationsIdFk() != null && mdApplicationfiles.getApplicationsIdFk().getId() == null) {
            mdApplicationfiles.setApplicationsIdFk(null);
        }
        
    }
}