feat(W4): 院系子站嵌套路径-cms_site.path列+uk_site_path/parent_code,门户单段+嵌套双映射,旧链301,public_base_url派生,sitePath预览,SQL三处+升级脚本,T-W4-01..15 全绿279/279

This commit is contained in:
chenxing
2026-09-08 12:34:33 +08:00
parent 5da6f7ee5d
commit 536bd6cea4
30 changed files with 593 additions and 55 deletions
@@ -213,4 +213,33 @@ class PortalUrlHelperTest {
assertThat(url.asset("css/main.css"))
.isEqualTo("https://base.yunhaixingtong.com/cms/portal/demo/assets/default/css/main.css");
}
// ===== W4 嵌套路径(方案 §8.3 T-W4-11/12:构造参语义 code→sitePath)=====
@Test
@DisplayName("T-W4-11: 嵌套 sitePath 的 baseUrl/asset/category 全嵌套")
void nestedSitePath_allUrlsNested() {
PortalUrlHelper url = PortalUrlHelper.fromBaseOrigin(
"https://base.yunhaixingtong.com/cms", "sch-3/jdxy", "scholar-blue");
assertThat(url.home()).isEqualTo("https://base.yunhaixingtong.com/cms/portal/sch-3/jdxy/");
assertThat(url.category(7)).isEqualTo("https://base.yunhaixingtong.com/cms/portal/sch-3/jdxy/c/7");
assertThat(url.article(9)).isEqualTo("https://base.yunhaixingtong.com/cms/portal/sch-3/jdxy/a/9");
assertThat(url.asset("css/main.css"))
.isEqualTo("https://base.yunhaixingtong.com/cms/portal/sch-3/jdxy/assets/scholar-blue/css/main.css");
}
@Test
@DisplayName("T-W4-12: siteHome 兄弟/父级——当前=sch-3/jdxy 时替换站点段为嵌套目标")
void nestedSitePath_siteHomeSiblingsAndParent() {
PortalUrlHelper url = new PortalUrlHelper(
"https://base.yunhaixingtong.com/cms/portal/sch-3/jdxy", "sch-3/jdxy", "default",
"https://base.yunhaixingtong.com/cms");
// 父级主站
assertThat(url.siteHome("sch-3", null)).isEqualTo("https://base.yunhaixingtong.com/cms/portal/sch-3/");
// 兄弟子站(嵌套形态同构)
assertThat(url.siteHome("sch-3/other", null))
.isEqualTo("https://base.yunhaixingtong.com/cms/portal/sch-3/other/");
// 目标配 public_base_url 时优先
assertThat(url.siteHome("sch-3/other", "https://other.xxx.edu.cn")).isEqualTo("https://other.xxx.edu.cn/");
}
}