package com.zhiwei.manage.service;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zhiwei.manage.bean.Data;
import com.zhiwei.manage.dao.DataDao;
import com.zhiwei.manage.dao.ServerDao;
import com.zhiwei.manage.util.ESUtil;

@Service
public class DataServiceImpl implements DataService {
	@Autowired
	private DataDao dataDao;
	@Autowired
	private ServerDao serverDao;
	@Autowired
	private CrawTemplateService crService;
	private ESUtil es = new ESUtil();

	@Override
	public void insert(Data data) {
		dataDao.insert(data);
	}

	@Override
	public List<Data> findByPt(Date startTime, Date endTime, String pt) {
		return dataDao.findByPt(startTime, endTime, pt);
	}

	@Override
	public List<Data> findBySource(Date startTime, Date endTime, String source) {
		return dataDao.findBySource(startTime, endTime, source);
	}

	@Override
	public List<Data> findBytempName(Date startTime, Date endTime, String tempName) {
		return dataDao.findBytempName(startTime, endTime, tempName);
	}

	// @Override
	// public List<EasyNews> findByAccurateSource(String startTime, String endTime,
	// String source) {
	// return dataDao.findByAccurateSource(startTime, endTime, source);
	// }
	//
	// @Override
	// public List<EasyNews> findByAccurateSpId(String startTime, String endTime,
	// String SpId) {
	// return dataDao.findByAccurateSpId(startTime, endTime, SpId);
	// }
	//
	// @Override
	// public int findBySourceFromLibrary(Date startTime, Date endTime, String
	// source) {
	// return dataDao.findBySourceFromLibrary(startTime, endTime, source);
	// }

	// @Override
	// public List<String> findSourceByLikeParam(String param) {
	// return dataDao.findSourceByLikeParam(param);
	// }

	@Override
	public List<String> findTmpNameByLikeParam(String param) {
		return dataDao.findTmpNameByLikeParam(param);
	}

	@Override
	public List<Data> findByPtDay(Date startTime, Date endTime, String pt) {
		return dataDao.findByPtDay(startTime, endTime, pt);
	}

	@Override
	public List<Data> findByMethodAndParam(Date startTime, Date endTime, String method, String param) {
		return es.findByMethodAndParam(crService, startTime, endTime, method, param, serverDao.findServerBean("网媒"));
	}

	// @Override
	// public int findByAccurateType(Date startTime, Date endTime, String type) {
	// return dataDao.findByAccurateType(startTime, endTime, type);
	// }
	//
	// @Override
	// public List<String> findTypeByLikeParam(String param) {
	// return dataDao.findTypeByLikeParam(param);
	// }
	//
	// @Override
	// public List<Data> findByMethod(Date startTime, Date endTime, String method,
	// Object value) {
	// return dataDao.findByMethod(startTime, endTime, method, value);
	// }
	//
	// @Override
	// public long finCountByDayData(Date startTime, Date endTime, Template temp) {
	// return dataDao.finCountByDayData(startTime, endTime, temp);
	// }
	//
	// @Override
	// public int findByTempName(Date startTime, Date endTime, String tempName) {
	// return dataDao.findBySpId(startTime, endTime, tempName);
	// }
	//
	// @Override
	// public long finCountByDayData(Date startDate, Date endDate, String pt) {
	// return dataDao.finCountByDayData(startDate, endDate, pt);
	// }

}
