From 8b7ac00eabff7cfe22babad304b776129fc8d6a3 Mon Sep 17 00:00:00 2001 From: Loyio Date: Sun, 24 Jan 2021 11:38:37 +0800 Subject: [PATCH] feat: add wtu route (#6766) --- docs/university.md | 13 +++++++++++ lib/router.js | 3 +++ lib/routes/universities/wtu/index.js | 34 ++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 lib/routes/universities/wtu/index.js diff --git a/docs/university.md b/docs/university.md index 631871083..45ca69426 100644 --- a/docs/university.md +++ b/docs/university.md @@ -1632,6 +1632,19 @@ type 列表: +## 武汉纺织大学 + +### 信息门户公告 + + + +| 公告类型 | 通知公告 | 教务信息 | 科研动态 | +| -------- | -------- | -------- | -------- | +| 参数 | 1 | 2 | 3 | + + + ## 西安电子科技大学 ### 教务处 diff --git a/lib/router.js b/lib/router.js index fc40fd535..41506a7cc 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3905,4 +3905,7 @@ router.get('/thrillist/:tag?', require('./routes/thrillist/index')); // 丁香园 router.get('/dxy/vaccine/:province?/:city?/:location?', require('./routes/dxy/vaccine')); +// Wtu +router.get('/wtu/:type', require('./routes/universities/wtu')); + module.exports = router; diff --git a/lib/routes/universities/wtu/index.js b/lib/routes/universities/wtu/index.js new file mode 100644 index 000000000..3aff51207 --- /dev/null +++ b/lib/routes/universities/wtu/index.js @@ -0,0 +1,34 @@ +const got = require('@/utils/got'); + +const apiUrl = 'http://ehall.wtu.edu.cn/wtu/api/queryBulletinListByConditional.do?pageNum=1&pageSize=8&columnId='; +const listUrl = 'http://ehall.wtu.edu.cn/new/list.html?type='; +const psgUrl = 'http://ehall.wtu.edu.cn/new/detail-word.html?'; +const map = new Map([ + [1, { title: '通知公告', type: '2', id: '1994a3b58bef4ee887e1efc19881decd' }], + [2, { title: '教务信息', type: '5', id: '36d47fcd3e774f289adfef1d93138a9d' }], + [3, { title: '科研动态', type: '3', id: '48e8abfb983b4e4486b69feacad1dc1b' }], +]); + +module.exports = async (ctx) => { + const typein = Number.parseInt(ctx.params.type); + const title = map.get(typein).title; + const columnId = map.get(typein).id; + const type = map.get(typein).type; + const res = await got({ + method: 'get', + url: apiUrl + `${columnId}`, + }); + const res_json = res.data.bulletinList; + + ctx.state.data = { + title: `${title} - 武汉纺织大学信息门户`, + link: listUrl + `${type}`, + description: `${title} - 武汉纺织大学信息门户`, + item: res_json.map((item) => ({ + title: item.TITLE, + description: item.TITLE, + pubDate: new Date(item.CREATE_TIME).toUTCString(), + link: psgUrl + `type=` + `${type}` + `?bulletinId=` + item.WID, + })), + }; +};