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

import com.ssj.bean.sys.shortcuts.domain.Shortcuts;
import com.ssj.dao.sys.shortcuts.dao.ShortcutsDao;
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.shortcuts.service.ShortcutsService;
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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;
/**
 * @author Mount Liu
 * @date 2018/8/16
 */
@Service
@Transactional
public class ShortcutsServiceImpl extends BaseServiceImpl<Shortcuts, String> implements ShortcutsService {

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

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

	@Override
	public Integer updateOrder(String id,int order) {
		return dao.updateShortcutsOrder(id, order);
	}
}
