ソースを参照

修复全屏风模板初始化数据缺失

补齐 hxcs 同步链路中的全屏风模板栏目、首页子栏目和示例文章修复脚本,并让红色模板能够按试运行域名定位没有 id_code 的现有演示站。网站创建前增加模板栏目完整性检查,避免模板数据为空时生成没有栏目和文章的网站。\n\nValidation:\n- bash -n local-run/bin/sync-to-hxcs-prod.sh\n- WebsiteService.java 编译通过\n- 本地数据库事务演练及 hxcs 形态兜底演练通过并回滚\n- 本地完整服务重启成功,首页、红色模板站点和工作台返回 200
非繁 4 ヶ月 前
親
コミット
91c21afae0

+ 29 - 0
local-run/bin/sync-to-hxcs-prod.sh

@@ -96,6 +96,22 @@ run_db_sync() {
 		log "  -> $(basename "${sql}")"
 		remote_mysql --default-character-set=utf8mb4 < "${sql}"
 	done
+
+	local template_repairs=(
+		"${PROJECT_ROOT}/local-run/repairs/2026-06-19-screen-final-nav-matrix.sql"
+		"${PROJECT_ROOT}/local-run/repairs/2026-06-18-screen-template-home-columns.sql"
+		"${PROJECT_ROOT}/local-run/repairs/2026-06-18-screen-color-study-section.sql"
+		"${PROJECT_ROOT}/local-run/repairs/2026-06-18-screen-quick-entry-columns.sql"
+		"${PROJECT_ROOT}/local-run/repairs/2026-06-18-screen-study-description.sql"
+		"${PROJECT_ROOT}/local-run/repairs/2026-06-19-screen-study-children-pages.sql"
+		"${PROJECT_ROOT}/local-run/repairs/2026-06-19-screen-red-template.sql"
+	)
+	log "执行 ffkj 模板栏目与示例文章补齐..."
+	for sql in "${template_repairs[@]}"; do
+		[[ -f "${sql}" ]] || continue
+		log "  -> $(basename "${sql}")"
+		remote_mysql --default-character-set=utf8mb4 < "${sql}"
+	done
 	log "DB 同步完成。"
 }
 
@@ -247,6 +263,19 @@ verify_remote() {
 	log "验证远程 DB 关键记录..."
 	remote_mysql --default-character-set=utf8mb4 -e "
 SELECT 'templates' AS t, config, name FROM sp_gzhx_apps.website_template WHERE config IN ('ffkjscreen02','ffkjcollegered1');
+SELECT 'template_navigation' AS t, t.config, COUNT(n.navigationid) AS cnt
+FROM sp_gzhx_apps.website_template t
+LEFT JOIN sp_gzhx_apps.website_navigation n ON n.wnccode = 10010 AND n.wtid = t.wtid
+WHERE t.config IN ('ffkjscreen02','ffkjcollegered1')
+GROUP BY t.config;
+SELECT 'website_content' AS t, w.websiteid, w.name,
+       COUNT(DISTINCT n.navigationid) AS navigation_cnt,
+       COUNT(DISTINCT a.articleid) AS article_cnt
+FROM sp_gzhx_apps.website w
+LEFT JOIN sp_gzhx_apps.website_navigation n ON n.wnccode = 10000 AND n.websiteid = w.websiteid
+LEFT JOIN sp_gzhx_apps.article a ON a.websiteid = w.websiteid
+WHERE w.wtid IN (SELECT wtid FROM sp_gzhx_apps.website_template WHERE config IN ('ffkjscreen02','ffkjcollegered1'))
+GROUP BY w.websiteid, w.name;
 SELECT 'core_zj' AS t, COUNT(*) AS cnt FROM sp_gzhx_core.core_zj WHERE DYFWM LIKE 'website.ffkj%';
 SELECT 'guest' AS t, COUNT(*) AS cnt FROM information_schema.tables WHERE table_schema='sp_gzhx_apps' AND table_name LIKE '%guest%';
 "

+ 12 - 0
local-run/repairs/2026-06-18-screen-color-study-section.sql

@@ -4,6 +4,18 @@ SET @screen_template_id := (
 SET @screen_website_id := (
   SELECT websiteid FROM website WHERE id_code = 'local_ffkj_screen_site' ORDER BY websiteid LIMIT 1
 );
+SET @screen_website_id := COALESCE(
+  @screen_website_id,
+  (
+    SELECT w.websiteid
+    FROM website w
+    JOIN website_template t ON t.wtid = w.wtid
+    WHERE t.config = 'ffkjscreen02'
+      AND (w.domains LIKE '%hxcs.feifan.net%' OR w.domains LIKE '%ffkj-screen-red.localhost%')
+    ORDER BY w.websiteid
+    LIMIT 1
+  )
+);
 
 DROP TEMPORARY TABLE IF EXISTS ffkj_screen_study_nav_seed;
 CREATE TEMPORARY TABLE ffkj_screen_study_nav_seed (

+ 12 - 0
local-run/repairs/2026-06-18-screen-quick-entry-columns.sql

@@ -4,6 +4,18 @@ SET @screen_template_id := (
 SET @screen_website_id := (
   SELECT websiteid FROM website WHERE id_code = 'local_ffkj_screen_site' ORDER BY websiteid LIMIT 1
 );
+SET @screen_website_id := COALESCE(
+  @screen_website_id,
+  (
+    SELECT w.websiteid
+    FROM website w
+    JOIN website_template t ON t.wtid = w.wtid
+    WHERE t.config = 'ffkjscreen02'
+      AND (w.domains LIKE '%hxcs.feifan.net%' OR w.domains LIKE '%ffkj-screen-red.localhost%')
+    ORDER BY w.websiteid
+    LIMIT 1
+  )
+);
 
 DROP TEMPORARY TABLE IF EXISTS ffkj_screen_quick_nav_seed;
 CREATE TEMPORARY TABLE ffkj_screen_quick_nav_seed (

+ 12 - 0
local-run/repairs/2026-06-18-screen-study-description.sql

@@ -4,6 +4,18 @@ SET @screen_template_id := (
 SET @screen_website_id := (
   SELECT websiteid FROM website WHERE id_code = 'local_ffkj_screen_site' ORDER BY websiteid LIMIT 1
 );
+SET @screen_website_id := COALESCE(
+  @screen_website_id,
+  (
+    SELECT w.websiteid
+    FROM website w
+    JOIN website_template t ON t.wtid = w.wtid
+    WHERE t.config = 'ffkjscreen02'
+      AND (w.domains LIKE '%hxcs.feifan.net%' OR w.domains LIKE '%ffkj-screen-red.localhost%')
+    ORDER BY w.websiteid
+    LIMIT 1
+  )
+);
 SET @study_description := '围绕招生咨询、专业选择、就业发展和校园服务,集中呈现报考指南、培养特色、成长支持等信息,帮助学生和家长更清晰地了解在华夏学习、生活与发展的路径。';
 
 UPDATE website_navigation

+ 12 - 0
local-run/repairs/2026-06-18-screen-template-home-columns.sql

@@ -4,6 +4,18 @@ SET @screen_template_id := (
 SET @screen_website_id := (
   SELECT websiteid FROM website WHERE id_code = 'local_ffkj_screen_site' ORDER BY websiteid LIMIT 1
 );
+SET @screen_website_id := COALESCE(
+  @screen_website_id,
+  (
+    SELECT w.websiteid
+    FROM website w
+    JOIN website_template t ON t.wtid = w.wtid
+    WHERE t.config = 'ffkjscreen02'
+      AND (w.domains LIKE '%hxcs.feifan.net%' OR w.domains LIKE '%ffkj-screen-red.localhost%')
+    ORDER BY w.websiteid
+    LIMIT 1
+  )
+);
 
 UPDATE website_navigation
 SET dcode = 71

+ 18 - 1
local-run/repairs/2026-06-19-screen-final-nav-matrix.sql

@@ -2,7 +2,23 @@ SET @screen_template_id := (
   SELECT wtid FROM website_template WHERE config = 'ffkjscreen01' ORDER BY wtid LIMIT 1
 );
 SET @screen_website_id := (
-  SELECT websiteid FROM website WHERE id_code = 'local_ffkj_screen_site' ORDER BY websiteid LIMIT 1
+  SELECT websiteid
+  FROM website
+  WHERE id_code = 'local_ffkj_screen_site'
+  ORDER BY websiteid
+  LIMIT 1
+);
+SET @screen_website_id := COALESCE(
+  @screen_website_id,
+  (
+    SELECT w.websiteid
+    FROM website w
+    JOIN website_template t ON t.wtid = w.wtid
+    WHERE t.config = 'ffkjscreen02'
+      AND (w.domains LIKE '%hxcs.feifan.net%' OR w.domains LIKE '%ffkj-screen-red.localhost%')
+    ORDER BY w.websiteid
+    LIMIT 1
+  )
 );
 SET @content_path := '/web/upload/ffkj-template/content/portal-demo.html';
 
@@ -28,6 +44,7 @@ CREATE TEMPORARY TABLE ffkj_screen_nav_seed (
 
 INSERT INTO ffkj_screen_nav_seed VALUES
 ('FFKJ_SCHOOL_HOME', NULL, '首页', 'Home', '首页', '网站首页。', 10000, 10000, 10010, 10010, NULL, '/', NULL, NULL, '/main/ffkj-portal/assets/official/banner-3.png', 10),
+('FFKJ_SCHOOL_HOME_GROUP', NULL, '首页子栏目', 'Home Sections', '首页子栏目', '首页各内容区的隐藏栏目。', 10051, 10030, 10010, NULL, NULL, NULL, NULL, NULL, NULL, 9000),
 ('FFKJ_SCHOOL_ABOUT', NULL, '学校概况', 'School Profile', '学校概况', '学校简介、学校领导、学校标识、名师风采、学校荣誉、学校大事记和校园风光。', 10010, 10000, 10010, 10010, 'xuexiaogaikuang', '/xuexiaogaikuang/', NULL, NULL, '/main/ffkj-portal/assets/official/view-hero.jpg', 20),
 ('FFKJ_SCHOOL_ORG', NULL, '组织结构', 'Organization', '组织结构', '教学单位、管理服务等组织机构信息。', 10010, 10000, 10010, 10010, 'zuzhijiegou', '/zuzhijiegou/', NULL, NULL, '/main/ffkj-portal/assets/official/banner-3.png', 30),
 ('FFKJ_SCHOOL_NEWS_NAV', NULL, '校园新闻', 'News', '校园新闻', '学院要闻、一线动态、媒体华夏、师生风采和专题专栏。', 10010, 10000, 10010, 10010, 'xiaoyuanxinwen', '/xiaoyuanxinwen/', NULL, NULL, '/main/ffkj-portal/assets/official/campus-4.jpg', 40),

+ 63 - 1
local-run/repairs/2026-06-19-screen-red-template.sql

@@ -52,6 +52,25 @@ SET @red_template_id := (
   SELECT wtid FROM website_template WHERE config = @red_template_code ORDER BY wtid LIMIT 1
 );
 
+SET @red_website_id := (
+  SELECT websiteid
+  FROM website
+  WHERE id_code = @red_website_id_code
+  ORDER BY websiteid
+  LIMIT 1
+);
+SET @red_website_id := COALESCE(
+  @red_website_id,
+  (
+    SELECT websiteid
+    FROM website
+    WHERE wtid = @red_template_id
+      AND (domains LIKE '%hxcs.feifan.net%' OR domains LIKE '%ffkj-screen-red.localhost%')
+    ORDER BY websiteid
+    LIMIT 1
+  )
+);
+
 INSERT INTO website (
   dcode, unitid, wtcode, wtid, parent_wid, name, `desc`, protocol, port, domains, catalog_uri,
   logo, white_logo_file, seo_icon, seo_title, seo_keywords, seo_description, create_time, create_pid, id_code
@@ -80,10 +99,19 @@ SELECT
 FROM website bw
 WHERE bw.websiteid = @blue_website_id
   AND @red_template_id IS NOT NULL
+  AND @red_website_id IS NULL
   AND NOT EXISTS (SELECT 1 FROM website WHERE id_code = @red_website_id_code);
 
 SET @red_website_id := (
-  SELECT websiteid FROM website WHERE id_code = @red_website_id_code ORDER BY websiteid LIMIT 1
+  SELECT websiteid
+  FROM website
+  WHERE id_code = @red_website_id_code
+     OR (
+       wtid = @red_template_id
+       AND (domains LIKE '%hxcs.feifan.net%' OR domains LIKE '%ffkj-screen-red.localhost%')
+     )
+  ORDER BY websiteid
+  LIMIT 1
 );
 
 UPDATE website rw
@@ -199,6 +227,40 @@ WHERE bn.wnccode = 10000
       AND rn.idcard = bn.idcard
   );
 
+INSERT INTO website_navigation (
+  dcode, unitid, wnccode, websiteid, wtid, idcard, name, name_assistant, title, `desc`,
+  wntcode, wnscode, wnjtcode, wnlscode, uri, url, jump_url, jump_websiteid, parent_nid,
+  photo_size_width, photo_size_height, background_image, sort_number, create_time, create_pid
+)
+SELECT
+  tn.dcode, tn.unitid, 10000, @red_website_id, NULL, tn.idcard, tn.name, tn.name_assistant, tn.title, tn.`desc`,
+  tn.wntcode, tn.wnscode, tn.wnjtcode, tn.wnlscode, tn.uri, tn.url, tn.jump_url, tn.jump_websiteid, NULL,
+  tn.photo_size_width, tn.photo_size_height, tn.background_image, tn.sort_number, NOW(), 10000
+FROM website_navigation tn
+WHERE tn.wnccode = 10010
+  AND tn.wtid = @red_template_id
+  AND @red_website_id IS NOT NULL
+  AND NOT EXISTS (
+    SELECT 1 FROM website_navigation rn
+    WHERE rn.wnccode = 10000
+      AND rn.websiteid = @red_website_id
+      AND rn.idcard = tn.idcard
+  );
+
+UPDATE website_navigation rn
+JOIN website_navigation tn ON tn.wnccode = 10010
+  AND tn.wtid = @red_template_id
+  AND tn.idcard = rn.idcard
+LEFT JOIN website_navigation tp ON tp.wnccode = 10010
+  AND tp.wtid = @red_template_id
+  AND tp.navigationid = tn.parent_nid
+LEFT JOIN website_navigation rp ON rp.wnccode = 10000
+  AND rp.websiteid = @red_website_id
+  AND rp.idcard = tp.idcard
+SET rn.parent_nid = CASE WHEN tp.navigationid IS NULL THEN NULL ELSE rp.navigationid END
+WHERE rn.wnccode = 10000
+  AND rn.websiteid = @red_website_id;
+
 UPDATE website_navigation rn
 JOIN website_navigation bn ON bn.wnccode = 10000
   AND bn.websiteid = @blue_website_id

+ 12 - 0
local-run/repairs/2026-06-19-screen-study-children-pages.sql

@@ -4,6 +4,18 @@ SET @screen_template_id := (
 SET @screen_website_id := (
   SELECT websiteid FROM website WHERE id_code = 'local_ffkj_screen_site' ORDER BY websiteid LIMIT 1
 );
+SET @screen_website_id := COALESCE(
+  @screen_website_id,
+  (
+    SELECT w.websiteid
+    FROM website w
+    JOIN website_template t ON t.wtid = w.wtid
+    WHERE t.config = 'ffkjscreen02'
+      AND (w.domains LIKE '%hxcs.feifan.net%' OR w.domains LIKE '%ffkj-screen-red.localhost%')
+    ORDER BY w.websiteid
+    LIMIT 1
+  )
+);
 SET @study_content_path := '/web/upload/ffkj-template/content/study-demo.html';
 
 DROP TEMPORARY TABLE IF EXISTS ffkj_screen_study_child_seed;

+ 18 - 0
src/space/apps/moudules/website/services/WebsiteService.java

@@ -44,6 +44,10 @@ public class WebsiteService extends BaseTransaction {
 
 		Website website = (Website) PojoUtil.formatRequest(getRequest(), Website.class);
 		GeneralDBAccess gdba = getGdbaInstance();
+		String templateConfig = getWebsiteTemplateConfig(gdba, website.getWtid());
+		if (isFfkjPortalTemplate(templateConfig) && getTemplateNavigationCount(gdba, website.getWtid()) == 0) {
+			throw new IllegalStateException("网站模板[" + templateConfig + "]尚未完成栏目初始化,请先同步模板栏目数据后再创建网站。");
+		}
 		website.setCatalogUri("/");
 		gdba.insertByBean(website);
 
@@ -134,6 +138,20 @@ public class WebsiteService extends BaseTransaction {
 		return templateMap.get("config").toString();
 	}
 
+	private int getTemplateNavigationCount(GeneralDBAccess gdba, Long wtId) throws Exception {
+		if (StringUtil.isNull(wtId)) {
+			return 0;
+		}
+		String sql = " select count(*) as count from website_navigation where wnccode = 10010 and wtid = :wtId ";
+		SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
+		sqlCmd.setString("wtId", wtId);
+		Map<String, Object> navigationCountMap = gdba.selectAsMap(sqlCmd);
+		if (navigationCountMap == null || navigationCountMap.get("count") == null) {
+			return 0;
+		}
+		return Integer.valueOf(navigationCountMap.get("count").toString());
+	}
+
 	private boolean isFfkjPortalTemplate(String templateConfig) {
 		return "ffkjschool01".equals(templateConfig) || "ffkjcollege1".equals(templateConfig)
 				|| "ffkjscreen01".equals(templateConfig) || "ffkjscreen02".equals(templateConfig)