package org.jeecg.modules.inventory.convert;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.inventory.dto.ItdmSampleExpireDTO;
import org.jeecg.modules.inventory.entity.ItdmSampleExpire;
import org.jeecg.modules.inventory.vo.ItdmSampleExpireListVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;
import org.springframework.util.CollectionUtils;

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

@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE,imports ={ CollectionUtils.class, Collectors.class})
public interface ItdmSampleExpireConvert {

    ItdmSampleExpireConvert INSTANCE = Mappers.getMapper(ItdmSampleExpireConvert.class);

    @Mapping(target ="barCodes",source ="barCodes")
    ItdmSampleExpire convert(ItdmSampleExpireDTO dto, String barCodes);

    @Mapping(target ="barCodes",source ="barCodeList")
    ItdmSampleExpireListVO convert1(ItdmSampleExpire sampleExpire, List<String> barCodeList);


    @Mapping(target ="records",source ="results" )
    Page<ItdmSampleExpireListVO> convertPage(Page<ItdmSampleExpire> page, List<ItdmSampleExpireListVO> results);

}
