package com.ssj.service.weixin.story.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.story.bean.StoryImg;
import com.ssj.dao.weixin.story.dao.StoryImgDao;
import com.ssj.dao.weixin.story.dao.StoryQueryDao;
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.story.service.StoryImgService;


/** 
 * @author  ZhangCaibao 
 * @version 2017年6月12日 下午2:53:01 
 * 类说明 
 */
@Service(version="1.0")
@Transactional
public class StoryImgServiceImpl extends BaseServiceImpl<StoryImg, String> implements StoryImgService{

	@Autowired
	private StoryImgDao storyImgDao;
	
	@Autowired
	private StoryQueryDao queryDao;
	
	@Override
	public PagingAndSortingRepository<StoryImg, String> getDao() {
		return storyImgDao;
	}
	@Override
	public List<String> getImgList(String objectId) {
		return storyImgDao.getImgList(objectId);
	}
	@Override
	public Integer countObjectId(String objectId) {
		return storyImgDao.countObjectId(objectId);
	}
	@Override
	public Page<StoryImg> findByPage(Map<String, Object> params, Pageable sp) {
		Map<String, SearchFilter> filters = SearchFilter.parse(params);
		Specification<StoryImg> specification = DynamicSpecifications.bySearchFilter(filters.values(), StoryImg.class);    
		return  storyImgDao.findAll(specification, sp);
	}
	@Override
	public void updateNum(String id, Integer num) {
		storyImgDao.updateNum(id, num);
	}
	@Override
	public StoryImg findImgByAnything(String fileCode, String isbn13, String picIndex) {
		
		return storyImgDao.findImgByAnything(fileCode);
	}
	@Override
	public StoryImg findImgByIsbn13(String isbn13, String picIndex) {
		
		return storyImgDao.findImgByIsbn13(isbn13,Integer.parseInt(picIndex));
	}
	@Override
	public Map<String, Object> findGrImg(String isbn13) {
		
		return queryDao.findGrImg(isbn13);
	}
	@Override
	public void updateBase(String isbn13, String fileGr) {
		
		storyImgDao.updateBase(isbn13,fileGr);
	}
	@Override
	public void updateInfo(String isbn13, String fileGr) {
		storyImgDao.updateInfo(isbn13,fileGr);
		
	}
	@Override
	public void updateImgStat(String isbn13) {
		
		storyImgDao.updateImgStat(isbn13);
	}
	
	@Override
	public List<Map<String, Object>> randBookByGrLists(String filegr) {
		return queryDao.randBookByGrLists(filegr);
	}
	
	public List<Map<String, Object>> randBookByKeywordLists(String keywordFeel){
		return queryDao.randBookByKeywordLists(keywordFeel);
	}

}
