package com.zhiwei.manage.dao;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;

import com.zhiwei.manage.bean.CrawTemplate;

/**
 * 采集模板实现部分
 * 
 * @author admin
 *
 */
@Component
public class CrawTemplateDaoImpl implements CrawTemplateDao {

	@Resource(name = "newmongoTemplate")
	private MongoTemplate mongo;

	@Override
	public List<CrawTemplate> findAll() {
		return mongo.find(Query.query(Criteria.where("websitetype").is("main")), CrawTemplate.class);
	}

	@Override
	public String getSpIdByConfigName(String tempName) {
		return mongo.findOne(Query.query(Criteria.where("configName").is(tempName)), CrawTemplate.class).getId();
	}

	@Override
	public CrawTemplate getPt(String spyId) {
		return mongo.findOne(Query.query(Criteria.where("_id").is(spyId)), CrawTemplate.class);
	}

}
