From fe3c27cb67108128821fa3d3e54a8cb2b5851fbf Mon Sep 17 00:00:00 2001 From: cody <648753004@qq.com> Date: Sun, 10 Aug 2025 10:26:06 +0800 Subject: [PATCH 1/5] update --- app/Http/Controllers/Admin/SupplyDemandController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Http/Controllers/Admin/SupplyDemandController.php b/app/Http/Controllers/Admin/SupplyDemandController.php index aeb55d0..018b1a9 100755 --- a/app/Http/Controllers/Admin/SupplyDemandController.php +++ b/app/Http/Controllers/Admin/SupplyDemandController.php @@ -267,6 +267,7 @@ class SupplyDemandController extends BaseController $interactionGrowthRate = $this->calculateGrowthRate($interactionCount, $prevInteractionCount); return $this->success([ + 'supplyDemand' => $supplyDemand, 'supply_demand_count' => $supplyDemandCount, 'prev_supply_demand_count' => $prevSupplyDemandCount, 'supply_demand_growth_rate' => $supplyDemandGrowthRate, From ae04074f27b98503317352356bdb0817fbd2799f Mon Sep 17 00:00:00 2001 From: cody <648753004@qq.com> Date: Sun, 10 Aug 2025 10:27:36 +0800 Subject: [PATCH 2/5] update --- app/Http/Controllers/Admin/SupplyDemandController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Admin/SupplyDemandController.php b/app/Http/Controllers/Admin/SupplyDemandController.php index 018b1a9..0ea2874 100755 --- a/app/Http/Controllers/Admin/SupplyDemandController.php +++ b/app/Http/Controllers/Admin/SupplyDemandController.php @@ -196,7 +196,7 @@ class SupplyDemandController extends BaseController * description="", * @OA\Parameter(name="start_date", in="query", @OA\Schema(type="string"), required=true, description="开始日期"), * @OA\Parameter(name="end_date", in="query", @OA\Schema(type="string"), required=true, description="结束日期"), - * @OA\Parameter(name="type", in="query", @OA\Schema(type="string"), required=true, description="token"), + * @OA\Parameter(name="type", in="query", @OA\Schema(type="string"), required=true, description="type类型"), * @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"), * @OA\Response( * response="200", From 5deeebf777a9735218a193c8a2d8cb63c707c79c Mon Sep 17 00:00:00 2001 From: cody <648753004@qq.com> Date: Sun, 10 Aug 2025 10:29:48 +0800 Subject: [PATCH 3/5] update --- .../Controllers/Admin/SupplyDemandController.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Admin/SupplyDemandController.php b/app/Http/Controllers/Admin/SupplyDemandController.php index 0ea2874..addd8fa 100755 --- a/app/Http/Controllers/Admin/SupplyDemandController.php +++ b/app/Http/Controllers/Admin/SupplyDemandController.php @@ -197,6 +197,8 @@ class SupplyDemandController extends BaseController * @OA\Parameter(name="start_date", in="query", @OA\Schema(type="string"), required=true, description="开始日期"), * @OA\Parameter(name="end_date", in="query", @OA\Schema(type="string"), required=true, description="结束日期"), * @OA\Parameter(name="type", in="query", @OA\Schema(type="string"), required=true, description="type类型"), + * @OA\Parameter(name="page_size", in="query", @OA\Schema(type="string"), required=false, description="每页显示的条数"), + * @OA\Parameter(name="page", in="query", @OA\Schema(type="string"), required=false, description="页码"), * @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"), * @OA\Response( * response="200", @@ -266,8 +268,16 @@ class SupplyDemandController extends BaseController $messageGrowthRate = $this->calculateGrowthRate($messageCount, $prevMessageCount); $interactionGrowthRate = $this->calculateGrowthRate($interactionCount, $prevInteractionCount); + // 当期供需发布分页 + $list = SupplyDemand::where(function ($query) use ($type) { + if ($type) { + $query->where('type', $type); + } + })->whereBetween('created_at', [$startDate, $endDate]) + ->paginate($all['page_size'] ?? 20); + return $this->success([ - 'supplyDemand' => $supplyDemand, + 'list' => $list, 'supply_demand_count' => $supplyDemandCount, 'prev_supply_demand_count' => $prevSupplyDemandCount, 'supply_demand_growth_rate' => $supplyDemandGrowthRate, From 1a66408608fcec1d8b4c4b0731c451aa205c6449 Mon Sep 17 00:00:00 2001 From: cody <648753004@qq.com> Date: Sun, 10 Aug 2025 10:59:07 +0800 Subject: [PATCH 4/5] update --- app/Http/Controllers/Admin/SupplyDemandController.php | 4 +++- app/Models/SupplyDemand.php | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Admin/SupplyDemandController.php b/app/Http/Controllers/Admin/SupplyDemandController.php index addd8fa..a414c21 100755 --- a/app/Http/Controllers/Admin/SupplyDemandController.php +++ b/app/Http/Controllers/Admin/SupplyDemandController.php @@ -269,7 +269,9 @@ class SupplyDemandController extends BaseController $interactionGrowthRate = $this->calculateGrowthRate($interactionCount, $prevInteractionCount); // 当期供需发布分页 - $list = SupplyDemand::where(function ($query) use ($type) { + $list = SupplyDemand::with(['messages' => function ($query) { + $query->with('user', 'toUser')->limit(2)->orderBy('created_at', 'desc'); + }])->where(function ($query) use ($type) { if ($type) { $query->where('type', $type); } diff --git a/app/Models/SupplyDemand.php b/app/Models/SupplyDemand.php index 947a3b2..b9c0860 100755 --- a/app/Models/SupplyDemand.php +++ b/app/Models/SupplyDemand.php @@ -17,6 +17,7 @@ class SupplyDemand extends SoftDeletesModel if (empty($this->file_ids)) return []; return Upload::whereIn('id', $this->file_ids)->get(); } + public function user() { return $this->hasOne(User::class, 'id', 'user_id'); @@ -27,5 +28,11 @@ class SupplyDemand extends SoftDeletesModel return $this->hasMany(SupplyDemandKeep::class, 'supply_demand_id', 'id'); } + + public function messages() + { + return $this->hasMany(Message::class, 'supply_demand_id', 'id'); + } + } From eee82803e1618e937776c50011d414083f730cf1 Mon Sep 17 00:00:00 2001 From: cody <648753004@qq.com> Date: Sun, 10 Aug 2025 21:01:14 +0800 Subject: [PATCH 5/5] update --- app/Http/Controllers/Admin/SupplyDemandController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Admin/SupplyDemandController.php b/app/Http/Controllers/Admin/SupplyDemandController.php index a414c21..2181644 100755 --- a/app/Http/Controllers/Admin/SupplyDemandController.php +++ b/app/Http/Controllers/Admin/SupplyDemandController.php @@ -269,7 +269,7 @@ class SupplyDemandController extends BaseController $interactionGrowthRate = $this->calculateGrowthRate($interactionCount, $prevInteractionCount); // 当期供需发布分页 - $list = SupplyDemand::with(['messages' => function ($query) { + $list = SupplyDemand::with(['user', 'messages' => function ($query) { $query->with('user', 'toUser')->limit(2)->orderBy('created_at', 'desc'); }])->where(function ($query) use ($type) { if ($type) {