package kr.co.jinwoosi.clfd.clfd.dgns.service;

import kr.co.jinwoosi.clfd.clfd.dgns.mapper.DgnsListMapper;
import kr.co.jinwoosi.clfd.clfd.dgns.model.DgnsList;
import kr.co.jinwoosi.clfd.clfd.dgns.vo.DgnsSelection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DgnsListService {

    @Autowired
    private DgnsListMapper dgnsListMapper;

    public void saveDgnsList(Long userId, Long dgnsId, List<DgnsSelection> dgnsSelectionList) {
        for(DgnsSelection dgnsSelection : dgnsSelectionList) {
            DgnsList dgnsList = new DgnsList();
            dgnsList.setRegId(userId);
            dgnsList.setDgnsId(dgnsId);
            dgnsList.setDgnsAskId(Long.parseLong(dgnsSelection.getDgnsAskId()));
            dgnsList.setDgnsAnsId(Long.parseLong(dgnsSelection.getDgnsAnsId()));
            dgnsListMapper.insert(dgnsList);
        }
    }
}
