package cn.com.qmth.examcloud.core.questions.service.bean;

import cn.com.qmth.examcloud.core.questions.base.question.PaperDetailDto;
import cn.com.qmth.examcloud.core.questions.dao.entity.PaperDetail;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by songyue on 18/1/5.
 */
@Component
public class PaperDetailDtoAssembler {

    public PaperDetailDto toDto(PaperDetail paperDetail) {
        PaperDetailDto paperDetailDto = new PaperDetailDto();
        paperDetailDto.setId(paperDetail.getId());
        paperDetailDto.setName(paperDetail.getName());
        paperDetailDto.setNumber(paperDetail.getNumber());
        paperDetailDto.setScore(paperDetail.getScore());
        return paperDetailDto;
    }

    public List<PaperDetailDto> toDtoList(List<PaperDetail> paperDetailList) {
        List<PaperDetailDto> paperDetailDtos = new ArrayList<>();
        for (PaperDetail paperDetail : paperDetailList) {
            paperDetailDtos.add(toDto(paperDetail));
        }
        return paperDetailDtos;
    }
}
