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.bean.EasyNews;
import com.zhiwei.manage.bean.Template;
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<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("网媒"));
	}

}
