From aa6c242237ac7290e00e3879a3de7d451664c5e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=BF=97?= Date: Tue, 20 Jan 2026 17:17:25 +0800 Subject: [PATCH] update --- app/controller/Crawler.php | 69 +++++++++++++++++++++++++++++++++ route/app.php | 1 + view/crawler/index.html | 78 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 148 insertions(+) diff --git a/app/controller/Crawler.php b/app/controller/Crawler.php index 76d09eb..cb6803f 100644 --- a/app/controller/Crawler.php +++ b/app/controller/Crawler.php @@ -248,6 +248,75 @@ class Crawler extends BaseController } } + /** + * 自动获取全部职位代码并返回职位详情(无需手动勾选) + */ + public function fetchAllPositions() + { + try { + $dsdm = $this->request->param('dsdm', ''); + $examid = $this->request->param('examid', ''); + $bmid = $this->request->param('bmid', ''); + $userid = $this->request->param('userid', ''); + $aa = $this->request->param('aa', ''); + $cookiesParam = $this->request->param('cookies', ''); + + if (empty($dsdm) || empty($examid) || empty($bmid) || empty($userid) || empty($aa)) { + return json([ + 'code' => 0, + 'msg' => '请填写examid、bmid、userid、dsdm,并先获取地区选项生成aa', + ]); + } + + if (empty($cookiesParam)) { + return json([ + 'code' => 0, + 'msg' => '请填写Cookie数据', + ]); + } + + $cookies = is_string($cookiesParam) ? json_decode($cookiesParam, true) : $cookiesParam; + if (json_last_error() !== JSON_ERROR_NONE || empty($cookies)) { + return json([ + 'code' => 0, + 'msg' => 'Cookie数据格式错误,请检查JSON格式', + ]); + } + + $service = new CrawlerService(); + $treeData = $service->getPositionTree($dsdm, $examid, $bmid, $userid, (string)$aa, $cookies); + + $zwdmList = []; + if (is_array($treeData)) { + foreach ($treeData as $item) { + if (isset($item['CODE']) && !empty($item['CODE'])) { + $zwdmList[] = $item['CODE']; + } + } + } + + if (empty($zwdmList)) { + return json([ + 'code' => 0, + 'msg' => '未获取到职位代码', + ]); + } + + $results = $service->batchGetPositionInfo($zwdmList, $examid, $cookies); + + return json([ + 'code' => 1, + 'data' => $results, + 'msg' => '获取成功', + ]); + } catch (\Exception $e) { + return json([ + 'code' => 0, + 'msg' => '获取失败: ' . $e->getMessage(), + ]); + } + } + /** * 获取职位详细信息 */ diff --git a/route/app.php b/route/app.php index d8467ca..e840dc7 100644 --- a/route/app.php +++ b/route/app.php @@ -22,3 +22,4 @@ Route::post('crawler/getDsdmOptions', 'crawler/getDsdmOptions'); Route::post('crawler/getZwdmList', 'crawler/getZwdmList'); Route::post('crawler/getPositionInfo', 'crawler/getPositionInfo'); Route::post('crawler/batchGetPositionInfo', 'crawler/batchGetPositionInfo'); +Route::post('crawler/fetchAllPositions', 'crawler/fetchAllPositions'); \ No newline at end of file diff --git a/view/crawler/index.html b/view/crawler/index.html index 8071a7b..a971f7f 100644 --- a/view/crawler/index.html +++ b/view/crawler/index.html @@ -344,6 +344,7 @@