Skip to content

Commit ab4c39c

Browse files
committed
Use "description" instead of "detail"
1 parent a34637b commit ab4c39c

15 files changed

+113
-110
lines changed

README.md

+11-8
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010

1111
| 数据集名称 | 规范 | 目录 | 汇总 | 进度 |
1212
| - | - | - | - | - |
13-
| 历史行政区划代码 || [data](data) | [SQL](sql) \| [JSON] \| [CSV] | 100% |
14-
| 新旧代码对应关系 | [diff 规范](diff-spec.md) | [diff](diff) | 同上 | 100% |
13+
| 历史行政区划代码 || [data](data) | [SQL](sql) \| [JSON] \| [CSV] | 已完成 |
14+
| 新旧代码对应关系 | [diff 规范](diff-spec.md) | [diff](diff) | 同上 | 基本完成* |
15+
16+
\* 代码变更的文本描述收集工作现已开始,欢迎各位参与,详情请见 Issue #TODO。
1517

1618
## CSV 汇总表说明
1719

@@ -26,19 +28,20 @@
2628
注:“新代码”中代码以字符 `;` 分隔。若一代码后接包含年份的方括号(如 `[2010]`),说明其对应的行政区域变更发生在指定的年份,否则默认为“变更(弃用)时间”。
2729
- 查询一条记录对应的最新代码的方法是,以该记录为根节点,按“新代码”字段展开树节点,直至所有叶节点的“新代码”字段均为空且状态均为“启用”为止。
2830
- 在行政区划合并后又拆分的情况(或其他类似情况)下,按上述方法或不能精确查询一条记录对应的最新代码。后续可通过扩展语法解决此问题。
29-
- 本汇总表适用 [CC0] 许可协议,仅供参考之用,不建议用于其他用途。
31+
- 本汇总表适用 [CC0-1.0] 许可协议,仅供参考之用,不建议用于其他用途。
3032

3133
## 原始数据来源
3234

33-
- [中华人民共和国县级以上行政区划代码][1],民政部
34-
- [县级以上行政区划变更情况][2],民政部
35-
- [中华人民共和国行政区划沿革][3],中国政府网
36-
- [全国行政区划信息查询平台][4],民政部
35+
- [中华人民共和国县级以上行政区划代码][1],民政部。
36+
- [县级以上行政区划变更情况][2],民政部。
37+
- [中华人民共和国行政区划沿革][3],中国政府网。
38+
- [全国行政区划信息查询平台][4],民政部。
39+
- [原始数据勘误](errata.md),本项目。
3740

3841
[preview]: https://yescallop.cn/areacodes/
3942
[CSV]: https://raw.githubusercontent.com/yescallop/areacodes/master/result.csv
4043
[JSON]: https://raw.githubusercontent.com/yescallop/areacodes/master/codes.json
41-
[CC0]: https://creativecommons.org/publicdomain/zero/1.0/deed.zh
44+
[CC0-1.0]: https://creativecommons.org/publicdomain/zero/1.0/deed.zh-hans
4245
[1]: https://www.mca.gov.cn/n156/n186/index.html
4346
[2]: http://xzqh.mca.gov.cn/description?dcpid=1
4447
[3]: http://www.gov.cn/test/2006-02/27/content_212020.htm

app/src/App.vue

+8-8
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const guide: Item = {
3838
code: 4,
3939
name: "向右的箭头表明代码的后继",
4040
start: 1980,
41-
successors: [{ code: 5, time: 1990, details: "这是一条变更详情" }]
41+
successors: [{ code: 5, time: 1990, desc: "这是一条变更描述" }]
4242
},
4343
{
4444
code: 5,
@@ -185,13 +185,13 @@ insertItem(guide, []);
185185
fetch(codesUrl)
186186
.then(resp => resp.json())
187187
.then((resp: CodesJson) => {
188-
resp.items.forEach(item => insertItem(item, resp.details));
188+
resp.items.forEach(item => insertItem(item, resp.descriptions));
189189
createIndexArr();
190190
scrollToHash();
191191
itemArr.value = resp.items;
192192
});
193193
194-
function insertItem(item: Item, details: string[], parent?: Item) {
194+
function insertItem(item: Item, descriptions: string[], parent?: Item) {
195195
let arr = items.get(item.code);
196196
if (arr == undefined) {
197197
arr = [];
@@ -207,18 +207,18 @@ function insertItem(item: Item, details: string[], parent?: Item) {
207207
arr.push(item);
208208
209209
item.successors?.forEach(link => {
210-
if (link.id != undefined) {
211-
link.details = details[link.id];
212-
link.id = undefined;
210+
if (link.desc_id != undefined) {
211+
link.desc = descriptions[link.desc_id];
212+
link.desc_id = undefined;
213213
}
214214
let links = predecessors.get(link.code);
215215
if (links == undefined) {
216216
links = [];
217217
predecessors.set(link.code, links);
218218
}
219-
links.push({ time: timeOrDefault(link, item), code: item.code, details: link.details });
219+
links.push({ time: timeOrDefault(link, item), code: item.code, desc: link.desc });
220220
});
221-
item.children?.forEach(child => insertItem(child, details, item));
221+
item.children?.forEach(child => insertItem(child, descriptions, item));
222222
item.parent = parent;
223223
}
224224

app/src/common.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export interface GlobalProps {
1414

1515
export interface CodesJson {
1616
items: Item[],
17-
details: string[],
17+
descriptions: string[],
1818
}
1919

2020
export interface Item {
@@ -47,14 +47,14 @@ export enum Action {
4747
export interface Link {
4848
time?: number,
4949
code: number,
50-
id?: number,
51-
details?: string,
50+
desc_id?: number,
51+
desc?: string,
5252
}
5353

5454
export interface LinkZip {
5555
codes: {
5656
code: number,
57-
details?: string,
57+
desc?: string,
5858
}[],
5959
time: number,
6060
rev: boolean,

app/src/components/Link.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { inject } from 'vue';
33
import { type Item, scrollToItem, Action } from '@/common';
44
5-
defineProps<{ item: Item; details?: string; }>();
5+
defineProps<{ item: Item; desc?: string; }>();
66
77
const srcItem = inject<Item>('srcItem')!;
88
@@ -15,7 +15,7 @@ function onKeyDown(e: KeyboardEvent) {
1515
</script>
1616

1717
<template>
18-
<a :href="`#${item.code}:${item.start}`" :title="details" @click.prevent="scrollToItem(item)" @keydown="onKeyDown">
18+
<a :href="`#${item.code}:${item.start}`" :title="desc" @click.prevent="scrollToItem(item)" @keydown="onKeyDown">
1919
<ruby v-if="item.name != srcItem.name">{{ item.code }}<rt>{{
2020
item.name
2121
}}</rt></ruby>

app/src/components/Links.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const filteredLinkZips = computed(() => {
1313
let items = linkZip.codes
1414
.map(it => {
1515
let item = gProps.resolveLink(it.code, linkZip.time, linkZip.rev);
16-
return { item, details: it.details };
16+
return { item, desc: it.desc };
1717
}).filter(it => {
1818
if (it.item.code < 100000) return true;
1919
let res = gProps.searchResult.value;
@@ -31,7 +31,7 @@ const filteredLinkZips = computed(() => {
3131
{{ linkZip.rev ? "<=" : "=>" }}
3232
<template v-for="(it, index) in linkZip.items">
3333
<template v-if="index != 0">,</template>
34-
<Link :item="it.item" :details="it.details" />
34+
<Link :item="it.item" :desc="it.desc" />
3535
</template>
3636
&lt;{{ linkZip.time }}&gt;
3737
</li>

app/src/components/TreeItem.vue

+6-6
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function act() {
6666
interface LinkWithDirection {
6767
code: number,
6868
time: number,
69-
details?: string,
69+
desc?: string,
7070
rev: boolean,
7171
}
7272
@@ -78,7 +78,7 @@ function getLinks(): LinkWithDirection[] {
7878
links = predecessors.filter(link => {
7979
return link.time! >= item.start && (item.end == undefined || link.time! < item.end);
8080
}).map(link => {
81-
return { code: link.code, time: link.time!, details: link.details, rev: true };
81+
return { code: link.code, time: link.time!, desc: link.desc, rev: true };
8282
});
8383
} else {
8484
links = [];
@@ -89,7 +89,7 @@ function getLinks(): LinkWithDirection[] {
8989
links.push({
9090
code: link.code,
9191
time: timeOrDefault(link, item),
92-
details: link.details,
92+
desc: link.desc,
9393
rev: false,
9494
});
9595
});
@@ -107,14 +107,14 @@ function zipLinks(links: LinkWithDirection[]): LinkZip[] {
107107
return [];
108108
}
109109
let out: LinkZip[] = [];
110-
let codes = [{ code: links[0].code, details: links[0].details }];
110+
let codes = [{ code: links[0].code, desc: links[0].desc }];
111111
let last = links[0];
112112
links.slice(1).forEach(link => {
113113
if (link.time == last.time && link.rev == last.rev) {
114-
codes.push({ code: link.code, details: link.details });
114+
codes.push({ code: link.code, desc: link.desc });
115115
} else {
116116
out.push({ codes, time: last.time, rev: last.rev });
117-
codes = [{ code: link.code, details: link.details }];
117+
codes = [{ code: link.code, desc: link.desc }];
118118
last = link;
119119
}
120120
});

codes.json

+1-1
Large diffs are not rendered by default.

diff/2021-2022.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![detailed]
1+
#![described]
22

33
## 黑龙江省民政厅关于同意七台河市设立兴北镇由新兴区划归茄子河区管辖的批复(黑民行批〔2022〕7号)
44
#

diff/2022-2023.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![detailed]
1+
#![described]
22

33
## 四川省人民政府关于同意宜宾市部分县级行政区域界线变更的批复(川府民政〔2023〕1号)
44
#

errata.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
# 勘误
1+
# 原始数据勘误
22

3+
- 1980-1982 年安阳市下辖三个区代码存在,删去。
4+
- 1983 年河南省安阳市代码原为 412101,更正为 412100
5+
- 1983 年陕西省咸阳市代码原为 610401,更正为 610400。
36
- 关于 2002 年安阳市市辖区和安阳县行政区划的调整,国务院的批复(国函〔2002〕123号)与河南省人民政府的通知(豫政文〔2003〕5号)中关于部分街道归属的表述很可能有误,应以安阳市人民政府的通知(安政〔2003〕4号)为准。以上三份文件均在《安阳市铁西区志》中有收录。勘误后的调整如下(对应关系见《安阳年鉴》):
47
- 撤销铁西区、郊区,设立殷都区、龙安区;调整北关区、文峰区和安阳县的行政区域;撤销原郊区的东郊乡、北郊乡。
58
- 殷都区辖铁西路、梅园庄、电厂路、水冶、李珍(铁西区)、纱厂路(北关区)6个街道;原郊区的西郊乡,原北郊乡的三家庄、大司空、西大姓、前皇甫、后皇甫、皇甫屯、杜小屯、大碾屯、郭王度、武官、侯庄、小营、秋口、双塔、东大姓、西司空、枯河17个村,原东郊乡的任家庄村。
69
- 龙安区辖文明大道、太行小区(铁西区)2个街道,原郊区的东风乡、龙泉镇,原郊区东郊乡的侯七里、苏七里、李七里、肖七里、宗村、四府坟、余家庄、侯家庄、烧盆窑9个村,原安阳县的马投涧乡、善应镇的中龙山、张家庄2个村,曲沟镇的西高平村,水冶镇的北彰武村,宝莲寺镇的丁家庄、郜家庄、杨家庄、北田村、南田村5个村。
710
- 北关区辖红旗路、豆腐营、洹北、解放路、灯塔路(北关区)5个街道,原安阳县柏庄镇的东石桃、西石桃、桃村口、田桃村、李桃村5个村,韩陵乡的西良贡、养鱼屯、六寺、唐庄、羊毛屯、黄家营、西见山、西于曹8个村,白壁镇的前崇义、中崇义、后崇义、西六村4个村,原郊区北郊乡的屈王度、方北营、周家营、安阳桥、西漳涧、东漳涧、董王度、冯家庙、宋家庙、十里铺、马家垒、张贺垒、程寸营、韩王度、缑家垒15个村,原东郊乡的小营、李家庄、杏花村、苏家村、南漳涧5个村。
811
- 文峰区辖南关、东关(文峰区)、西关(北关区)、甜水井、头二三道街、东大街、西大街、唐子巷、北大街(文峰区)9个街道,原安阳县的高庄乡、宝莲寺镇的郭村集、西郭村、杨家井、马束庄、皇甫庄、三十里铺、黎庄、梁家庄、崇召、何官屯、任庄、南马庄、袁薛庄、孙薛庄、张薛庄、刘薛庄、张村、黎官屯、赵官屯、东风、刘王坡、马官屯、二十里铺、小营、魏家营、牛房26个村,白壁镇的郑家村、晁家村、盖津店、三府村、任家庄、西瓦亭、东瓦亭7个村,原郊区东郊乡的汪家店、大营、三官庙、石家沟、王村、郭家街、东关、南关、聂村、后张村、郭家庄11个村。
9-
10-
- 1983 年河南省安阳市代码缺失,补全;1980-1982 年安阳市下辖三个区代码存在,删去。
11-
12-
- 1983 年陕西省咸阳市代码原为 610401,更正为 610400。

sql/db.sql

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ CREATE TABLE `changes` (
99
`code` int NOT NULL,
1010
`new_code` int NOT NULL,
1111
`time` int NOT NULL,
12-
`details_id` int NULL DEFAULT NULL,
12+
`desc_id` int NULL DEFAULT NULL,
1313
PRIMARY KEY (`code`, `new_code`, `time`) USING BTREE,
14-
INDEX `details_id`(`details_id` ASC) USING BTREE,
15-
CONSTRAINT `changes_ibfk_1` FOREIGN KEY (`details_id`) REFERENCES `details` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
14+
INDEX `desc_id`(`desc_id` ASC) USING BTREE,
15+
CONSTRAINT `changes_ibfk_1` FOREIGN KEY (`desc_id`) REFERENCES `descriptions` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
1616
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_zh_0900_as_cs;
1717

1818
-- ----------------------------
@@ -28,10 +28,10 @@ CREATE TABLE `codes` (
2828
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_zh_0900_as_cs;
2929

3030
-- ----------------------------
31-
-- Table structure for details
31+
-- Table structure for descriptions
3232
-- ----------------------------
33-
DROP TABLE IF EXISTS `details`;
34-
CREATE TABLE `details` (
33+
DROP TABLE IF EXISTS `descriptions`;
34+
CREATE TABLE `descriptions` (
3535
`id` int NOT NULL AUTO_INCREMENT,
3636
`text` text CHARACTER SET utf8mb4 COLLATE utf8mb4_zh_0900_as_cs NOT NULL,
3737
PRIMARY KEY (`id`) USING BTREE
@@ -41,6 +41,6 @@ CREATE TABLE `details` (
4141
-- View structure for changes_ext
4242
-- ----------------------------
4343
DROP VIEW IF EXISTS `changes_ext`;
44-
CREATE ALGORITHM = MERGE SQL SECURITY DEFINER VIEW `changes_ext` AS select `c`.`code` AS `code`,`p`.`name` AS `name`,`p`.`start` AS `start`,`c`.`new_code` AS `new_code`,`s`.`name` AS `new_name`,`s`.`start` AS `new_start`,`c`.`time` AS `time`,`c`.`details_id` AS `details_id` from ((`changes` `c` join `codes` `p` on(((`p`.`code` = `c`.`code`) and ((`c`.`time` - 1) >= `p`.`start`) and ((`p`.`end` is null) or ((`c`.`time` - 1) < `p`.`end`))))) join `codes` `s` on(((`s`.`code` = `c`.`new_code`) and (`c`.`time` >= `s`.`start`) and ((`s`.`end` is null) or (`c`.`time` < `s`.`end`)))));
44+
CREATE ALGORITHM = MERGE SQL SECURITY DEFINER VIEW `changes_ext` AS select `c`.`code` AS `code`,`p`.`name` AS `name`,`p`.`start` AS `start`,`c`.`new_code` AS `new_code`,`s`.`name` AS `new_name`,`s`.`start` AS `new_start`,`c`.`time` AS `time`,`c`.`desc_id` AS `desc_id` from ((`changes` `c` join `codes` `p` on(((`p`.`code` = `c`.`code`) and ((`c`.`time` - 1) >= `p`.`start`) and ((`p`.`end` is null) or ((`c`.`time` - 1) < `p`.`end`))))) join `codes` `s` on(((`s`.`code` = `c`.`new_code`) and (`c`.`time` >= `s`.`start`) and ((`s`.`end` is null) or (`c`.`time` < `s`.`end`)))));
4545

4646
SET FOREIGN_KEY_CHECKS = 1;

sql/details.sql sql/descriptions.sql

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
BEGIN;
2-
INSERT INTO `details` (`text`) VALUES
2+
INSERT INTO `descriptions` (`text`) VALUES
33
('# 黑龙江省民政厅关于同意七台河市设立兴北镇由新兴区划归茄子河区管辖的批复(黑民行批〔2022〕7号)
44
55
同意新兴区设立兴北镇,隶属关系由新兴区划归茄子河区管辖。镇人民政府驻北兴农场四委108栋362号。兴北镇的行政区划代码为230904102。
@@ -116,16 +116,16 @@ INSERT INTO `details` (`text`) VALUES
116116
来源:[新疆维吾尔自治区人民政府网站](https://www.xinjiang.gov.cn/xinjiang/tzgg/202301/8bd4c6578fae4c469680d068c187c7b0.shtml)');
117117
SET @id = LAST_INSERT_ID();
118118

119-
UPDATE `changes` SET `details_id` = @id WHERE (`code`, `new_code`, `time`) = (230902, 230904, 2022);
120-
UPDATE `changes` SET `details_id` = @id := @id + 1 WHERE (`code`, `new_code`, `time`) = (360112, 360113, 2022);
121-
UPDATE `changes` SET `details_id` = @id := @id + 1 WHERE (`code`, `new_code`, `time`) = (410223, 410184, 2022);
119+
UPDATE `changes` SET `desc_id` = @id WHERE (`code`, `new_code`, `time`) = (230902, 230904, 2022);
120+
UPDATE `changes` SET `desc_id` = @id := @id + 1 WHERE (`code`, `new_code`, `time`) = (360112, 360113, 2022);
121+
UPDATE `changes` SET `desc_id` = @id := @id + 1 WHERE (`code`, `new_code`, `time`) = (410223, 410184, 2022);
122122
SET @id = @id + 1;
123-
UPDATE `changes` SET `details_id` = @id WHERE (`code`, `new_code`, `time`) IN ((620122, 620102, 2022), (620122, 620105, 2022));
124-
UPDATE `changes` SET `details_id` = @id := @id + 1 WHERE (`code`, `new_code`, `time`) = (640122, 640106, 2022);
125-
UPDATE `changes` SET `details_id` = @id := @id + 1 WHERE (`code`, `new_code`, `time`) = (511525, 511526, 2023);
126-
UPDATE `changes` SET `details_id` = @id := @id + 1 WHERE (`code`, `new_code`, `time`) = (530602, 530624, 2023);
127-
UPDATE `changes` SET `details_id` = @id := @id + 1 WHERE (`code`, `new_code`, `time`) = (540422, 540481, 2023);
128-
UPDATE `changes` SET `details_id` = @id := @id + 1 WHERE (`code`, `new_code`, `time`) = (540530, 540581, 2023);
129-
UPDATE `changes` SET `details_id` = @id := @id + 1 WHERE (`code`, `new_code`, `time`) = (620121, 620122, 2023);
130-
UPDATE `changes` SET `details_id` = @id := @id + 1 WHERE (`code`, `new_code`, `time`) = (650000, 659012, 2023);
123+
UPDATE `changes` SET `desc_id` = @id WHERE (`code`, `new_code`, `time`) IN ((620122, 620102, 2022), (620122, 620105, 2022));
124+
UPDATE `changes` SET `desc_id` = @id := @id + 1 WHERE (`code`, `new_code`, `time`) = (640122, 640106, 2022);
125+
UPDATE `changes` SET `desc_id` = @id := @id + 1 WHERE (`code`, `new_code`, `time`) = (511525, 511526, 2023);
126+
UPDATE `changes` SET `desc_id` = @id := @id + 1 WHERE (`code`, `new_code`, `time`) = (530602, 530624, 2023);
127+
UPDATE `changes` SET `desc_id` = @id := @id + 1 WHERE (`code`, `new_code`, `time`) = (540422, 540481, 2023);
128+
UPDATE `changes` SET `desc_id` = @id := @id + 1 WHERE (`code`, `new_code`, `time`) = (540530, 540581, 2023);
129+
UPDATE `changes` SET `desc_id` = @id := @id + 1 WHERE (`code`, `new_code`, `time`) = (620121, 620122, 2023);
130+
UPDATE `changes` SET `desc_id` = @id := @id + 1 WHERE (`code`, `new_code`, `time`) = (650000, 659012, 2023);
131131
COMMIT;

0 commit comments

Comments
 (0)