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

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

@Repository
public class TCoreConfigDao extends BaseDao<TCoreConfig, String> {
   public List<Map<String, Object>> queryById(String id) {
      String sql = "select datasystemid from t_core_config where datasystemid='" + id + "'";
      return this.getSession().createNativeQuery(sql).setResultTransformer(Transformers.aliasToBean(TCoreConfig.class)).getResultList();
   }

   public List<String> queryBydbtype(String dbtype) {
      String sql = "select id from t_core_config where dbtype='" + dbtype + "'";
      return this.getSession().createNativeQuery(sql).getResultList();
   }

   public List<String> queryBysystemid(String id) {
      String sql = "select id from t_core_config where datasystemid='" + id + "'";
      return this.getSession().createNativeQuery(sql).getResultList();
   }

   public int removeBysysid(String id) {
      String sql = "delete from t_core_config where datasystemid='" + id + "'";
      return this.getSession().createNativeQuery(sql).executeUpdate();
   }

   public void updateConfig(String datasystemid, String dbtype, String sourcedelimiter, String sourcequoteCharacter, String targetdelimiter, String targetquoteCharacter, String fileDir, String suffix, String configid) {
      String sql = "update t_core_config set datasystemid='" + datasystemid + "',dbtype='" + dbtype + "',sourcedelimiter='" + sourcedelimiter + "',sourcequoteCharacter='" + sourcequoteCharacter + "',targetdelimiter='" + targetdelimiter + "',targetquoteCharacter='" + targetquoteCharacter + "',fileDir='" + fileDir + "',suffix='" + suffix + "' where id ='" + configid + "'";
      this.getSession().createNativeQuery(sql).executeUpdate();
   }
}
