package com.iamberry.wechat.service.questionnaire;

import java.util.List;

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

import com.iamberry.wechat.core.entity.questionnaire.QuestionnaireAnswer;
import com.iamberry.wechat.face.questionnaire.QuestionnaireAnswerService;
import com.iamberry.wechat.service.mapper.QuestionnaireAnswerMapper;

@Service
public class QuestionnaireAnswerServiceImpl implements QuestionnaireAnswerService{
	@Autowired
	private QuestionnaireAnswerMapper questionnaireAnswerMapper;

	@Override
	public List<QuestionnaireAnswer> getAllAnswer(
			QuestionnaireAnswer questionnaireAnswer) {
		// TODO Auto-generated method stub
		return questionnaireAnswerMapper.getAllAnswer(questionnaireAnswer);
	}

	@Override
	public Integer getAllAnswerCount(QuestionnaireAnswer questionnaireAnswer) {
		// TODO Auto-generated method stub
		int count = questionnaireAnswerMapper.getAllAnswerCount(questionnaireAnswer);
		return count = count % questionnaireAnswer.getPage().getPageSize() == 0? count/questionnaireAnswer.getPage().getPageSize():(count/questionnaireAnswer.getPage().getPageSize())+1;
	}
}
