QueryAdminMenus5.java 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import java.sql.*;
  2. public class QueryAdminMenus5 {
  3. public static void main(String[] args) throws Exception {
  4. String url = "jdbc:mysql://cq-cdb-8fjmemkb.sql.tencentcdb.com:27220/ylrz_saas?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8";
  5. try (Connection c = DriverManager.getConnection(url, "root", "Ylrz_1q2w3e4r5t6y");
  6. Statement st = c.createStatement()) {
  7. System.out.println("=== menu_name contains shengji (upgrade) ===");
  8. try (ResultSet rs = st.executeQuery(
  9. "SELECT menu_id, menu_name, parent_id, path, component, icon, visible, menu_type "
  10. + "FROM sys_menu WHERE menu_name LIKE '%"
  11. + "\u5347\u7ea7" + "%' ORDER BY menu_id")) {
  12. while (rs.next()) {
  13. System.out.printf("%s | %s | parent=%s | path=%s | comp=%s | icon=%s | type=%s%n",
  14. rs.getString(1), rs.getString(2), rs.getString(3),
  15. rs.getString(4), rs.getString(5), rs.getString(6), rs.getString(8));
  16. }
  17. }
  18. System.out.println("\n=== verify components exist ===");
  19. String[][] rows = {
  20. {"32850", "saas/tenant/upgrade/index"},
  21. {"2816", "system/dict/index"},
  22. };
  23. try (PreparedStatement ps = c.prepareStatement("SELECT menu_id, menu_name, component FROM sys_menu WHERE menu_id=?")) {
  24. for (String[] r : rows) {
  25. ps.setString(1, r[0]);
  26. try (ResultSet rs = ps.executeQuery()) {
  27. if (rs.next()) {
  28. String comp = rs.getString(3);
  29. java.nio.file.Path p = java.nio.file.Paths.get(
  30. "d:/ylrz_saas_new/adminui/src/views/" + comp + ".vue");
  31. System.out.println(rs.getString(1) + " " + rs.getString(2) + " -> " + comp
  32. + " file=" + (java.nio.file.Files.exists(p) ? "OK" : "MISSING"));
  33. }
  34. }
  35. }
  36. }
  37. System.out.println("\n=== all visible C menus with component not matching existing vue file (sample) ===");
  38. try (ResultSet rs = st.executeQuery(
  39. "SELECT menu_id, menu_name, component FROM sys_menu "
  40. + "WHERE menu_type='C' AND visible='0' AND status='0' "
  41. + "AND component IS NOT NULL AND component <> '' "
  42. + "AND component LIKE '%/index' "
  43. + "ORDER BY menu_id")) {
  44. int missing = 0;
  45. while (rs.next() && missing < 30) {
  46. String comp = rs.getString(3);
  47. java.nio.file.Path p = java.nio.file.Paths.get(
  48. "d:/ylrz_saas_new/adminui/src/views/" + comp + ".vue");
  49. if (!java.nio.file.Files.exists(p)) {
  50. // try without /index
  51. p = java.nio.file.Paths.get(
  52. "d:/ylrz_saas_new/adminui/src/views/" + comp.replace("/index", "") + "/index.vue");
  53. }
  54. if (!java.nio.file.Files.exists(p)) {
  55. System.out.printf("404? %s | %s | %s%n",
  56. rs.getString(1), rs.getString(2), comp);
  57. missing++;
  58. }
  59. }
  60. }
  61. }
  62. }
  63. }