| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- import java.io.*;
- import java.sql.*;
- public class VerifyMenuSyncFinal {
- public static void main(String[] a) throws Exception {
- Class.forName("com.mysql.cj.jdbc.Driver");
- new File("output").mkdirs();
- try (PrintWriter out = new PrintWriter(new OutputStreamWriter(
- new FileOutputStream("output/verify-menu-sync-final.txt"), "UTF-8"))) {
- dump(open("fs_tenant_cs1"), out, "TENANT sys_menu");
- dump(open("fs_tenant_cs1"), out, "TENANT company_menu");
- dump(open("ylrz_saas"), out, "MASTER tenant_sys_menu");
- dump(open("ylrz_saas"), out, "MASTER tenant_company_menu");
- }
- System.out.println("ok");
- }
- static void dump(Connection c, PrintWriter out, String label) throws Exception {
- String table = label.contains("company") ? "company_menu" : "sys_menu";
- if (label.startsWith("MASTER tenant_sys")) table = "tenant_sys_menu";
- if (label.startsWith("MASTER tenant_company")) table = "tenant_company_menu";
- out.println("\n=== " + label + " ===");
- try (Statement st = c.createStatement();
- ResultSet rs = st.executeQuery(
- "SELECT menu_id, menu_name, parent_id, order_num, menu_type, visible, HEX(menu_name) hx "
- + "FROM " + table + " WHERE menu_id=29900 OR parent_id=29900 ORDER BY parent_id, order_num, menu_id")) {
- int n = 0;
- while (rs.next()) {
- n++;
- out.printf("[%d] %s | parent=%d order=%d type=%s visible=%s hx=%s%n",
- rs.getLong(1), rs.getString(2), rs.getLong(3), rs.getInt(4),
- rs.getString(5), rs.getString(6), rs.getString(7));
- }
- out.println("count=" + n);
- }
- try (Statement st = c.createStatement();
- ResultSet rs = st.executeQuery(
- "SELECT COUNT(*) FROM " + table + " WHERE parent_id=29900 AND menu_type='C' AND visible='0'")) {
- rs.next();
- out.println("visible_leaf_count=" + rs.getInt(1));
- }
- }
- static Connection open(String db) throws SQLException {
- return DriverManager.getConnection(
- "jdbc:mysql://cq-cdb-8fjmemkb.sql.tencentcdb.com:27220/" + db
- + "?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8",
- "root", "Ylrz_1q2w3e4r5t6y");
- }
- }
|