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

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

   public int createViewDataScope() {
      String sql = "insert into t_view_data_scope (id,description, datasystem_name, tschemas,names,columnid,fields) select UUID() id, z.scope_name scope_name,d.sysname datasystem_name,t.tschemas tschemas,t.names names,t.id columnid,t.fields fields from t_core_data_scope z,t_core_scope_field f,t_core_table_field t,t_core_datasystem d where f.scope_id = z.scope_id and t.id = f.tablefield_id and d.id = t.datasystem_id";
      return this.getSession().createNativeQuery(sql).executeUpdate();
   }
}
