package digital.laboratory.platform.inspection.convert;

import digital.laboratory.platform.inspection.dto.TestSampleDataExpandDTO;
import digital.laboratory.platform.inspection.entity.TestRecordSampleDataExpand;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author ChenJiangBao
 * @version 1.0
 * @description: 样本实验扩展数据实现类
 * @date 2025/3/21 15:35
 */
public class TestSampleDataExpandConverter {

    /**
     * DTO 转实体类
     */
    public static TestRecordSampleDataExpand dtoToEntity(TestSampleDataExpandDTO dto) {
        if (dto == null) return null;
        TestRecordSampleDataExpand testRecordSampleDataExpand = new TestRecordSampleDataExpand();
        testRecordSampleDataExpand.setId(dto.getId());
        testRecordSampleDataExpand.setTestDataId(dto.getTestDataId());
        testRecordSampleDataExpand.setPeakArea(dto.getPeakArea());
        testRecordSampleDataExpand.setFragmentRetTime(dto.getFragmentRetTime());
        testRecordSampleDataExpand.setQualitativeIonPair(dto.getQualitativeIonPair());
        return testRecordSampleDataExpand;
    }

    /**
     * dto列表转实体列表
     * @param dtoList
     * @return
     */
    public static List<TestRecordSampleDataExpand> dtoToEntityList(List<TestSampleDataExpandDTO> dtoList) {
        if (dtoList == null) return Collections.emptyList();
        return dtoList.stream().map(TestSampleDataExpandConverter::dtoToEntity).collect(Collectors.toList());
    }

}
