package com.qmth.qrzk.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.qmth.qrzk.dao.IQuestionTypeDao;
import com.qmth.qrzk.repository.common.mapper.CourseQuestionTypeMapper;
import com.qmth.qrzk.repository.common.mapper.QuestionTypeMapper;
import com.qmth.qrzk.repository.service.query.QuestionTypeQueryParams;
import com.qmth.qrzk.repository.user.model.CourseQuestionType;
import com.qmth.qrzk.repository.user.model.QuestionType;

/**
 * 题型接口实现类
 * 
 * @author 钟辉
 * 
 */
@Repository("questionTypeDaoImpl")
@Transactional
public class QuestionTypeDaoImpl implements IQuestionTypeDao {

	// 注入questionTypeMapper提供查询数据库
	@Autowired
	@Qualifier("questionTypeMapper")
	private QuestionTypeMapper questionTypeMapper;

	// 注入courseQuestionTypeMapper
	@Autowired
	@Qualifier("courseQuestionTypeMapper")
	private CourseQuestionTypeMapper courseQuestionTypeMapper;

	/**
	 * 根据传入的对应id集合查询出所有的题型
	 */
	@Override
	public List<QuestionType> findQuestionName(List<Integer> list) {
		List<QuestionType> ls = questionTypeMapper.findAllByIds(list);
		return ls;
	}

	/**
	 * 根据课程id查询出所有相关联的题型
	 */
	@Override
	public List<CourseQuestionType> findCourseQuestionType(int courseId) {
		List<CourseQuestionType> list = courseQuestionTypeMapper
				.findQuestionTypeIds(courseId);
		return list;
	}

	@Override
	public List<QuestionType> queryQuestionTypes(QuestionTypeQueryParams params) {
		return questionTypeMapper.queryQuestionTypes(params);
	}

	@Override
	public int queryQuestionTypesCount(QuestionTypeQueryParams params) {
		return questionTypeMapper.queryQuestionTypesCount(params);
	}

	@Override
	public QuestionType selectById(int id) {
		// TODO Auto-generated method stub
		return questionTypeMapper.selectById(id);
	}

	@Override
	public List<QuestionType> queryByCourseId(int courseId) {
		return questionTypeMapper.queryByCourseId(courseId);
	}

	@Override
	public int deleteLink(int courseId) {
		return courseQuestionTypeMapper.deleteLink(courseId);
	}

	@Override
	public int addCourseQuestionType(List<CourseQuestionType> list) {
		// TODO Auto-generated method stub
		return questionTypeMapper.addCourseQuestionType(list);
	}

	@Override
	public int addQuestionType(QuestionType questionType) {
		// TODO Auto-generated method stub
		return questionTypeMapper.addQuestionType(questionType);
	}

	@Override
	public int updateQuestionType(QuestionType questionType) {
		// TODO Auto-generated method stub
		return questionTypeMapper.updateQuestionType(questionType);
	}

	@Override
	public List<QuestionType>  findByName(String name) {
		// TODO Auto-generated method stub
		return questionTypeMapper.findByName(name);
	}

	@Override
	public int getCount(CourseQuestionType cq) {
		// TODO Auto-generated method stub
		return courseQuestionTypeMapper.getCount(cq);
	}

	@Override
	public int addCourseLinkQuestionType(CourseQuestionType cq) {
		// TODO Auto-generated method stub
		return questionTypeMapper.addCourseLinkQuestionType(cq);
	}
}
