From 250569828a4f3a20e0c4c4071d793e4e88c5e852 Mon Sep 17 00:00:00 2001 From: wanghousheng Date: Wed, 31 Jan 2024 01:55:40 +0800 Subject: [PATCH] 1 --- app/api/controller/Recovery.php | 13 +++++++++++-- app/common/model/RecoveryOrder.php | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/api/controller/Recovery.php b/app/api/controller/Recovery.php index f3f99bba..c52c0c5e 100644 --- a/app/api/controller/Recovery.php +++ b/app/api/controller/Recovery.php @@ -45,11 +45,11 @@ class Recovery extends Controller /** * @notes:获取详情 - * @return Json|void + * @return Json * @throws BaseException * @author: wanghousheng */ - public function detail() + public function detail(): Json { $recoveryId = intval($this->request->post('recovery_id')); if (!$recoveryId) { @@ -57,6 +57,15 @@ class Recovery extends Controller } $model = new RecoveryOrder(); $info = $model->getDetails($recoveryId); + if ($info && !empty($info['images'])) { + $images_list = helper::getArrayColumn($info['images'], 'file'); + $arr = []; + foreach ($images_list as $image) { + $arr[] = $image['preview_url']; + } + $info['images_list'] = $arr; + unset($info['images']); + } return $this->renderSuccess(['detail' => $info]); } diff --git a/app/common/model/RecoveryOrder.php b/app/common/model/RecoveryOrder.php index 6d9fa861..3ba62b77 100644 --- a/app/common/model/RecoveryOrder.php +++ b/app/common/model/RecoveryOrder.php @@ -30,7 +30,7 @@ class RecoveryOrder extends BaseModel */ public function images(): HasMany { - return $this->hasMany('RecoveryImage')->order(['id']); + return $this->hasMany(RecoveryImage::class, 'recovery_id', 'recovery_id')->order(['id']); } public function getOrderStatusTextAttr($value, $data)