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

import com.chenyang.nse.bussiness.config.HibernateConfig;
import com.chenyang.nse.bussiness.dao.BaseDao;
import com.chenyang.nse.bussiness.entity.orm.table.console.TConsoleDictionarytype;
import java.util.List;
import org.springframework.stereotype.Repository;

@Repository
public class TConsoleDictionarytypeDao extends BaseDao<TConsoleDictionarytype, String> {
   public List<TConsoleDictionarytype> queryAllDictionaryType() {
      String type = "SIGNED";
      if (HibernateConfig.PEIZHIKUDBTYPE.equals("1") || HibernateConfig.PEIZHIKUDBTYPE.equals("2")) {
         type = "INT";
      }

      String sql = "select * from t_console_dictionarytype order by CAST(typecode as " + type + ") ";
      return this.getSession().createNativeQuery(sql, TConsoleDictionarytype.class).getResultList();
   }

   public void savetCoreDicField(StringBuilder sql) {
      System.out.println(sql.toString());
      this.getSession().createNativeQuery(sql.toString()).executeUpdate();
   }

   public void removebytype(String typecode) {
      String sql = "delete t1,t2 from t_console_dictionarytype t1 left join t_console_dictionary t2 on  t1.typecode = t2.typecode where t1.typecode = '" + typecode + "'";
      this.getSession().createNativeQuery(sql).executeUpdate();
   }
}
