package dev.lions.user.manager.server.impl.mapper;

import dev.lions.user.manager.dto.sync.SyncHistoryDTO;
import dev.lions.user.manager.server.impl.entity.SyncHistoryEntity;
import org.mapstruct.*;

import java.util.List;

@Mapper(componentModel = MappingConstants.ComponentModel.JAKARTA_CDI, injectionStrategy = InjectionStrategy.CONSTRUCTOR, unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface SyncHistoryMapper {

    @Mapping(target = "id", source = "id", qualifiedByName = "longToString")
    SyncHistoryDTO toDTO(SyncHistoryEntity entity);

    List<SyncHistoryDTO> toDTOList(List<SyncHistoryEntity> entities);

    @Named("longToString")
    default String longToString(Long id) {
        return id != null ? id.toString() : null;
    }
}
