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

import com.chenyang.nse.bussiness.dao.BaseDao;
import com.chenyang.nse.bussiness.entity.orm.table.core.fieldscope.view.TViewSensitiveLevel;
import org.springframework.stereotype.Repository;

@Repository
public class TViewSensitiveLevelDao extends BaseDao<TViewSensitiveLevel, String> {
   public int clearTable() {
      String sql = "truncate table t_view_sensitive_level ";
      return this.getSession().createNativeQuery(sql).executeUpdate();
   }

   public int createViewSensitiveLevel() {
      String sql = "insert into t_view_sensitive_level (id,description, datasystem_name, tschemas,names,columnid,fields) select UUID() id,z.sensitive_name sensitive_name,d.sysname datasystem_name,t.tschemas tschemas,t.names names,t.id columnid,t.fields fields from t_core_sensitive_level z,t_core_field_sensitive f,t_core_table_field t,t_core_datasystem d where f.sensitive_id = z.id and t.id = f.tablefield_id and d.id = t.datasystem_id";
      return this.getSession().createNativeQuery(sql).executeUpdate();
   }
}
