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

import com.chenyang.nse.bussiness.config.HibernateConfig;
import com.chenyang.nse.bussiness.dao.BaseDao;
import com.chenyang.nse.bussiness.entity.orm.table.core.encryption.TCoreEncryptionTypeField;
import com.chenyang.nse.bussiness.entity.orm.table.core.encryption.TCoreKafkaTopicSecret;
import java.util.List;
import org.hibernate.transform.Transformers;
import org.springframework.stereotype.Repository;

@Repository
public class TCoreKafkaTopicSecretDao extends BaseDao<TCoreKafkaTopicSecret, String> {
   public List<TCoreEncryptionTypeField> queryFields(String projectId) {
      String sql = "SELECT id as id,encryption_secretkey_id,flag,state FROM t_core_encryption_field WHERE projectid = '" + projectId + "' and (state = '1' or state is null)";
      if (HibernateConfig.PEIZHIKUDBTYPE.equals("3")) {
         sql = "SELECT id as \"id\",encryption_secretkey_id as \"encryption_secretkey_id\",flag as \"flag\",state as \"state\" FROM t_core_encryption_field WHERE projectid = '" + projectId + "' and (state = '1' or state is null)";
      }

      return this.getSession().createNativeQuery(sql).setResultTransformer(Transformers.aliasToBean(TCoreEncryptionTypeField.class)).getResultList();
   }
}
