2026-05-31-recursive-nav-demo.sql 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. USE spaceappsv1;
  2. SET @unit_id := 10000;
  3. SET @create_pid := 10000;
  4. SET @college_template_id := (
  5. SELECT wtid
  6. FROM website_template
  7. WHERE config = 'ffkjcollege1'
  8. LIMIT 1
  9. );
  10. SET @art_website_id := (
  11. SELECT websiteid
  12. FROM website
  13. WHERE name = '建筑与艺术传媒学院'
  14. OR domains LIKE '%ffkj-jzyyscmxy%'
  15. ORDER BY websiteid DESC
  16. LIMIT 1
  17. );
  18. DROP TEMPORARY TABLE IF EXISTS zq_recursive_nav_seed;
  19. CREATE TEMPORARY TABLE zq_recursive_nav_seed (
  20. idcard VARCHAR(128) NOT NULL,
  21. parent_idcard VARCHAR(128) NULL,
  22. name VARCHAR(256) NOT NULL,
  23. name_assistant VARCHAR(256) NULL,
  24. title VARCHAR(256) NOT NULL,
  25. description VARCHAR(2048) NOT NULL,
  26. wntcode INT NOT NULL,
  27. wnscode INT NOT NULL,
  28. wnjtcode INT NOT NULL,
  29. wnlscode INT NULL,
  30. uri VARCHAR(512) NULL,
  31. url VARCHAR(512) NULL,
  32. sort_number INT NOT NULL
  33. );
  34. INSERT INTO zq_recursive_nav_seed VALUES
  35. ('FFKJ_COLLEGE_NEWS_NAV', NULL, '新闻动态', 'News', '新闻动态', '学院新闻动态列表。', 10010, 10000, 10010, 10010, 'xueyuandongtai', '/xueyuandongtai/', 30),
  36. ('FFKJ_COLLEGE_NOTICE_NAV', NULL, '公告通知', 'Notice', '公告通知', '学院公告与通知列表。', 10010, 10000, 10010, 10010, 'tongzhigonggao', '/tongzhigonggao/', 40),
  37. ('FFKJ_COLLEGE_NOTICE_ANNOUNCE', 'FFKJ_COLLEGE_NOTICE_NAV', '公告', 'Notice', '公告', '学院公告列表。', 10010, 10000, 10010, 10010, 'gonggao', '/tongzhigonggao/gonggao/', 10),
  38. ('FFKJ_COLLEGE_NOTICE_NOTICE', 'FFKJ_COLLEGE_NOTICE_NAV', '通知', 'Notice', '通知', '学院通知列表。', 10010, 10000, 10010, 10010, 'tongzhi', '/tongzhigonggao/tongzhi/', 20),
  39. ('FFKJ_COLLEGE_NOTICE_ANNOUNCE_COLLEGE_INITIAL', 'FFKJ_COLLEGE_NOTICE_ANNOUNCE', '学院公告【初始】', 'Notice', '学院公告【初始】', '用于验证多层级导航的初始示例栏目。', 10010, 10000, 10010, 10010, 'xueyuangonggao', '/tongzhigonggao/gonggao/xueyuangonggao/', 10),
  40. ('FFKJ_COLLEGE_NOTICE_ANNOUNCE_IMPORTANT_INITIAL', 'FFKJ_COLLEGE_NOTICE_ANNOUNCE_COLLEGE_INITIAL', '重要公告【初始】', 'Notice', '重要公告【初始】', '用于验证四级导航的初始示例栏目。', 10010, 10000, 10010, 10010, 'zhongyaogonggao', '/tongzhigonggao/gonggao/xueyuangonggao/zhongyaogonggao/', 10);
  41. INSERT INTO website_navigation (
  42. dcode, unitid, wnccode, websiteid, wtid, idcard, name, name_assistant, title, `desc`,
  43. wntcode, wnscode, wnjtcode, wnlscode, uri, url, parent_nid,
  44. photo_size_width, photo_size_height, background_image, sort_number, create_time, create_pid
  45. )
  46. SELECT
  47. 61, @unit_id, 10010, NULL, @college_template_id, s.idcard, s.name, s.name_assistant, s.title, s.description,
  48. s.wntcode, s.wnscode, s.wnjtcode, s.wnlscode, s.uri, s.url, parent.navigationid,
  49. 380, 220, NULL, s.sort_number, NOW(), @create_pid
  50. FROM zq_recursive_nav_seed s
  51. LEFT JOIN website_navigation parent ON parent.wnccode = 10010
  52. AND parent.wtid = @college_template_id
  53. AND parent.idcard = s.parent_idcard
  54. WHERE @college_template_id IS NOT NULL
  55. AND NOT EXISTS (
  56. SELECT 1
  57. FROM website_navigation wn
  58. WHERE wn.wnccode = 10010
  59. AND wn.wtid = @college_template_id
  60. AND wn.idcard = s.idcard
  61. );
  62. UPDATE website_navigation wn
  63. JOIN zq_recursive_nav_seed s ON wn.wnccode = 10010
  64. AND wn.wtid = @college_template_id
  65. AND wn.idcard = s.idcard
  66. LEFT JOIN website_navigation parent ON parent.wnccode = 10010
  67. AND parent.wtid = @college_template_id
  68. AND parent.idcard = s.parent_idcard
  69. SET wn.dcode = 61,
  70. wn.unitid = @unit_id,
  71. wn.websiteid = NULL,
  72. wn.name = s.name,
  73. wn.name_assistant = s.name_assistant,
  74. wn.title = s.title,
  75. wn.`desc` = s.description,
  76. wn.wntcode = s.wntcode,
  77. wn.wnscode = s.wnscode,
  78. wn.wnjtcode = s.wnjtcode,
  79. wn.wnlscode = s.wnlscode,
  80. wn.uri = s.uri,
  81. wn.url = s.url,
  82. wn.jump_url = NULL,
  83. wn.jump_websiteid = NULL,
  84. wn.parent_nid = parent.navigationid,
  85. wn.sort_number = s.sort_number;
  86. SET @site_notice_nav_id := (
  87. SELECT navigationid
  88. FROM website_navigation
  89. WHERE websiteid = @art_website_id
  90. AND idcard = 'FFKJ_COLLEGE_NOTICE_NAV'
  91. LIMIT 1
  92. );
  93. UPDATE website_navigation
  94. SET idcard = 'FFKJ_COLLEGE_NOTICE_ANNOUNCE'
  95. WHERE websiteid = @art_website_id
  96. AND parent_nid = @site_notice_nav_id
  97. AND name = '公告';
  98. UPDATE website_navigation
  99. SET idcard = 'FFKJ_COLLEGE_NOTICE_NOTICE'
  100. WHERE websiteid = @art_website_id
  101. AND parent_nid = @site_notice_nav_id
  102. AND name = '通知';
  103. INSERT INTO website_navigation (
  104. dcode, unitid, wnccode, websiteid, wtid, idcard, name, name_assistant, title, `desc`,
  105. wntcode, wnscode, wnjtcode, wnlscode, uri, url, parent_nid,
  106. photo_size_width, photo_size_height, background_image, sort_number, create_time, create_pid
  107. )
  108. SELECT
  109. 61, @unit_id, 10000, @art_website_id, NULL, s.idcard, s.name, s.name_assistant, s.title, s.description,
  110. s.wntcode, s.wnscode, s.wnjtcode, s.wnlscode, s.uri, s.url, parent.navigationid,
  111. 380, 220, NULL, s.sort_number, NOW(), @create_pid
  112. FROM zq_recursive_nav_seed s
  113. LEFT JOIN website_navigation parent ON parent.wnccode = 10000
  114. AND parent.websiteid = @art_website_id
  115. AND parent.idcard = s.parent_idcard
  116. WHERE @art_website_id IS NOT NULL
  117. AND s.idcard NOT IN ('FFKJ_COLLEGE_NEWS_NAV', 'FFKJ_COLLEGE_NOTICE_NAV')
  118. AND NOT EXISTS (
  119. SELECT 1
  120. FROM website_navigation wn
  121. WHERE wn.wnccode = 10000
  122. AND wn.websiteid = @art_website_id
  123. AND wn.idcard = s.idcard
  124. );
  125. UPDATE website_navigation wn
  126. JOIN zq_recursive_nav_seed s ON wn.wnccode = 10000
  127. AND wn.websiteid = @art_website_id
  128. AND wn.idcard = s.idcard
  129. LEFT JOIN website_navigation parent ON parent.wnccode = 10000
  130. AND parent.websiteid = @art_website_id
  131. AND parent.idcard = s.parent_idcard
  132. SET wn.dcode = 61,
  133. wn.unitid = @unit_id,
  134. wn.name = s.name,
  135. wn.name_assistant = s.name_assistant,
  136. wn.title = s.title,
  137. wn.`desc` = s.description,
  138. wn.wntcode = s.wntcode,
  139. wn.wnscode = s.wnscode,
  140. wn.wnjtcode = s.wnjtcode,
  141. wn.wnlscode = s.wnlscode,
  142. wn.uri = s.uri,
  143. wn.url = s.url,
  144. wn.jump_url = NULL,
  145. wn.jump_websiteid = NULL,
  146. wn.parent_nid = parent.navigationid,
  147. wn.sort_number = s.sort_number
  148. WHERE s.idcard NOT IN ('FFKJ_COLLEGE_NEWS_NAV', 'FFKJ_COLLEGE_NOTICE_NAV');
  149. DROP TEMPORARY TABLE IF EXISTS zq_recursive_nav_seed;