package digital.laboratory.platform.imr.convert;

import cn.hutool.core.collection.CollUtil;
import digital.laboratory.platform.imr.dto.DrugMaterialInfoDTO;
import digital.laboratory.platform.imr.entity.DrugMaterialInfo;

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

/**
 * 毒品检材信息转换类
 */
public class DrugMaterialInfoConvert {

    public static DrugMaterialInfo dtoToEntity(DrugMaterialInfoDTO dto) {
        if (dto == null) {
            return null;
        }
        DrugMaterialInfo drugMaterialInfo = new DrugMaterialInfo();
        drugMaterialInfo.setId(dto.getId());
        drugMaterialInfo.setCaseId(dto.getCaseId());
        drugMaterialInfo.setDrugName(dto.getDrugName());
        drugMaterialInfo.setMassVolume(dto.getMassVolume());
        drugMaterialInfo.setUnit(dto.getUnit());
        drugMaterialInfo.setPackageComplete(dto.getPackageComplete());
        return drugMaterialInfo;
    }

    public static List<DrugMaterialInfo> dtoToEntityList(List<DrugMaterialInfoDTO> dtos) {
        if (CollUtil.isEmpty(dtos)) {
            return Collections.emptyList();
        }
        return dtos.stream().map(dto -> dtoToEntity(dto)).collect(Collectors.toList());
    }

}
