From dde8e881067c5173a94694887aed039c96a77da4 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Fri, 16 Jan 2026 15:15:36 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/controller/UsedCarController.php | 14 ++++++++++++++ app/common/service/UsedCarService.php | 11 +++++++++++ config/route.php | 1 + 3 files changed, 26 insertions(+) diff --git a/app/common/controller/UsedCarController.php b/app/common/controller/UsedCarController.php index c0c14b3..688999d 100644 --- a/app/common/controller/UsedCarController.php +++ b/app/common/controller/UsedCarController.php @@ -43,6 +43,20 @@ class UsedCarController extends BaseController $this->service = new UsedCarService(); } + /** + * 更新状态 + * @return \support\Response + */ + public function status(Request $request){ + try { + $data = $request->post(); + $res = $this->service->serviceUpdateStatus($request, $data); + return $this->success([], '更新成功'); + } catch (\Throwable $e) { + return $this->error($e->getMessage()); + } + } + /** * 列表页数据格式化 * diff --git a/app/common/service/UsedCarService.php b/app/common/service/UsedCarService.php index 68c13ea..853b98a 100644 --- a/app/common/service/UsedCarService.php +++ b/app/common/service/UsedCarService.php @@ -132,6 +132,17 @@ class UsedCarService return $data; } + public function serviceUpdateStatus(Request $request, array $data) + { + if (empty($data['id'])) { + throw new BusinessException('id不能为空'); + } + if (!isset($data['status'])) { + throw new BusinessException('status错误'); + } + return UsedCar::where('id', $data['id'])->update(['status' => $data['status']]); + } + public function getcode($userId){ $userCount = Redis::get('used_car_count_'.$userId, 0); $todayStart = strtotime('today'); diff --git a/config/route.php b/config/route.php index 9748ad1..8af7574 100644 --- a/config/route.php +++ b/config/route.php @@ -64,6 +64,7 @@ Route::group('/common', function () { Route::any('/show', [app\common\controller\UsedCarController::class, 'show']); Route::any('/store', [app\common\controller\UsedCarController::class, 'store']); Route::any('/update', [app\common\controller\UsedCarController::class, 'update']); + Route::any('/update/status', [app\common\controller\UsedCarController::class, 'status']); Route::any('/destroy', [app\common\controller\UsedCarController::class, 'destroy']); Route::any('/crawl', [app\common\controller\UsedCarController::class, 'crawlKeyword']); });