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.TViewComplianceDirectory;
import org.springframework.stereotype.Repository;

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

   public int createViewComplianceDirectory() {
      String sql = "insert into t_view_compliance_directory  (id,description, datasystem_name, tschemas,names,columnid,fields) select UUID() id,z.directory_name directory_name,d.sysname datasystem_name,t.tschemas tschemas,t.names names,t.id columnid,t.fields fields from t_core_compliance_directory z,t_core_field_directory f,t_core_table_field t,t_core_datasystem d where f.directory_id = z.id and t.id = f.tablefield_id and d.id = t.datasystem_id";
      return this.getSession().createNativeQuery(sql).executeUpdate();
   }
}
