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


import java.util.List;

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

import com.qmth.qrzk.dao.ICodeBookDao;
import com.qmth.qrzk.repository.user.model.CodeBook;
import com.qmth.qrzk.repository.user.service.ICodeBookService;

@Service("codeBookServiceImpl")
public class CodeBookServiceImpl implements ICodeBookService{

	@Autowired
	@Qualifier("codeBookImpl")
	private ICodeBookDao codeBookDao;

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

	@Override
	public void insertCodeBook(List<CodeBook> list) {
		// TODO Auto-generated method stub
		codeBookDao.insertCodeBook(list);
	}

	@Override
	public void deleteCodeBook(CodeBook cb) {
		// TODO Auto-generated method stub
		codeBookDao.deleteCodeBook(cb);
	}

	@Override
	public List<CodeBook> getAllCodeBook() {
		// TODO Auto-generated method stub
		return codeBookDao.getAllCodeBook();
	}

	@Override
	public String findByRandomCode(String randomCode) {
		// TODO Auto-generated method stub
		List<CodeBook> list=codeBookDao.findByRandomCode(randomCode);
		if(list.size()>0){
			return list.get(0).getPassword();
		}
		return null;
	}

	@Override
	public int validatePassword(CodeBook cb) {
		// TODO Auto-generated method stub
		return codeBookDao.validatePassword(cb);
	}
}
