Skip to content

Commit

Permalink
feat(route): add 中国民用航空局公众留言 (#14109)
Browse files Browse the repository at this point in the history
  • Loading branch information
nczitzk authored Dec 24, 2023
1 parent 26d4afc commit d2d115d
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 0 deletions.
56 changes: 56 additions & 0 deletions lib/v2/gov/caac/cjwt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const got = require('@/utils/got');
const timezone = require('@/utils/timezone');
const { parseDate } = require('@/utils/parse-date');
const { art } = require('@/utils/render');
const path = require('path');

module.exports = async (ctx) => {
const { category = '' } = ctx.params;
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 30;

const rootUrl = 'https://www.caac.gov.cn';
const apiUrl = new URL(`caacgov/jsonp/messageBoard/visit/get${category ? 'CJWT' : ''}List`, rootUrl).href;
const currentUrl = new URL('HDJL/', rootUrl).href;

const { data: response } = await got(apiUrl, {
searchParams: {
callbackparam: 'jsonp_messageBoard_getList',
infoMess: category,
pageIndex: 1,
},
});

const items = JSON.parse(response.match(/jsonp_messageBoard_getList\((.*?)\)$/)[1])
.returnData.root.slice(0, limit)
.map((item) => ({
title: item.infoMess.replace(/<\/?em>/g, ''),
link: new URL(`index_180.html?info=${item.id}&type=id`, rootUrl).href,
description: art(path.join(__dirname, 'templates/description.art'), {
item,
}),
author: `${item.gname}/${item.feedbackName}`,
category: [item.messageType],
guid: `caac-cjwt#${item.id}`,
pubDate: timezone(parseDate(item.createDate), +8),
updated: timezone(parseDate(item.feedbackDate), +8),
}));

const author = '中国民用航空局';
const image = new URL('images/Logo2.png', rootUrl).href;
const icon = new URL('images/weixinLogo.jpg', rootUrl).href;
const subtitle = '公众留言';

ctx.state.data = {
item: items,
title: [author, subtitle, category].filter((i) => i).join(' - '),
link: currentUrl,
description: '向公众提供服务和开展互动交流',
language: 'zh',
image,
icon,
logo: icon,
subtitle,
author,
allowEmpty: true,
};
};
25 changes: 25 additions & 0 deletions lib/v2/gov/caac/templates/description.art
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<div>
<dl>
<dt>
<label>【{{ item.messageType }}】</label>
<span>{{ item.workUnit }}</span>
<span>{{ item.gname }}</span>
<span>{{ item.createDate }}</span>
</dt>
<dd style="margin-top:10px; color:#EF7321;">
<p style="text-indent:1em;">
{{@ item.infoMess }}
</p>
</dd>
<dt width="140px">
<label>【回复】</label>
<span>{{ item.feedbackName }}</span>
<span>{{ item.feedbackDate }}</span>
</dt>
<dd>
<p style="text-indent:1em;">
{{@ item.feedback }}
</p>
</dd>
</dl>
</div>
1 change: 1 addition & 0 deletions lib/v2/gov/maintainer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {
// ministry
'/cac/:path+': ['drgnchan'],
'/caac/cjwt/:category?': ['nczitzk'],
'/ccdi/:path+': ['bigfei'],
'/chinamine-safety/zfxxgk/:category?': ['nczitzk'],
'/chinamine-safety/xw/:category?': ['nczitzk'],
Expand Down
47 changes: 47 additions & 0 deletions lib/v2/gov/radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,53 @@ module.exports = {
},
],
},
'caac.gov.cn': {
_name: '中国民用航空局',
'.': [
{
title: '公众留言',
docs: 'https://docs.rsshub.app/routes/government#zhong-guo-min-yong-hang-kong-ju-gong-zhong-liu-yan',
source: ['/HDJL/'],
target: '/gov/caac/cjwt',
},
{
title: '公众留言 - 机票',
docs: 'https://docs.rsshub.app/routes/government#zhong-guo-min-yong-hang-kong-ju-gong-zhong-liu-yan',
source: ['/HDJL/'],
target: '/gov/caac/cjwt/机票',
},
{
title: '公众留言 - 托运',
docs: 'https://docs.rsshub.app/routes/government#zhong-guo-min-yong-hang-kong-ju-gong-zhong-liu-yan',
source: ['/HDJL/'],
target: '/gov/caac/cjwt/托运',
},
{
title: '公众留言 - 无人机',
docs: 'https://docs.rsshub.app/routes/government#zhong-guo-min-yong-hang-kong-ju-gong-zhong-liu-yan',
source: ['/HDJL/'],
target: '/gov/caac/cjwt/无人机',
},
{
title: '公众留言 - 体检',
docs: 'https://docs.rsshub.app/routes/government#zhong-guo-min-yong-hang-kong-ju-gong-zhong-liu-yan',
source: ['/HDJL/'],
target: '/gov/caac/cjwt/体检',
},
{
title: '公众留言 - 行政审批',
docs: 'https://docs.rsshub.app/routes/government#zhong-guo-min-yong-hang-kong-ju-gong-zhong-liu-yan',
source: ['/HDJL/'],
target: '/gov/caac/cjwt/行政审批',
},
{
title: '公众留言 - 投诉',
docs: 'https://docs.rsshub.app/routes/government#zhong-guo-min-yong-hang-kong-ju-gong-zhong-liu-yan',
source: ['/HDJL/'],
target: '/gov/caac/cjwt/投诉',
},
],
},
'ccdi.gov.cn': {
_name: '中央纪委国家监委',
www: [
Expand Down
1 change: 1 addition & 0 deletions lib/v2/gov/router.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = function (router) {
// ministry
router.get(/cac(\/[\w/-]+)?/, require('./cac/index'));
router.get('/caac/cjwt/:category?', require('./caac/cjwt'));
router.get(/ccdi(\/[\w/-]+)?/, require('./ccdi'));
router.get('/chinamine-safety/zfxxgk/:category*', require('./chinamine-safety/zfxxgk'));
router.get('/chinamine-safety/xw/:category*', require('./chinamine-safety/xw'));
Expand Down
9 changes: 9 additions & 0 deletions website/docs/routes/government.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,15 @@

<Route author="TonyRL" example="/cast" path="/cast/:column?" paramsDesc={['栏目 ID,即 URL 中的数字,默认为 `457`']} radar="1" notOperational="1" />

## 中国民用航空局 {#zhong-guo-min-yong-hang-kong-ju}

### 公众留言 {#zhong-guo-min-yong-hang-kong-ju-gong-zhong-liu-yan}

<Route author="nczitzk" example="/gov/caac/cjwt" path="/gov/caac/cjwt/:category?" paramsDesc={['分类,见下表,默认为全部']} radar="1">
| 机票 | 托运 | 无人机 | 体检 | 行政审批 | 投诉 |
| ---- | ---- | ------ | ---- | -------- | ---- |
</Route>

## 中国农工民主党 {#zhong-guo-nong-gong-min-zhu-dang}

### 新闻中心 {#zhong-guo-nong-gong-min-zhu-dang-xin-wen-zhong-xin}
Expand Down

0 comments on commit d2d115d

Please sign in to comment.