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

import com.alibaba.dubbo.config.annotation.Service;
import com.ssj.bean.sys.message.domain.Message;
import com.ssj.dao.sys.message.dao.MessageDao;
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.sys.message.service.MessageService;
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 java.util.Map;

@Service(version = "1.0")
public class MessageServiceImpl extends BaseServiceImpl<Message, String> implements MessageService {

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

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