From f8d7e71f2b2851e77e3994bb6aa49f5ea577138e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B5=A9=E5=AE=87?= <37102468+HaoyuLee@users.noreply.github.com> Date: Thu, 17 Oct 2024 22:59:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20route=20=E2=80=98/gov/zj/search/:website?= =?UTF-8?q?id=3F/:word/:cateid=3F=E2=80=99=20result.item=20deduplication?= =?UTF-8?q?=20(#16730)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 宁波市人力资源保障局-某分类-公告列表 * feat: 宁波国资委-某分类-公告列表 * Update lib/routes/gov/zj/ningborsjnotice.ts Co-authored-by: Tony * Update lib/routes/gov/zj/ningbogzw-notice.ts Co-authored-by: Tony * Update lib/routes/gov/zj/ningbogzw-notice.ts Co-authored-by: Tony * Update lib/routes/gov/zj/ningborsjnotice.ts Co-authored-by: Tony * fix: description content indent update * fix: route ‘/gov/zj/search/:websiteid?/:word/:cateid?’ result.item deduplication * fix: route ‘/gov/zj/search/:websiteid?/:word/:cateid?’ result.item deduplication --------- --- lib/routes/gov/zj/search.ts | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/routes/gov/zj/search.ts b/lib/routes/gov/zj/search.ts index e3f2942fa..e8c0bd9ef 100644 --- a/lib/routes/gov/zj/search.ts +++ b/lib/routes/gov/zj/search.ts @@ -1,9 +1,8 @@ -import { Route } from '@/types'; +import { Route, DataItem } from '@/types'; import { parseDate } from '@/utils/parse-date'; import got from '@/utils/got'; import { load } from 'cheerio'; import dayjs from 'dayjs'; - export const route: Route = { path: '/zj/search/:websiteid?/:word/:cateid?', categories: ['government'], @@ -24,18 +23,18 @@ export const route: Route = { url: 'search.zj.gov.cn/jsearchfront/search.do', maintainers: ['HaoyuLee'], description: ` - | 行政区域 | websiteid | - | ------------ | -- | - | 宁波市本级 | 330201000000000 | +| 行政区域 | websiteid | +| ------------ | -- | +| 宁波市本级 | 330201000000000 | - | 搜索关键词 | word | +| 搜索关键词 | word | - | 信息分类 | cateid | +| 信息分类 | cateid | - | 排序类型 | sortType | - | ------------ | -- | - | 按相关度 | 1 | - | 按时间 | 2 | +| 排序类型 | sortType | +| ------------ | -- | +| 按相关度 | 1 | +| 按时间 | 2 | `, async handler(ctx) { const { websiteid = '330201000000000', word = '人才', cateid = 658, sortType = 2 } = ctx.req.param(); @@ -71,10 +70,16 @@ export const route: Route = { description: $('.newsDescribe>a').text() || '', }; }) || []; + const res = {}; + for (const current of items) { + if (!res[current.link]) { + res[current.link] = current; + } + } return { title: '浙江省人民政府-全省政府网站统一搜索', link: 'https://search.zj.gov.cn/jsearchfront/search.do', - item: items, + item: Object.entries(res).map(([, value]) => value) as DataItem[], }; }, };