package vn.azteam.tpf.service.mapper;

import vn.azteam.tpf.domain.*;
import vn.azteam.tpf.service.dto.TBObjectParameterDTO;

import org.mapstruct.*;

/**
 * Mapper for the entity TBObjectParameter and its DTO TBObjectParameterDTO.
 */
@Mapper(componentModel = "spring", uses = {TBDetailUserMapper.class,
                                            TBActivityTypeMapper.class,
                                            TBActivityExtendTypeMapper.class,
                                            TBControlTypeMapper.class})
public interface TBObjectParameterMapper extends EntityMapper<TBObjectParameterDTO, TBObjectParameter> {

    @Mapping(source = "deletedBy.id", target = "deletedById")
    @Mapping(source = "createdBy.id", target = "createdById")
    @Mapping(source = "modifiedBy.id", target = "modifiedById")
    @Mapping(source = "activityType.id", target = "activityTypeId")
    @Mapping(source = "activityType.customer.id", target = "tbCustomerId")
    @Mapping(source = "tbControlType.id", target = "tbControlTypeId")
    @Mapping(source = "tbControlType.name", target = "tbControlTypeName")
    @Mapping(source = "tbActivityExtendType.id", target = "tbActivityExtendTypeId")
    @Mapping(source = "tbActivityExtendType.name", target = "tbActivityExtendTypeName")
    @Mapping(source = "tbActivityExtendType.externalTable", target = "tbActivityExtendTypeExternalTable")
    @Mapping(source = "tbActivityExtendType.objectType", target = "tbActivityExtendTypeObjectType")
    @Mapping(source = "tbActivityExtendType.condition", target = "tbActivityExtendTypeCondition")
    @Mapping(target = "relationTable", ignore = true)
    @Mapping(target = "foreignKey", ignore = true)
    @Mapping(target = "tbActivityExtendTypeDropDownDTOList", ignore = true)
    TBObjectParameterDTO toDto(TBObjectParameter tBObjectParameter);

    @Mapping(source = "deletedById", target = "deletedBy")
    @Mapping(source = "createdById", target = "createdBy")
    @Mapping(source = "modifiedById", target = "modifiedBy")
    @Mapping(source = "activityTypeId", target = "activityType")
    @Mapping(source = "tbActivityExtendTypeId", target = "tbActivityExtendType")
    @Mapping(source = "tbControlTypeId", target = "tbControlType")
    TBObjectParameter toEntity(TBObjectParameterDTO tBObjectParameterDTO);

    default TBObjectParameter fromId(Long id) {
        if (id == null) {
            return null;
        }
        TBObjectParameter tBObjectParameter = new TBObjectParameter();
        tBObjectParameter.setId(id);
        return tBObjectParameter;
    }
}
