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

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

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.dubbo.config.annotation.Service;
import com.ssj.bean.weixin.problem.domain.Problem;
import com.ssj.dao.weixin.problem.dao.ProblemDao;
import com.ssj.dao.weixin.problem.dao.ProblemQueryDao;
import com.ssj.framework.core.common.service.BaseServiceImpl;
import com.ssj.framework.core.persistence.DynamicSpecifications;
import com.ssj.framework.core.persistence.SearchFilter;
import com.ssj.service.weixin.problem.service.ProblemService;


@Service(version="1.0")
@Transactional
public class ProblemServiceImpl extends BaseServiceImpl<Problem, String> implements ProblemService{
	@Autowired
	private ProblemDao  problemDao;
	@Autowired
	private ProblemQueryDao  problemQueryDao;
	@Override
	public PagingAndSortingRepository<Problem, String> getDao() {
		return  problemDao;
	}
	@Override
	public Page<Map<String, Object>> findForPage(
			Map<String, Object> searchParams, Pageable pageable) {
		return problemQueryDao.findForPage(searchParams, pageable);
	}
	@Override
	public void updatenum(String id, Integer num) {
		problemDao.updatenum(id, num);
	}
	@Override
	public Integer countType() {
		return (int) problemDao.count();
	}
	@Override
	public Page<Map<String, Object>> findVipPage(
			Map<String, Object> searchParams, Pageable pageable) {
		return problemQueryDao.findVipPage(searchParams, pageable);
	}
	@Override
	public Page<Map<String, Object>> findUpdateVipPage(
			Map<String, Object> searchParams, Pageable pageable) {
		return problemQueryDao.findUpdateVipPage(searchParams, pageable);
	}
	@Override
	public void updateZybStudentBg(String id, String ids) {
		problemDao.updateZybStudentBg(id, ids);
		
	}
	@Override
	public void updateZybStudentPush(String id, String ids) {
		problemDao.updateZybStudentPush(id, ids);
		
	}
	@Override
	public void updateZybStudentWork(String id, String ids) {
		problemDao.updateZybStudentWork(id, ids);
		
	}
	@Override
	public void updateLibUserHistory(String id, String ids) {
		problemDao.updateLibUserHistory(id, ids);
		
	}
	@Override
	public void updateOrderDetails(String id, String ids) {
		problemDao.updateLibOrderDetails(id, ids);
		
	}
	@Override
	public void updateLibBookDetails(String id, String ids) {
		problemDao.updateLibBookDetails(id, ids);
		
	}
	@Override
	public void updateLibVipService(String id, String ids) {
		problemDao.updateLibVipService(id, ids);
		
	}
	@Override
	public void updateLibOrderDetails(String id, String ids) {
		problemDao.updateLibOrderDetails(id, ids);
		
	}
	@Override
	public void updateLibVip(String id, String ids) {
		problemDao.updateLibVip(id, ids);
		
	}
	@Override
	public void updateLibSubscribe(String id, String ids) {
		problemDao.updateLibSubscribe(id, ids);
		
	}

	@Override
	public Page<Map<String, Object>> findBanbenDetailPage(Map<String, Object> params, Pageable initPage) {
		return problemQueryDao.findBanbenDetailPage(params,initPage);
	}

	@Override
	public List<Problem> findByProblem(int type, int stat) {
		return problemDao.findByProblem(type, stat);
	}
	@Override
	public Page<Problem> findByPage(Map<String, Object> params, Pageable sp) {
		Map<String, SearchFilter> filters = SearchFilter.parse(params);
		Specification<Problem> specification = DynamicSpecifications.bySearchFilter(filters.values(), Problem.class);    
		return  problemDao.findAll(specification, sp);
	}
	
	

	

}
