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

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

@Repository
public class TCoreRowSensitiveLevelDao extends BaseDao<TCoreRowSensitiveLevel, String> {
   public List<Map<String, Object>> querySensitiveLevel(String key_name, String key_id, String table_name, String schem, String datasystem_id) {
      String sql = "SELECT sensitive_id FROM t_core_row_sensitive_level WHERE key_name ='" + key_name + "' AND key_id = '" + key_id + "' AND table_name = '" + table_name + "' AND schem = '" + schem + "' AND datasystem_id = '" + datasystem_id + "'";
      List<Map<String, Object>> list = this.getSession().createNativeQuery(sql).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).getResultList();
      return list;
   }

   public List<Map<String, Object>> queryRowSensitiveLevel(String key_id, String key_name, String table_name, String schem, String datasystem_id) {
      String sql = "SELECT id FROM t_core_row_sensitive_level WHERE key_id = :key_id and key_name = :key_name and table_name = :table_name and schem = :schem and datasystem_id = :datasystem_id";
      return this.getSession().createNativeQuery(sql).setParameter("key_id", key_id).setParameter("table_name", table_name).setParameter("key_name", key_name).setParameter("schem", schem).setParameter("datasystem_id", datasystem_id).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).getResultList();
   }
}
