From d34f6470402c2948d520fbfb3f54d1575482d5dd Mon Sep 17 00:00:00 2001 From: chenwenke Date: Fri, 1 May 2026 10:03:06 +0800 Subject: [PATCH] =?UTF-8?q?feat(ip):=20=E8=B0=83=E6=95=B4=E9=A6=99?= =?UTF-8?q?=E6=B8=AF=E5=92=8C=E6=BE=B3=E9=97=A8=E7=9A=84=E8=A1=8C=E6=94=BF?= =?UTF-8?q?=E5=8C=BA=E5=88=92=E5=B1=82=E7=BA=A7=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加香港特别行政区和澳门特别行政区作为二级行政区 - 调整香港和澳门的行政区划层级结构 - 优化区域数据的层级映射规则 --- .../ip/core/utils/AreaDataConverterTest.java | 18 ++++++++++++++---- .../src/test/resources/area_new.csv | 12 ++++++------ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/yudao-framework/yudao-spring-boot-starter-biz-ip/src/test/java/cn/iocoder/yudao/framework/ip/core/utils/AreaDataConverterTest.java b/yudao-framework/yudao-spring-boot-starter-biz-ip/src/test/java/cn/iocoder/yudao/framework/ip/core/utils/AreaDataConverterTest.java index 2d5612a18..4f9ea8cb8 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-ip/src/test/java/cn/iocoder/yudao/framework/ip/core/utils/AreaDataConverterTest.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-ip/src/test/java/cn/iocoder/yudao/framework/ip/core/utils/AreaDataConverterTest.java @@ -73,8 +73,13 @@ public class AreaDataConverterTest { for (CsvRow row : rows) { // id - String idStr = String.format("%-6s", Integer.parseInt(row.get(0))).replace(' ', '0'); - + String id = row.get(0); + String idStr; + if (id.startsWith("8")) {//香港澳门特殊处理 + idStr = id; + } else { + idStr = String.format("%-6s", Integer.parseInt(id)).replace(' ', '0'); + } // 转换层级 int deep = Integer.parseInt(row.get(2)); int type = deep + 2; // 0->2省, 1->3市, 2->4区 @@ -86,9 +91,14 @@ public class AreaDataConverterTest { } //父id - String pidStr = String.format("%-6s", Integer.parseInt(row.get(1))).replace(' ', '0'); - if ("000000".equals(pidStr)) { + String pid = row.get(1); + String pidStr; + if ("0".equals(pid)) { pidStr = "1"; // 省级,父节点为中国 + } else if (pid.startsWith("8")) {//香港澳门特殊处理 + pidStr = pid; + } else { + pidStr = String.format("%-6s", Integer.parseInt(pid)).replace(' ', '0'); } areas.add(new AreaObj(Integer.parseInt(idStr), name, type, Integer.parseInt(pidStr))); diff --git a/yudao-framework/yudao-spring-boot-starter-biz-ip/src/test/resources/area_new.csv b/yudao-framework/yudao-spring-boot-starter-biz-ip/src/test/resources/area_new.csv index 5333db54b..056b9047f 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-ip/src/test/resources/area_new.csv +++ b/yudao-framework/yudao-spring-boot-starter-biz-ip/src/test/resources/area_new.csv @@ -1,5 +1,7 @@ id,name,type,parentId 1,中国,1,0 +81,香港特别行政区,2,1 +82,澳门特别行政区,2,1 110000,北京市,2,1 120000,天津市,2,1 130000,河北省,2,1 @@ -32,8 +34,8 @@ id,name,type,parentId 640000,宁夏回族自治区,2,1 650000,新疆维吾尔自治区,2,1 710000,台湾省,2,1 -810000,香港特别行政区,2,1 -820000,澳门特别行政区,2,1 +8100,香港特别行政区,3,81 +8200,澳门特别行政区,3,82 110100,北京市,3,110000 120100,天津市,3,120000 130100,石家庄市,3,130000 @@ -424,8 +426,6 @@ id,name,type,parentId 712500,台东县,3,710000 712600,花莲县,3,710000 712700,澎湖县,3,710000 -810000,香港特别行政区,3,810000 -820000,澳门特别行政区,3,820000 110101,东城区,4,110100 110102,西城区,4,110100 110105,朝阳区,4,110100 @@ -3601,8 +3601,8 @@ id,name,type,parentId 712710,七美乡,4,712700 712711,白沙乡,4,712700 712712,湖西乡,4,712700 -810000,香港特别行政区,4,810000 -820000,澳门特别行政区,4,820000 +810000,香港特别行政区,4,8100 +820000,澳门特别行政区,4,8200 419001000,济源市,4,419001 429004000,仙桃市,4,429004 429005000,潜江市,4,429005