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

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

@Repository
public class TCoreMaskingRuleinfoDao extends BaseDao<TCoreMaskingRuleinfo, String> {
   public int queryRuleCount(String dataareaId) {
      String sql = XmlTool.getSql("dataarea", "queryRuleCount");
      int count = Integer.parseInt(this.getSession().createNativeQuery(sql).setParameter("dataareaId", dataareaId).uniqueResult().toString());
      return count;
   }

   public String updatedef(String id) {
      String r = "f";
      String sql1 = "select defaulttype  from  t_core_masking_ruleinfo where  dataarea_id ='" + id + "'";
      List<Map<String, Object>> vo = this.getSession().createNativeQuery(sql1).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).getResultList();
      if (!vo.isEmpty()) {
         r = "s";
      }

      return r;
   }
}
