Skip to content

Commit 75c718a

Browse files
authored
feat(route): add 国家外汇管理局业务咨询 & 投诉建议 (#13995)
1 parent faefb73 commit 75c718a

File tree

8 files changed

+208
-0
lines changed

8 files changed

+208
-0
lines changed

lib/v2/gov/maintainer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ module.exports = {
4949
'/pbc/tradeAnnouncement': ['nczitzk'],
5050
'/pbc/zcyj': ['Fatpandac'],
5151
'/samr/xgzlyhd/:category?/:department?': ['nczitzk'],
52+
'/safe/bussiness/:site?': ['nczitzk'],
53+
'/safe/complaint/:site?': ['nczitzk'],
5254
'/sasac/:path+': ['TonyRL'],
5355
'/stats/:path+': ['bigfei', 'nczitzk'],
5456
'/zhengce/govall/:advance?': ['ciaranchen'],

lib/v2/gov/radar.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,31 @@ module.exports = {
11851185
},
11861186
],
11871187
},
1188+
'safe.gov.cn': {
1189+
_name: '国家外汇管理局',
1190+
'.': [
1191+
{
1192+
title: '业务咨询',
1193+
docs: 'https://docs.rsshub.app/routes/government#guo-jia-wai-hui-guan-li-ju-ye-wu-zi-xun',
1194+
source: ['/:site/ywzx/index.html'],
1195+
target: (params) => {
1196+
const site = params.site;
1197+
1198+
return `/gov/safe/business/${site}`;
1199+
},
1200+
},
1201+
{
1202+
title: '投诉建议',
1203+
docs: 'https://docs.rsshub.app/routes/government#guo-jia-wai-hui-guan-li-ju-tou-su-jian-yi',
1204+
source: ['/:site/tsjy/index.html'],
1205+
target: (params) => {
1206+
const site = params.site;
1207+
1208+
return `/gov/safe/complaint/${site}`;
1209+
},
1210+
},
1211+
],
1212+
},
11881213
'sasac.gov.cn': {
11891214
_name: '国务院国有资产监督管理委员会',
11901215
'.': [

lib/v2/gov/router.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ module.exports = function (router) {
4141
router.get('/pbc/gzlw', require('./pbc/gzlw'));
4242
router.get('/pbc/tradeAnnouncement', require('./pbc/tradeAnnouncement'));
4343
router.get('/pbc/zcyj', require('./pbc/zcyj'));
44+
router.get('/safe/business/:site?', require('./safe/business'));
45+
router.get('/safe/complaint/:site?', require('./safe/complaint'));
4446
router.get('/samr/xgzlyhd/:category?/:department?', require('./samr/xgzlyhd'));
4547
router.get('/sasac/:path+', require('./sasac/generic'));
4648
router.get(/stats(\/[\w/-]+)?/, require('./stats'));

lib/v2/gov/safe/business.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const { processZxfkItems } = require('./util');
2+
3+
module.exports = async (ctx) => {
4+
const { site = 'beijing' } = ctx.params;
5+
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 3;
6+
7+
ctx.state.data = await processZxfkItems(site, 'ywzx', limit);
8+
};

lib/v2/gov/safe/complaint.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const { processZxfkItems } = require('./util');
2+
3+
module.exports = async (ctx) => {
4+
const { site = 'beijing' } = ctx.params;
5+
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 5;
6+
7+
ctx.state.data = await processZxfkItems(site, 'tsjy', limit);
8+
};

lib/v2/gov/safe/templates/message.art

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<table>
2+
<tbody>
3+
<tr>
4+
<th>留言人</th>
5+
<th>留言内容</th>
6+
<th>留言时间</th>
7+
</tr>
8+
{{ if message }}
9+
{{ set object = message }}
10+
<tr>
11+
<td>{{ object.author }}</td>
12+
<td>{{ object.content }}</td>
13+
<td>{{ object.date }}</td>
14+
</tr>
15+
{{ /if }}
16+
{{ if reply }}
17+
{{ set object = reply }}
18+
<tr style="color: #0069ae;">
19+
<td>{{ object.author }}</td>
20+
<td>{{ object.content }}</td>
21+
<td>{{ object.date }}</td>
22+
</tr>
23+
{{ /if }}
24+
</tbody>
25+
</table>

lib/v2/gov/safe/util.js

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
const got = require('@/utils/got');
2+
const cheerio = require('cheerio');
3+
const { parseDate } = require('@/utils/parse-date');
4+
const { art } = require('@/utils/render');
5+
const path = require('path');
6+
7+
const rootUrl = 'https://www.safe.gov.cn';
8+
9+
const zxfkCategoryApis = {
10+
// 业务咨询 https://www.safe.gov.cn/<site>/ywzx/index.html
11+
ywzx: 'www/busines/businessQuery?siteid=',
12+
13+
// 投诉建议 https://www.safe.gov.cn/<site>/tsjy/index.html
14+
tsjy: 'www/complaint/complaintQuery?siteid=',
15+
};
16+
17+
const processZxfkItems = async (site = 'beijing', category = 'ywzx', limit = '3') => {
18+
const apiUrl = new URL(`${zxfkCategoryApis[category]}${site}`, rootUrl).href;
19+
const currentUrl = new URL(`${site}/${category}/index.html`, rootUrl).href;
20+
21+
const { data: response } = await got(apiUrl);
22+
23+
const $ = cheerio.load(response);
24+
25+
const items = $('#complaint')
26+
.slice(0, limit)
27+
.toArray()
28+
.map((item) => {
29+
item = $(item);
30+
31+
const spans = item.find('span[objid]');
32+
33+
const message = {
34+
author: spans.first().text().replace(/:$/, ''),
35+
content: spans.eq(1).text(),
36+
date: spans.eq(2).text(),
37+
};
38+
39+
const reply = {
40+
author: spans.eq(3).text().replace(/:$/, ''),
41+
content: spans.eq(4).text(),
42+
date: spans.eq(5).text(),
43+
};
44+
45+
return {
46+
title: `${message.author}: ${message.content}`,
47+
link: new URL(item.find('.title').prop('href'), rootUrl).href,
48+
description: art(path.join(__dirname, 'templates/message.art'), {
49+
message,
50+
reply,
51+
}),
52+
author: `${message.author}/${reply.author}`,
53+
guid: item.find('.id').text(),
54+
pubDate: parseDate(message.date),
55+
updated: parseDate(reply.date),
56+
};
57+
});
58+
59+
const { data: currentResponse } = await got(currentUrl);
60+
61+
const content = cheerio.load(currentResponse);
62+
63+
const author = content('meta[name="ColumnName"]').prop('content');
64+
const subtitle = content('meta[name="ColumnType"]').prop('content');
65+
66+
const imagePath = 'safe/templateresource/372b1dfdab204181b9b4f943a8e926a6';
67+
const image = new URL(`${imagePath}/logo_06.png`, rootUrl).href;
68+
const icon = new URL(`${imagePath}/safe.ico`, rootUrl).href;
69+
70+
return {
71+
item: items,
72+
title: `${author} - ${subtitle}`,
73+
link: currentUrl,
74+
description: content('meta[name="ColumnDescription"]').prop('content'),
75+
language: 'zh',
76+
image,
77+
icon,
78+
logo: icon,
79+
subtitle,
80+
author,
81+
allowEmpty: true,
82+
};
83+
};
84+
85+
module.exports = {
86+
processZxfkItems,
87+
};

website/docs/routes/government.mdx

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,57 @@ Language
618618

619619
</Route>
620620

621+
## 国家外汇管理局 {#guo-jia-wai-hui-guan-li-ju}
622+
623+
<details>
624+
<summary>*业务咨询**投诉建议* 可用的站点参数</summary>
625+
626+
| 上海市 | 北京市 | 天津市 | 河北省 |
627+
| -------- | ------- | ------- | ----- |
628+
| shanghai | beijing | tianjin | hebei |
629+
630+
| 山西省 | 内蒙古自治区 | 辽宁省 | 吉林省 |
631+
| ------ | --------- | -------- | ----- |
632+
| shanxi | neimenggu | liaoning | jilin |
633+
634+
| 黑龙江省 | 江苏省 | 浙江省 | 安徽省 |
635+
| ------------ | ------- | -------- | ----- |
636+
| heilongjiang | jiangsu | zhejiang | anhui |
637+
638+
| 福建省 | 江西省 | 山东省 | 河南省 |
639+
| ------ | ------- | -------- | ----- |
640+
| fujian | jiangxi | shandong | henan |
641+
642+
| 湖北省 | 湖南省 | 广东省 | 广西壮族自治区 |
643+
| ----- | ----- | --------- | ------- |
644+
| hubei | hunan | guangdong | guangxi |
645+
646+
| 海南省 | 重庆市 | 四川省 | 贵州省 |
647+
| ------ | --------- | ------- | ------- |
648+
| hainan | chongqing | sichuan | guizhou |
649+
650+
| 云南省 | 西藏自治区 | 陕西省 | 甘肃省 |
651+
| ------ | ------ | ------- | ----- |
652+
| yunnan | xizang | shaanxi | gansu |
653+
654+
| 青海省 | 宁夏回族自治区 | 新疆维吾尔自治区 | 大连市 |
655+
| ------- | ------- | -------- | ------ |
656+
| qinghai | ningxia | xinjiang | dalian |
657+
658+
| 宁波市 | 厦门市 | 青岛市 | 深圳市 |
659+
| ------ | ------ | ------- | -------- |
660+
| ningbo | xiamen | qingdao | shenzhen |
661+
662+
</details>
663+
664+
### 业务咨询 {#guo-jia-wai-hui-guan-li-ju-ye-wu-zi-xun}
665+
666+
<Route author="nczitzk" example="/gov/safe/business/beijing" path="/gov/safe/business/:site?" paramsDesc={['站点,见上表,默认为 beijing']} radar="1"/>
667+
668+
### 投诉建议 {#guo-jia-wai-hui-guan-li-ju-tou-su-jian-yi}
669+
670+
<Route author="nczitzk" example="/gov/safe/complaint/beijing" path="/gov/safe/complaint/:site?" paramsDesc={['站点,见上表,默认为 beijing']} radar="1"/>
671+
621672
## 国家新闻出版广电总局(弃用) {#guo-jia-xin-wen-chu-ban-guang-dian-zong-ju-qi-yong}
622673

623674
### 游戏审批结果 {#guo-jia-xin-wen-chu-ban-guang-dian-zong-ju-qi-yong-you-xi-shen-pi-jie-guo}

0 commit comments

Comments
 (0)