package com.chenyang.nse.bussiness.dao.table.core.duty;

import com.chenyang.nse.bussiness.dao.BaseDao;
import com.chenyang.nse.bussiness.entity.orm.table.core.duty.DutyTableInfo;
import java.util.List;
import org.hibernate.transform.Transformers;
import org.springframework.stereotype.Repository;

@Repository
public class DutyTableInfoDao extends BaseDao<DutyTableInfo, String> {
   public List<DutyTableInfo> querySchemaList(String projectid, String datasystemid) {
      String sql = "SELECT  Max(id) as id,projectid,datasystemid,schemaname FROM t_console_dutytableinfo WHERE projectid = '" + projectid + "' and datasystemid = '" + datasystemid + "' GROUP BY schemaname";
      return this.getSession().createNativeQuery(sql).setResultTransformer(Transformers.aliasToBean(DutyTableInfo.class)).getResultList();
   }

   public List<DutyTableInfo> queryTableList(String projectid, String datasystemid, String schemaname) {
      String sql = "SELECT id as id,projectid,datasystemid,tablename FROM t_console_dutytableinfo WHERE projectid = '" + projectid + "' and datasystemid = '" + datasystemid + "' and schemaname='" + schemaname + "'";
      return this.getSession().createNativeQuery(sql).setResultTransformer(Transformers.aliasToBean(DutyTableInfo.class)).getResultList();
   }
}
