Browse Source

技术资料附件接口优化

曹鹤洋 1 year ago
parent
commit
1d3c5b3b18
1 changed files with 8 additions and 1 deletions
  1. 8 1
      application/api/controller/WorkOrder.php

+ 8 - 1
application/api/controller/WorkOrder.php

@@ -1690,7 +1690,14 @@ class WorkOrder extends Api
     {
         $fileName = '黄金叶(软大金圆)(二维码版)';
     $filePath = 'uploads/黄金叶(软大金圆)(二维码版).xlsx'; // Excel文件路径
-    $this->success('成功',['fileName'=>$fileName,'filePath'=>$filePath]);
+    $fileContent = base64_encode(file_get_contents($filePath));
+
+    $this->success('成功',['fileName'=>$fileName,'data'=>$fileContent]);
+    
+    $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http';
+        $host = $_SERVER['HTTP_HOST'];
+        $siteUrl = $protocol . '://' . $host .'/'.$filePath ;
+
     $excelData = []; // 存储 Excel 数据的数组
 
     $reader = IOFactory::createReader('Xlsx'); // 创建Excel读取器