package com.ssj.service.weixin.grword.service.impl;

import com.ssj.bean.weixin.grword.domain.TbReadAnswer;
import com.ssj.bean.weixin.grword.domain.TbReadScore;
import com.ssj.bean.weixin.grword.domain.TbReadSubject;
import com.ssj.dao.weixin.grword.dao.ReadAnswerDao;
import com.ssj.dao.weixin.grword.dao.ReadQueryDao;
import com.ssj.dao.weixin.grword.dao.ReadScoreDao;
import com.ssj.dao.weixin.grword.dao.ReadSubjectDao;
import com.ssj.framework.core.common.service.BaseServiceImpl;
import com.ssj.service.weixin.grword.service.ReadQueryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
@Transactional
public class ReadQueryServiceImpl extends BaseServiceImpl<TbReadSubject, String> implements ReadQueryService{

	@Autowired
	private ReadSubjectDao readSubjectDao;
	
	@Autowired
	private ReadQueryDao readQueryDao;
	
	@Autowired
	private ReadAnswerDao readAnswerDao;
	
	@Autowired
	private ReadScoreDao readScoreDao;
	

	@Override
	public PagingAndSortingRepository<TbReadSubject, String> getDao() {
		return readSubjectDao;
	}

	@Override
	public Map<String, Object> findSubjectByIsbn13(String isbn13) {
		return readQueryDao.findSubjectByIsbn13(isbn13);
	}

	@Override
	public Map<String, Object> findAnswerByUserId(String userId, String isbn13,String scoreId) {
		return readQueryDao.findAnswerByUserId(userId, isbn13,scoreId);
	}

	@Override
	public Map<String, Object> findSubjectByIsbn13AndSort(String isbn13,Integer sort) {
		return readQueryDao.findSubjectByIsbn13AndSort(isbn13, sort);
	}

	@Override
	public void saveReadScore(TbReadScore readScore) {
		readScoreDao.save(readScore);
	}

	

	@Override
	public void saveReadAnswer(TbReadAnswer readAnswer) {
		readAnswerDao.save(readAnswer);
	}

	@Override
	public TbReadScore findScoreByState(String userId, String isbn13,String state) {
		return readScoreDao.findScoreByState(userId,isbn13,state);
	}

	@Override
	public TbReadScore findScoreById(String scoreId) {
		return readScoreDao.findScoreById(scoreId);
	}

	@Override
	public List<TbReadAnswer> findReadAnswerByScoreId(String scoreId) {
		return readAnswerDao.findReadAnswerByScoreId(scoreId);
	}

	@Override
	public TbReadScore findNewScoreByisbn13(String userId,String isbn13) {
		return readScoreDao.findNewScoreByisbn13(userId,isbn13);
	}

	@Override
	public TbReadSubject findSubjectById(String subjectId) {
		return readSubjectDao.findSubjectById(subjectId);
	}

	@Override
	public List<Map<String, Object>> findBookByUserIdAndLevel(String userId,Integer level,Integer userGr,Integer size) {
		return readQueryDao.findBookByUserIdAndLevel(userId,level,userGr,size);
	}

	@Override
	public List<Map<String, Object>> findBookByUserIdAndLevelSuccess(String userId) {
		return readQueryDao.findBookByUserIdAndLevelSuccess(userId);
	}

	@Override
	public void saveReadSubject(TbReadSubject readSubject) {
		readSubjectDao.save(readSubject);
	}

	@Override
	public List<Map<String, Object>> findSubjectByIsbn13Page(String isbn13) {
		return readQueryDao.findSubjectByIsbn13Page(isbn13);
	}

	@Override
	public List<Map<String, Object>> findAnswerByUserIdPage(String userId,String isbn13, String scoreId) {
		return readQueryDao.findSubjectByIsbn13Page(isbn13);
	}

	@Override
	public void updateReadAnswerAdopt(String userId, String isbn13) {
		 readScoreDao.updateReadAnswerAdopt(userId, isbn13);
	}

	
	
	
	
}
