package cn.hmsoft.ltc.service.impl;

import java.sql.SQLException;
import java.util.List;
import org.springframework.stereotype.Component;
import cn.hmsoft.ltc.common.constants.LtContext;
import cn.hmsoft.ltc.dao.TestPaperDao;
import cn.hmsoft.ltc.model.TestPaper;
import cn.hmsoft.ltc.service.iface.TestPaperService;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;

/**
 * 课程管理接口实现类
 * @author Administrator
 *
 */
@Component
public class TestPaperServiceImpl implements TestPaperService { 
	
	private TestPaperDao testPaperDao = new TestPaperDao();

	@Override
	public void insertTestPaper(TestPaper testPaper) throws SQLException {
		this.testPaperDao.insertTestPaper(testPaper);
	}

	@Override
	public ObservableList<TestPaper> selectTestPaper() throws SQLException {
		final ObservableList<TestPaper> dataList = FXCollections.observableArrayList();
		List<TestPaper> testPaperList = this.testPaperDao.selectTestPaperByUserId(LtContext.LOGIN_USER_ID);
		dataList.addAll(testPaperList);
		return dataList;
	}

	@Override
	public ObservableList<TestPaper> selectTestPaperComBobox() throws SQLException {
		final ObservableList<TestPaper> dataList = FXCollections.observableArrayList();
		List<TestPaper> testPaperList = this.testPaperDao.selectTestPaperByUserId(LtContext.LOGIN_USER_ID);
		dataList.addAll(testPaperList);
		return dataList;
	}


	@Override
	public TestPaper selectTestPaperByPageNo(String pageNo) throws SQLException {
		return this.testPaperDao.selectTestPaperByPageNo(pageNo);
	}

	/**
	 * 根据课程ID删除
	 * @param courseId
	 */
	@Override
	public void deleteTestPaper(Integer courseId) {
		this.testPaperDao.deleteTestPaper(courseId);
	}

	@Override
	public void updateTestPaper(String paperNo, Integer status) {
		this.testPaperDao.updateTestPaper(paperNo, status);
		
	}
	
	@Override
	public void updateTestPaperKeyChapter(String paperNo, String keyChapter) {
		this.testPaperDao.updateTestPaperKeyChapter(paperNo, keyChapter);
		
	}

	@Override
	public void updateTestPaperChapterNumber(Integer chapterNumber, Integer courseId) {
		this.testPaperDao.updateTestPaperChapterNumber(chapterNumber, courseId);
	}
}
