|
|
@@ -77,13 +77,11 @@ class Facility extends Api
|
|
|
// 获取前端传入的图片路径参数
|
|
|
$params = $this->request->param('path', '');
|
|
|
// 查询数据库
|
|
|
- $res = Db::name('text_to_image')->alias('b')
|
|
|
- ->field('b.chinese_description,b.english_description,b.new_image_url,b.custom_image_url,b.size,b.old_image_url,b.img_name')
|
|
|
+ $res = Db::name('text_to_image')
|
|
|
+ ->field('id,chinese_description,english_description,new_image_url,custom_image_url,size,old_image_url,img_name,model')
|
|
|
->where('old_image_url', $params)
|
|
|
->where('img_name', '<>', '')
|
|
|
- // ->where('custom_image_url', '<>', '')
|
|
|
- // ->where('status', 1)
|
|
|
- ->order('b.id desc')
|
|
|
+ ->order('id desc')
|
|
|
->select();
|
|
|
return json(['code' => 0, 'msg' => '查询成功', 'data' => $res,'count'=>count($res)]);
|
|
|
}
|
|
|
@@ -95,88 +93,92 @@ class Facility extends Api
|
|
|
$page = (int)$this->request->param('page', 1);
|
|
|
$limit = (int)$this->request->param('limit', 50);
|
|
|
$status = $this->request->param('status', '');
|
|
|
-
|
|
|
$relativePath = $this->request->param('path', '');
|
|
|
+
|
|
|
$basePath = ROOT_PATH . 'public/';
|
|
|
$fullPath = $basePath . $relativePath;
|
|
|
|
|
|
if (!is_dir($fullPath)) {
|
|
|
- return json(['code' => 1, 'msg' => '目录不存在']);
|
|
|
+ return json(['code' => 1, 'msg' => '原图目录不存在']);
|
|
|
}
|
|
|
|
|
|
- // 1. 获取所有图片路径(不再全部加载到内存)
|
|
|
+ // 1. 获取所有图片路径
|
|
|
$allImages = glob($fullPath . '/*.{jpg,jpeg,png}', GLOB_BRACE);
|
|
|
if (empty($allImages)) {
|
|
|
return json(['code' => 0, 'msg' => '暂无图片', 'data' => [], 'total' => 0]);
|
|
|
}
|
|
|
- // ✅ 加入排序:按照创建时间从新到旧
|
|
|
- usort($allImages, function ($a, $b) {
|
|
|
- return filectime($b) - filectime($a);
|
|
|
- });
|
|
|
- // 构建相对路径数组
|
|
|
- $relativeImages = array_map(function ($imgPath) use ($basePath) {
|
|
|
- return str_replace($basePath, '', $imgPath);
|
|
|
- }, $allImages);
|
|
|
|
|
|
- // 2. 提前构建是否已出图map
|
|
|
+ // 2. 构建路径信息映射(路径 => 文件信息)
|
|
|
+ $imageInfoMap = [];
|
|
|
+ foreach ($allImages as $imgPath) {
|
|
|
+ $relative = str_replace('\\', '/', trim(str_replace($basePath, '', $imgPath), '/'));
|
|
|
+ $info = @getimagesize($imgPath);
|
|
|
+ $imageInfoMap[$relative] = [
|
|
|
+ 'width' => $info[0] ?? 0,
|
|
|
+ 'height' => $info[1] ?? 0,
|
|
|
+ 'size_kb' => round(filesize($imgPath) / 1024, 2),
|
|
|
+ 'created_time' => date('Y-m-d H:i:s', filectime($imgPath))
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ $relativeImages = array_keys($imageInfoMap);
|
|
|
+
|
|
|
+ // 3. 获取数据库记录
|
|
|
$dbRecords = Db::name('text_to_image')
|
|
|
->whereIn('old_image_url', $relativeImages)
|
|
|
- ->where('img_name', '<>', '')
|
|
|
- ->where('custom_image_url', '<>', '')
|
|
|
- ->where('status',1)
|
|
|
- ->field('old_image_url,new_image_url,custom_image_url,chinese_description,english_description,img_name')
|
|
|
+ ->field('id as img_id, old_image_url, new_image_url, custom_image_url, chinese_description, english_description, img_name, status')
|
|
|
->select();
|
|
|
|
|
|
+ // 4. 构建映射表:路径 => 整条数据库记录
|
|
|
$processedMap = [];
|
|
|
foreach ($dbRecords as $item) {
|
|
|
- $processedMap[$item['old_image_url']] = $item;
|
|
|
+ $key = str_replace('\\', '/', trim($item['old_image_url'], '/'));
|
|
|
+ $processedMap[$key] = $item;
|
|
|
}
|
|
|
|
|
|
- // 3. 提前获取 same_count 的统计
|
|
|
+ // 5. 获取 same_count 统计
|
|
|
$sameCountMap = Db::name('text_to_image')
|
|
|
->whereIn('old_image_url', $relativeImages)
|
|
|
- ->where('img_name', '<>', '')
|
|
|
- ->where('custom_image_url', '<>', '')
|
|
|
+ ->where('status', 1)
|
|
|
->group('old_image_url')
|
|
|
- ->where('status',1)
|
|
|
->column('count(*) as cnt', 'old_image_url');
|
|
|
|
|
|
- // 4. 构造最终筛选数据(分页前进行状态筛选)
|
|
|
- $filtered = [];
|
|
|
- foreach ($allImages as $imgPath) {
|
|
|
- $relative = str_replace($basePath, '', $imgPath);
|
|
|
- $processed = $processedMap[$relative] ?? null;
|
|
|
- $isProcessed = $processed ? 1 : 0;
|
|
|
+ // 6. 构建结果数据
|
|
|
+ $allData = [];
|
|
|
+ foreach ($relativeImages as $path) {
|
|
|
+ $item = $processedMap[$path] ?? [];
|
|
|
+ $info = $imageInfoMap[$path];
|
|
|
|
|
|
- // 状态过滤
|
|
|
- if ($status === 'processed' && !$isProcessed) continue;
|
|
|
- if ($status === 'unprocessed' && $isProcessed) continue;
|
|
|
+ $isProcessed = !empty($item['img_name']) && !empty($item['custom_image_url']);
|
|
|
+ $dbStatus = isset($item['status']) ? (int)$item['status'] : 0;
|
|
|
|
|
|
- $info = @getimagesize($imgPath); // 加@防止报错
|
|
|
- $sizeKB = round(filesize($imgPath) / 1024, 2);
|
|
|
- $ctime = date('Y-m-d H:i:s', filectime($imgPath));
|
|
|
+ // 状态过滤(0:未出图,1:已出图)
|
|
|
+ if ($status !== '' && (int)$status !== $dbStatus) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
- $filtered[] = [
|
|
|
- 'path' => $relative,
|
|
|
- 'width' => $info[0] ?? 0,
|
|
|
- 'height' => $info[1] ?? 0,
|
|
|
- 'size_kb' => $sizeKB,
|
|
|
- 'created_time' => $ctime,
|
|
|
- 'img_name' => $processed['img_name'] ?? '',
|
|
|
- 'is_processed' => $isProcessed,
|
|
|
- 'new_image_url' => $processed['new_image_url'] ?? '',
|
|
|
- 'custom_image_url' => $processed['custom_image_url'] ?? '',
|
|
|
- 'chinese_description' => ($processed['chinese_description'] ?? '') . ($processed['english_description'] ?? ''),
|
|
|
- 'english_description' => ($processed['english_description'] ?? '') . ($processed['english_description'] ?? ''),
|
|
|
- 'same_count' => $sameCountMap[$relative] ?? 0
|
|
|
+ $allData[] = [
|
|
|
+ 'path' => $path,//原图路径
|
|
|
+ 'status' => $dbStatus,//状态
|
|
|
+ 'same_count' => $sameCountMap[$path] ?? 0, // 出图数量
|
|
|
+ 'is_processed' => $isProcessed ? 1 : 0,
|
|
|
+ 'new_image_url' => $item['new_image_url'] ?? '',
|
|
|
+ 'custom_image_url' => $item['custom_image_url'] ?? '',
|
|
|
+ 'chinese_description' => $item['chinese_description'] ?? '',
|
|
|
+ 'english_description' => $item['english_description'] ?? '',
|
|
|
+ 'img_name' => $item['img_name'] ?? '',
|
|
|
+ 'width' => $info['width'],
|
|
|
+ 'height' => $info['height'],
|
|
|
+ 'size_kb' => $info['size_kb'],
|
|
|
+ 'created_time' => $info['created_time']
|
|
|
];
|
|
|
}
|
|
|
|
|
|
- // 5. 手动分页(对少量已筛选后的数据)
|
|
|
- $total = count($filtered);
|
|
|
- $pagedData = array_slice($filtered, ($page - 1) * $limit, $limit);
|
|
|
- foreach ($pagedData as $index => &$item) {
|
|
|
- $item['id'] = ($page - 1) * $limit + $index + 1;
|
|
|
+ // 7. 分页处理
|
|
|
+ $total = count($allData);
|
|
|
+ $pagedData = array_slice(array_values($allData), ($page - 1) * $limit, $limit);
|
|
|
+ foreach ($pagedData as $i => &$row) {
|
|
|
+ $row['id'] = ($page - 1) * $limit + $i + 1;
|
|
|
}
|
|
|
|
|
|
return json([
|
|
|
@@ -189,6 +191,215 @@ class Facility extends Api
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// public function getPreviewimg()
|
|
|
+// {
|
|
|
+// $page = (int)$this->request->param('page', 1);
|
|
|
+// $limit = (int)$this->request->param('limit', 50);
|
|
|
+// $status = $this->request->param('status', '');
|
|
|
+// $relativePath = $this->request->param('path', '');
|
|
|
+//
|
|
|
+// $basePath = ROOT_PATH . 'public/';
|
|
|
+// $fullPath = $basePath . $relativePath;
|
|
|
+//
|
|
|
+// if (!is_dir($fullPath)) {
|
|
|
+// return json(['code' => 1, 'msg' => '原图目录不存在']);
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 1. 获取所有图片路径
|
|
|
+// $allImages = glob($fullPath . '/*.{jpg,jpeg,png}', GLOB_BRACE);
|
|
|
+// if (empty($allImages)) {
|
|
|
+// return json(['code' => 0, 'msg' => '暂无图片', 'data' => [], 'total' => 0]);
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 2. 构建路径信息映射(路径 => 文件信息)
|
|
|
+// $imageInfoMap = [];
|
|
|
+// foreach ($allImages as $imgPath) {
|
|
|
+// $relative = str_replace('\\', '/', trim(str_replace($basePath, '', $imgPath), '/'));
|
|
|
+// $info = @getimagesize($imgPath);
|
|
|
+// $imageInfoMap[$relative] = [
|
|
|
+// 'width' => $info[0] ?? 0,
|
|
|
+// 'height' => $info[1] ?? 0,
|
|
|
+// 'size_kb' => round(filesize($imgPath) / 1024, 2),
|
|
|
+// 'created_time' => date('Y-m-d H:i:s', filectime($imgPath))
|
|
|
+// ];
|
|
|
+// }
|
|
|
+//
|
|
|
+// $relativeImages = array_keys($imageInfoMap);
|
|
|
+//
|
|
|
+// // 3. 获取数据库记录
|
|
|
+// $dbRecords = Db::name('text_to_image')
|
|
|
+// ->whereIn('old_image_url', $relativeImages)
|
|
|
+// ->field('id as img_id, old_image_url, new_image_url, custom_image_url, chinese_description, english_description, img_name,status')
|
|
|
+// ->select();
|
|
|
+//
|
|
|
+// // 4. 构建映射表:路径 => 整条数据库记录
|
|
|
+// $processedMap = [];
|
|
|
+// foreach ($dbRecords as $item) {
|
|
|
+// $key = str_replace('\\', '/', trim($item['old_image_url'], '/'));
|
|
|
+// $processedMap[$key] = $item;
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 5. 获取 same_count 统计
|
|
|
+// $sameCountMap = Db::name('text_to_image')
|
|
|
+// ->whereIn('old_image_url', $relativeImages)
|
|
|
+// ->where('status', 1)
|
|
|
+// ->group('old_image_url')
|
|
|
+// ->column('count(*) as cnt', 'old_image_url');
|
|
|
+//
|
|
|
+// // 6. 构建结果数据
|
|
|
+// $allData = [];
|
|
|
+// foreach ($relativeImages as $path) {
|
|
|
+// $item = $processedMap[$path] ?? [];
|
|
|
+// $info = $imageInfoMap[$path];
|
|
|
+//
|
|
|
+// $isProcessed = !empty($item['img_name']) && !empty($item['custom_image_url']);
|
|
|
+//
|
|
|
+// // 状态过滤
|
|
|
+// if ($status === '1') {
|
|
|
+// if (!$isProcessed) continue;
|
|
|
+// } elseif ($status === '2') {
|
|
|
+// if ($isProcessed) continue;
|
|
|
+// }
|
|
|
+//
|
|
|
+// $allData[] = [
|
|
|
+// 'path' => $path,
|
|
|
+// 'status' => (int)($item['status'] ?? 0),
|
|
|
+// 'same_count' => $sameCountMap[$path] ?? 0,//出图数量
|
|
|
+// 'is_processed' => $isProcessed ? 1 : 0,
|
|
|
+// 'new_image_url' => $item['new_image_url'] ?? '',
|
|
|
+// 'custom_image_url' => $item['custom_image_url'] ?? '',
|
|
|
+// 'chinese_description' => $item['chinese_description'] ?? '',
|
|
|
+// 'english_description' => $item['english_description'] ?? '',
|
|
|
+// 'img_name' => $item['img_name'] ?? '',
|
|
|
+// 'width' => $info['width'],
|
|
|
+// 'height' => $info['height'],
|
|
|
+// 'size_kb' => $info['size_kb'],
|
|
|
+// 'created_time' => $info['created_time']
|
|
|
+// ];
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 7. 分页处理
|
|
|
+// $total = count($allData);
|
|
|
+// $pagedData = array_slice(array_values($allData), ($page - 1) * $limit, $limit);
|
|
|
+// foreach ($pagedData as $i => &$row) {
|
|
|
+// $row['id'] = ($page - 1) * $limit + $i + 1;
|
|
|
+// }
|
|
|
+//
|
|
|
+// return json([
|
|
|
+// 'code' => 0,
|
|
|
+// 'msg' => '获取成功',
|
|
|
+// 'data' => $pagedData,
|
|
|
+// 'total' => $total,
|
|
|
+// 'page' => $page,
|
|
|
+// 'limit' => $limit
|
|
|
+// ]);
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// public function getPreviewimg()
|
|
|
+// {
|
|
|
+// $page = (int)$this->request->param('page', 1);
|
|
|
+// $limit = (int)$this->request->param('limit', 50);
|
|
|
+// $status = $this->request->param('status', '');
|
|
|
+//
|
|
|
+// $relativePath = $this->request->param('path', '');
|
|
|
+// $basePath = ROOT_PATH . 'public/';
|
|
|
+// $fullPath = $basePath . $relativePath;
|
|
|
+//
|
|
|
+// if (!is_dir($fullPath)) {
|
|
|
+// return json(['code' => 1, 'msg' => '目录不存在']);
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 1. 获取所有图片路径(不再全部加载到内存)
|
|
|
+// $allImages = glob($fullPath . '/*.{jpg,jpeg,png}', GLOB_BRACE);
|
|
|
+// if (empty($allImages)) {
|
|
|
+// return json(['code' => 0, 'msg' => '暂无图片', 'data' => [], 'total' => 0]);
|
|
|
+// }
|
|
|
+// // ✅ 加入排序:按照创建时间从新到旧
|
|
|
+// usort($allImages, function ($a, $b) {
|
|
|
+// return filectime($b) - filectime($a);
|
|
|
+// });
|
|
|
+// // 构建相对路径数组
|
|
|
+// $relativeImages = array_map(function ($imgPath) use ($basePath) {
|
|
|
+// return str_replace($basePath, '', $imgPath);
|
|
|
+// }, $allImages);
|
|
|
+//
|
|
|
+// // 2. 提前构建是否已出图map
|
|
|
+// $dbRecords = Db::name('text_to_image')
|
|
|
+// ->whereIn('old_image_url', $relativeImages)
|
|
|
+// ->where('img_name', '<>', '')
|
|
|
+// ->where('custom_image_url', '<>', '')
|
|
|
+// ->where('status',1)
|
|
|
+// ->field('id,old_image_url,new_image_url,custom_image_url,chinese_description,english_description,img_name')
|
|
|
+// ->select();
|
|
|
+//
|
|
|
+// $processedMap = [];
|
|
|
+// foreach ($dbRecords as $item) {
|
|
|
+// $processedMap[$item['old_image_url']] = $item;
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 3. 提前获取 same_count 的统计
|
|
|
+// $sameCountMap = Db::name('text_to_image')
|
|
|
+// ->whereIn('old_image_url', $relativeImages)
|
|
|
+// ->where('img_name', '<>', '')
|
|
|
+// ->where('custom_image_url', '<>', '')
|
|
|
+// ->group('old_image_url')
|
|
|
+// ->where('status',1)
|
|
|
+// ->column('count(*) as cnt', 'old_image_url');
|
|
|
+//
|
|
|
+// // 4. 构造最终筛选数据(分页前进行状态筛选)
|
|
|
+// $filtered = [];
|
|
|
+// foreach ($allImages as $imgPath) {
|
|
|
+// $relative = str_replace($basePath, '', $imgPath);
|
|
|
+// $processed = $processedMap[$relative] ?? null;
|
|
|
+// $isProcessed = $processed ? 1 : 0;
|
|
|
+//
|
|
|
+// // 状态过滤
|
|
|
+// if ($status === 'processed' && !$isProcessed) continue;
|
|
|
+// if ($status === 'unprocessed' && $isProcessed) continue;
|
|
|
+//
|
|
|
+// $info = @getimagesize($imgPath); // 加@防止报错
|
|
|
+// $sizeKB = round(filesize($imgPath) / 1024, 2);
|
|
|
+// $ctime = date('Y-m-d H:i:s', filectime($imgPath));
|
|
|
+//
|
|
|
+// $filtered[] = [
|
|
|
+// 'path' => $relative,
|
|
|
+// 'width' => $info[0] ?? 0,
|
|
|
+// 'height' => $info[1] ?? 0,
|
|
|
+// 'size_kb' => $sizeKB,
|
|
|
+// 'created_time' => $ctime,
|
|
|
+// 'img_name' => $processed['img_name'] ?? '',
|
|
|
+// 'is_processed' => $isProcessed,
|
|
|
+// 'new_image_url' => $processed['new_image_url'] ?? '',
|
|
|
+// 'custom_image_url' => $processed['custom_image_url'] ?? '',
|
|
|
+// 'chinese_description' => ($processed['chinese_description'] ?? '') . ($processed['english_description'] ?? ''),
|
|
|
+// 'english_description' => ($processed['english_description'] ?? '') . ($processed['english_description'] ?? ''),
|
|
|
+// 'same_count' => $sameCountMap[$relative] ?? 0
|
|
|
+// ];
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 5. 手动分页(对少量已筛选后的数据)
|
|
|
+// $total = count($filtered);
|
|
|
+// $pagedData = array_slice($filtered, ($page - 1) * $limit, $limit);
|
|
|
+// foreach ($pagedData as $index => &$item) {
|
|
|
+// $item['id'] = ($page - 1) * $limit + $index + 1;
|
|
|
+// }
|
|
|
+//
|
|
|
+// return json([
|
|
|
+// 'code' => 0,
|
|
|
+// 'msg' => '获取成功',
|
|
|
+// 'data' => $pagedData,
|
|
|
+// 'total' => $total,
|
|
|
+// 'page' => $page,
|
|
|
+// 'limit' => $limit
|
|
|
+// ]);
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 获取原图目录及每个目录下的图片数量
|
|
|
*/
|
|
|
@@ -274,105 +485,10 @@ class Facility extends Api
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 图片上传
|
|
|
* @return void
|
|
|
*/
|
|
|
-// public function getUploadPath()
|
|
|
-// {
|
|
|
-// // 处理 CORS OPTIONS 预检请求
|
|
|
-// if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
|
|
|
-// header('Access-Control-Allow-Origin: *');
|
|
|
-// header('Access-Control-Allow-Methods: POST, OPTIONS');
|
|
|
-// header('Access-Control-Allow-Headers: Content-Type, Authorization');
|
|
|
-// header('Access-Control-Max-Age: 86400');
|
|
|
-// exit(204);
|
|
|
-// }
|
|
|
-//
|
|
|
-//// 实际请求必须返回 CORS 头
|
|
|
-// header('Access-Control-Allow-Origin: *');
|
|
|
-// $today = date('Ymd');
|
|
|
-// $basePath = 'uploads/operate/ai/Preview/' . $today;
|
|
|
-// $rootBasePath = ROOT_PATH . 'public/' . $basePath;
|
|
|
-//
|
|
|
-// // 创建当天目录
|
|
|
-// if (!is_dir($rootBasePath)) {
|
|
|
-// mkdir($rootBasePath, 0755, true);
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 获取子目录索引
|
|
|
-// $dirs = array_filter(glob($rootBasePath . '/*'), 'is_dir');
|
|
|
-// $usedIndexes = [];
|
|
|
-//
|
|
|
-// foreach ($dirs as $dirPath) {
|
|
|
-// $dirName = basename($dirPath);
|
|
|
-// if (preg_match('/^\d{2}$/', $dirName)) {
|
|
|
-// $usedIndexes[] = intval($dirName);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// $nextIndex = empty($usedIndexes) ? 1 : max($usedIndexes) + 1;
|
|
|
-// $subDir = str_pad($nextIndex, 2, '0', STR_PAD_LEFT);
|
|
|
-// $relativePath = $basePath . '/' . $subDir;
|
|
|
-// $targetPath = ROOT_PATH . 'public/' . $relativePath;
|
|
|
-//
|
|
|
-// // 创建该批次目录
|
|
|
-// if (!is_dir($targetPath)) {
|
|
|
-// mkdir($targetPath, 0755, true);
|
|
|
-// }
|
|
|
-//
|
|
|
-// return json([
|
|
|
-// 'code' => 0,
|
|
|
-// 'msg' => '获取上传路径成功',
|
|
|
-// 'data' => [
|
|
|
-// 'upload_path' => $relativePath
|
|
|
-// ]
|
|
|
-// ]);
|
|
|
-// }
|
|
|
-// public function ImgUpload()
|
|
|
-// {
|
|
|
-// if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
|
|
|
-// header('Access-Control-Allow-Origin: *');
|
|
|
-// header('Access-Control-Allow-Methods: POST, OPTIONS');
|
|
|
-// header('Access-Control-Allow-Headers: Content-Type, Authorization');
|
|
|
-// header('Access-Control-Max-Age: 86400');
|
|
|
-// exit(204);
|
|
|
-// }
|
|
|
-// header('Access-Control-Allow-Origin: *');
|
|
|
-//
|
|
|
-// $file = request()->file('image');
|
|
|
-// $relativePath = input('post.upload_path');
|
|
|
-//
|
|
|
-// if (!$file || !$relativePath) {
|
|
|
-// return json(['code' => 1, 'msg' => '缺少上传文件或路径参数']);
|
|
|
-// }
|
|
|
-//
|
|
|
-// $targetPath = ROOT_PATH . 'public/' . $relativePath;
|
|
|
-//
|
|
|
-// if (!is_dir($targetPath)) {
|
|
|
-// mkdir($targetPath, 0755, true);
|
|
|
-// }
|
|
|
-//
|
|
|
-// $tmpFilePath = $file->getPathname();
|
|
|
-// $extension = pathinfo($file->getInfo('name'), PATHINFO_EXTENSION);
|
|
|
-// $hashName = hash_file('md5', $tmpFilePath);
|
|
|
-// $newFileName = $hashName . '.' . $extension;
|
|
|
-//
|
|
|
-// $info = $file->validate(['size' => 10 * 1024 * 1024, 'ext' => 'jpg,jpeg,png'])
|
|
|
-// ->move($targetPath, $newFileName);
|
|
|
-//
|
|
|
-// if ($info) {
|
|
|
-// $imageUrl = $relativePath . '/' . str_replace('\\', '/', $newFileName);
|
|
|
-// return json(['code' => 0, 'msg' => '上传成功', 'data' => ['url' => $imageUrl]]);
|
|
|
-// } else {
|
|
|
-// return json(['code' => 1, 'msg' => '上传失败', 'data' => $file->getError()]);
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
public function ImgUpload()
|
|
|
{
|
|
|
// 处理 CORS OPTIONS 预检请求
|
|
|
@@ -450,6 +566,7 @@ class Facility extends Api
|
|
|
$Template = Db::name("template")
|
|
|
->where('id', 1) // 假设模板 ID 是 1,需根据实际情况修改
|
|
|
->update([
|
|
|
+ 'english_content' => $params['english_content'], // 更新文生文模版内容
|
|
|
'content' => $params['textareaContent'], // 更新图生文模版内容
|
|
|
'width' => $params['width'], // 更新宽度
|
|
|
'height' => $params['height'], // 更新宽度
|