package digital.laboratory.platform.imr.convert;

import cn.hutool.core.collection.CollUtil;
import digital.laboratory.platform.imr.dto.DrugDepotsDTO;
import digital.laboratory.platform.imr.entity.DrugCaseInfo;
import digital.laboratory.platform.imr.vo.DrugCaseInfoVO;

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

/**
 * 毒品案件转换类
 */
public class DrugCaseInfoConvert {

    public static DrugCaseInfo dtoTOEntity(DrugDepotsDTO dto) {
        if (dto == null) {
            return null;
        }
        DrugCaseInfo drugCaseInfo = new DrugCaseInfo();
        drugCaseInfo.setId(dto.getId());
        drugCaseInfo.setCaseName(dto.getCaseName());
        drugCaseInfo.setCaseNo(dto.getCaseNo());
        drugCaseInfo.setHandingOverOrg(dto.getHandingOverOrg());
        drugCaseInfo.setHandingOverDate(dto.getHandingOverDate());
        drugCaseInfo.setFrontOrgIds(dto.getFrontOrgIds());
        return drugCaseInfo;
    }

    public static DrugCaseInfoVO entityToVO(DrugCaseInfo entity) {
        if (entity == null) {
            return null;
        }

        DrugCaseInfoVO drugCaseInfoVO = new DrugCaseInfoVO();
        drugCaseInfoVO.setId(entity.getId());
        drugCaseInfoVO.setCaseName(entity.getCaseName());
        drugCaseInfoVO.setCaseNo(entity.getCaseNo());
        drugCaseInfoVO.setHandingOverOrg(entity.getHandingOverOrg());
        drugCaseInfoVO.setHandingOverDate(entity.getHandingOverDate());
        drugCaseInfoVO.setFrontOrgIds(entity.getFrontOrgIds());
        return drugCaseInfoVO;
    }

    public static List<DrugCaseInfoVO> entityToVOList(List<DrugCaseInfo> entityList) {
        if (CollUtil.isEmpty(entityList)) {
            return Collections.emptyList();
        }
        return entityList.stream().map(entity -> entityToVO(entity)).collect(Collectors.toList());
    }
}
