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

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

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

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

    public PaperDto toDto(Paper paper) {
        PaperDto paperDto = new PaperDto();
        paperDto.setId(paper.getId());
        paperDto.setName(paper.getName());
        paperDto.setTitle(paper.getTitle());
        paperDto.setParams(paper.getParams());
        paperDto.setTotalScore(paper.getTotalScore());
        paperDto.setExamRemark(paper.getExamRemark());
        return paperDto;
    }

    public List<PaperDto> toDtoList(List<Paper> paperList) {
        return paperList.stream()
                .map(paper -> toDto(paper))
                .collect(Collectors.toList());
    }
}
