package com.yihu.hos.crawler.dao;

import com.yihu.hos.crawler.model.flow.CrawlerFlowHeadModel;
import com.yihu.hos.crawler.model.flow.CrawlerFlowModel;
import com.yihu.hos.web.framework.dao.SQLGeneralDAO;
import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by HZY on 2016/4/27.
 */
@Repository("CrawlerFlowHeadDao")
public class CrawlerFlowHeadDao extends SQLGeneralDAO {
    public static final String BEAN_ID = "CrawlerFlowHeadDao";

    public void deleteCrawlerFlowHeadList(Integer versionId) throws Exception {
        String sql = "delete from crawler_flow_head where scheme_version_id= :scheme_version_id";
        Query query = getCurrentSession().createSQLQuery(sql);
        query.setInteger("scheme_version_id", versionId);
        query.executeUpdate();
    }

    public List<CrawlerFlowHeadModel> getCrawlerFlowHeadList(Integer versionId) {
        String sql = "FROM CrawlerFlowHeadModel where schemeVersionId= :schemeVersionId";
        Query query = getCurrentSession().createQuery(sql);
        query.setParameter("schemeVersionId", versionId);
        List<CrawlerFlowHeadModel> modelList = query.list();
        return modelList;
    }

}
