package cn.hmsoft.ltc.service.impl;

import java.sql.SQLException;
import java.util.List;
import org.springframework.stereotype.Component;
import cn.hmsoft.ltc.dao.QuestionTypeDao;
import cn.hmsoft.ltc.model.QuestionType;
import cn.hmsoft.ltc.service.iface.QuestionTypeService;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;

/**
 * 题型管理接口类实现类
 * @author Administrator
 *
 */
@Component
public class QuestionTypeServiceImpl implements QuestionTypeService {
	
	QuestionTypeDao questionTypeDao = new QuestionTypeDao();

	@Override
	public void insertQuestionType(QuestionType questionType) {
		this.questionTypeDao.insertQuestionType(questionType);
	}

	@Override
	public List<QuestionType> selectQuestionType() throws SQLException {
		List<QuestionType> questionList = this.questionTypeDao.selectQuestionType();
		return questionList;
	}

	@Override
	public boolean deleteQuestionType(int id) throws SQLException {
		boolean flag = this.questionTypeDao.deleteQuestionType(id);
		return flag;
	}

	@Override
	public ObservableList<QuestionType> selectQuestionTypeObs() throws SQLException {
		final ObservableList<QuestionType> dataList = FXCollections.observableArrayList();
		List<QuestionType> questionList = this.questionTypeDao.selectQuestionType();
		dataList.addAll(questionList);
		return dataList;
	}

	@Override
	public ObservableList<QuestionType> selectQuestionTypeObs(QuestionType questione) throws SQLException {
		final ObservableList<QuestionType> dataList = FXCollections.observableArrayList();
		List<QuestionType> questionList = this.questionTypeDao.selectQuestionType();
		dataList.addAll(questionList);
		return dataList;
	}

	@Override
	public QuestionType selectQuestionTypeById(Integer id) throws SQLException {
		return questionTypeDao.selectQuestionTypeById(id);
	}

}
