CrawlerFlowDao.java 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package com.yihu.hos.rest.common.dao;
  2. import com.yihu.hos.rest.models.crawler.flow.CrawlerFlowModel;
  3. import com.yihu.hos.web.framework.dao.SQLGeneralDAO;
  4. import org.hibernate.Query;
  5. import org.springframework.stereotype.Repository;
  6. import java.util.List;
  7. /**
  8. * Created by HZY on 2016/4/27.
  9. */
  10. @Repository("CrawlerFlowDao")
  11. public class CrawlerFlowDao extends SQLGeneralDAO {
  12. public static final String BEAN_ID = "CrawlerFlowDao";
  13. public List<CrawlerFlowModel> getCrawlerFlowList(Long versionId) {
  14. String adapterVersionHql = "FROM CrawlerFlowModel where schemeVersionId= :schemeVersionId";
  15. Query query = getCurrentSession().createQuery(adapterVersionHql);
  16. query.setParameter("schemeVersionId", versionId);
  17. List<CrawlerFlowModel> modelList = query.list();
  18. return modelList;
  19. }
  20. public void deleteCrawlerFlowList(Long versionId)throws Exception {
  21. String sql = "delete from crawler_flow where scheme_version_id='"+versionId+"'";
  22. super.execute(sql);
  23. }
  24. public List<CrawlerFlowModel> getCrawlerFlowList(Integer versionId,List<String> datasetCodes) {
  25. String adapterVersionHql = "FROM CrawlerFlowModel where schemeVersionId= :schemeVersionId and datasetCode in (:datasetCode) and inputDatasetCode in (:inputDatasetCode)";
  26. Query query = getCurrentSession().createQuery(adapterVersionHql);
  27. query.setParameter("schemeVersionId", versionId);
  28. query.setParameterList("datasetCode", datasetCodes);
  29. query.setParameterList("inputDatasetCode", datasetCodes);
  30. List<CrawlerFlowModel> modelList = query.list();
  31. return modelList;
  32. }
  33. }