From d2d115da42af13f43562de34239748b3fab55576 Mon Sep 17 00:00:00 2001 From: Ethan Shen <42264778+nczitzk@users.noreply.github.com> Date: Mon, 25 Dec 2023 00:32:27 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E4=B8=AD=E5=9B=BD?= =?UTF-8?q?=E6=B0=91=E7=94=A8=E8=88=AA=E7=A9=BA=E5=B1=80=E5=85=AC=E4=BC=97?= =?UTF-8?q?=E7=95=99=E8=A8=80=20(#14109)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/v2/gov/caac/cjwt.js | 56 +++++++++++++++++++++++ lib/v2/gov/caac/templates/description.art | 25 ++++++++++ lib/v2/gov/maintainer.js | 1 + lib/v2/gov/radar.js | 47 +++++++++++++++++++ lib/v2/gov/router.js | 1 + website/docs/routes/government.mdx | 9 ++++ 6 files changed, 139 insertions(+) create mode 100644 lib/v2/gov/caac/cjwt.js create mode 100644 lib/v2/gov/caac/templates/description.art diff --git a/lib/v2/gov/caac/cjwt.js b/lib/v2/gov/caac/cjwt.js new file mode 100644 index 0000000000..7b3952e9c7 --- /dev/null +++ b/lib/v2/gov/caac/cjwt.js @@ -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, + }; +}; diff --git a/lib/v2/gov/caac/templates/description.art b/lib/v2/gov/caac/templates/description.art new file mode 100644 index 0000000000..3e87d92712 --- /dev/null +++ b/lib/v2/gov/caac/templates/description.art @@ -0,0 +1,25 @@ +
+
+
+ + {{ item.workUnit }} + {{ item.gname }} + {{ item.createDate }} +
+
+

+ {{@ item.infoMess }} +

+
+
+ + {{ item.feedbackName }} + {{ item.feedbackDate }} +
+
+

+ {{@ item.feedback }} +

+
+
+
\ No newline at end of file diff --git a/lib/v2/gov/maintainer.js b/lib/v2/gov/maintainer.js index 10c44c9839..cfbb2c6a8d 100644 --- a/lib/v2/gov/maintainer.js +++ b/lib/v2/gov/maintainer.js @@ -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'], diff --git a/lib/v2/gov/radar.js b/lib/v2/gov/radar.js index 94eb35f293..8b805f8a3b 100644 --- a/lib/v2/gov/radar.js +++ b/lib/v2/gov/radar.js @@ -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: [ diff --git a/lib/v2/gov/router.js b/lib/v2/gov/router.js index 42b1a5ab50..6572098433 100644 --- a/lib/v2/gov/router.js +++ b/lib/v2/gov/router.js @@ -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')); diff --git a/website/docs/routes/government.mdx b/website/docs/routes/government.mdx index 6d50828dc2..f145805118 100644 --- a/website/docs/routes/government.mdx +++ b/website/docs/routes/government.mdx @@ -1308,6 +1308,15 @@ +## 中国民用航空局 {#zhong-guo-min-yong-hang-kong-ju} + +### 公众留言 {#zhong-guo-min-yong-hang-kong-ju-gong-zhong-liu-yan} + + + | 机票 | 托运 | 无人机 | 体检 | 行政审批 | 投诉 | + | ---- | ---- | ------ | ---- | -------- | ---- | + + ## 中国农工民主党 {#zhong-guo-nong-gong-min-zhu-dang} ### 新闻中心 {#zhong-guo-nong-gong-min-zhu-dang-xin-wen-zhong-xin}