diff --git a/plugin/admin/app/controller/VehicleController.php b/plugin/admin/app/controller/VehicleController.php index ebdba17..0c984e8 100644 --- a/plugin/admin/app/controller/VehicleController.php +++ b/plugin/admin/app/controller/VehicleController.php @@ -12,6 +12,7 @@ use app\model\VehicleRu; use app\service\OssService; use plugin\admin\app\common\Util; use plugin\admin\app\model\Location; +use support\Cache; use support\Log; use support\Request; use support\Response; @@ -485,8 +486,10 @@ class VehicleController extends Crud ]; $translations = array_merge($required_translations, $translations); } - - $data = Vehicle::where('id', $id)->first(); + +// $data = Vehicle::where('id', $id)->first(); + list($vehicleModel,$local) = $this->getModel($lang); + $data = $vehicleModel::where('id', $id)->first(); if (!$data) { return json(['code' => 1, 'msg' => $translations['data_not_found'] ?? '数据不存在']); } @@ -550,6 +553,15 @@ class VehicleController extends Crud if(!str_starts_with($item['img_url'], 'http')){ try { + $img_url = Cache::get('img_dibai_'.$vehicle->id); + if ($img_url) { + $item['img_url'] = $img_url; + } else { + $ossservice = new OssService(); + $img_url = $ossservice->generatePrivateUrl($vehicle['img_url'],86400); + $item['img_url'] = $img_url; + Cache::set('img_dibai_'.$vehicle->id, $img_url, 86390); + } $ossservice = new OssService(); $img_url = $ossservice->generatePrivateUrl($item['img_url']); @@ -560,7 +572,7 @@ class VehicleController extends Crud 'generated_url' => $img_url, 'current_time' => time() ]); - $item['img_url'] = $img_url; +// $item['img_url'] = $img_url; } catch (\Exception $e) { Log::error("Vehicle image URL generation failed:", [ 'error' => $e->getMessage(),