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

import com.ssj.bean.sys.photoscroll.bean.Photoscroll;
import com.ssj.dao.sys.photoscroll.dao.PhotoscrollDao;
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.photoscroll.service.PhotoscrollService;
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.List;
import java.util.Map;

@Service
@Transactional
public class PhotoscrollServiceImpl extends BaseServiceImpl<Photoscroll, String> implements PhotoscrollService {

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

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

	@Override
	public List<Photoscroll> getPhototList(String phoneType){
		return dao.getPhotoList(phoneType);
	}
	@Override
	public Integer updatePhotoOrder(String id, int photoOrder) {
		return dao.updatePhotoOrder(id, photoOrder);
	}
}
