package util.sqlparse.visitor.postgresql;

import java.util.HashMap;
import java.util.Map;
import util.JdbcUtil;
import util.SqlUtil;

public class DesensitizationTest {
   public static void main(String[] args) throws Exception {
      oracleParseTest("select * from (select user_name,user_name from person) y");
   }

   static Map<String, Object> oracleParseTest(String sql) throws Exception {
      String content = "{\n      \"ip_port\": \"192.168.2.173:5432\",\n      \"url\": \"jdbc:postgresql://192.168.2.173:5432/postgres\",\n      \"username\": \"postgres\",\n      \"password\": \"postgres\",\n      \"dbType\": \"postgresql\",\n      \"isIgnorecase\": \"1\",\n      \"redisMode\": \"read\",\n      \"redisIp\": \"192.168.2.105\",\n      \"redisNodes\": \"192.168.2.81:6379,192.168.2.81:6380,192.168.2.82:6379,192.168.2.82:6380,192.168.2.83:6379,192.168.2.83:6380\",\n      \"redisPort\": \"6379\",\n      \"redisUsername\": \"\",\n      \"redisPassword\": \"123456\",\n      \"redisDatabase\": \"0\",\n      \"excludeSchema\": []\n    }";
      JdbcUtil.initData(content);

      try {
         Thread.sleep(2000L);
      } catch (InterruptedException e) {
         e.printStackTrace();
      }

      Map<String, String> params = new HashMap();
      params.put("sql", sql);
      params.put("dbType", "postgresql");
      params.put("schema", "public");
      params.put("url", "jdbc:postgresql://192.168.2.173:5432/postgres");
      Map<String, Object> stringObjectMap = null;
      SqlUtil sqlUtil = new SqlUtil();
      long startTime = System.currentTimeMillis();
      stringObjectMap = sqlUtil.parseSqlStructureAnd(params);
      System.out.println(stringObjectMap);
      long endTime = System.currentTimeMillis();
      System.out.println("共用时：" + (endTime - startTime) + "毫秒");
      return stringObjectMap;
   }
}
