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

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 com.alibaba.dubbo.config.annotation.Service;
import com.ssj.bean.weixin.message.domain.MessageReply;
import com.ssj.dao.weixin.message.dao.MessageReplyDao;
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.message.service.MessageReplyService;

import java.util.Map;

@Service(version="1.0")
public class MessageReplyServiceImpl extends BaseServiceImpl<MessageReply, String> implements MessageReplyService {

	@Autowired
	private MessageReplyDao dao;
	
	@Override
	public PagingAndSortingRepository<MessageReply, String> getDao() {
		return dao;
	}

	public MessageReply findByKeyword(String keyword) {
		return dao.findByKeyword(keyword);
	}

	public MessageReply findById(String id) {
		return dao.findById(id);
	}

	@Override
	public Page<MessageReply> findByPage(Map<String, Object> params, Pageable sp) {
		Map<String, SearchFilter> filters = SearchFilter.parse(params);
		Specification<MessageReply> specification = DynamicSpecifications.bySearchFilter(filters.values(), MessageReply.class);
		return  dao.findAll(specification,sp);
	}
}
