package com.qmth.qrzk.repository.user.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.qmth.qrzk.repository.common.base.BaseDao;
import com.qmth.qrzk.repository.service.query.QueryParams;
import com.qmth.qrzk.repository.user.model.Book;

@Service
public class BookServiceImpl{

	@Autowired
	private BaseDao dao;
	
//	/**
//	 * 根据课程id 查询b_course_book表 得到book_id集合
//	 */
//	public List<Integer> findBookIds(int course_id) {
//		List<Integer> ls=new ArrayList<Integer>();
//		List<CourseBook> list = dao.getList("findCourseBooksByCourseId", course_id);// bookDao.findBookIdByCourseId(course_id);
//		for(CourseBook cb:list){
//			ls.add(cb.getBookId());
//		}
//		return ls;
//	}
//	public List<Book> findBooksByCourseId(List<Integer> list) {
//		return dao.getList("findBookName", list);
//	}
	public List<Book> queryBooks(QueryParams params) {
		return dao.getPagerList("queryBooks", params);
	}
	public List<Book> getAllBooks() {
		return dao.getList("queryBooks");
	}
	public Book queryById(int id) {
		return dao.getObject("getBookById", id);
	}
	
	public Book get(String bookName){
		return dao.get("getBookIdByName", bookName);
	}
	
	public void updateBook(Book book){
		dao.update("updateBook", book);
	}
	
	public void addBook(Book book){
		dao.update("addBook", book);
	}
	public void delBook(int id){
		dao.delete("delBookById", id);
	}
	
	public List<Book> findBooks(String courseCode){
		return dao.getList("findBooks", courseCode);
	}
	
	public List<Book> findBooksInCourse(int courseId){
		return dao.getList("selectBooksInCourse", courseId);
	}
}
