mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 02:29:19 +08:00
feat: 迁移旧媒体文件到统一文件系统 sys/file
Backend: - SysFileController 新增 deleteFile + updateFile 接口 - 新增 SysFileUpdateDTO 用于更新文件元信息 - SysFileServiceImpl 实现 deleteFile + updateFile(带 companyId 校验) Frontend: - 导入订单页面改用 batchUploadFilesApi(返回 storagePath) - 文件管理页 media/file/index.vue 改用 system/file API - uploadFileApi → batchUploadFilesApi - url → accessUrl - updateFileApi 改用 system/file - FileEditModal 改用 system/file 类型和 API 旧媒体系统 (media/file) 不再使用,待后续清理。
This commit is contained in:
@@ -65,3 +65,20 @@ export async function getFilePageApi(params: PageQueryDTO<FileDTO.Filter>) {
|
||||
params,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
* @param fileId 文件ID
|
||||
*/
|
||||
export async function deleteFileApi(fileId: number) {
|
||||
return requestClient.delete(`/sys/file/${fileId}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新文件元信息
|
||||
* @param fileId 文件ID
|
||||
* @param data 更新内容
|
||||
*/
|
||||
export async function updateFileApi(fileId: number, data: { tags?: string; remark?: string }) {
|
||||
return requestClient.put(`/sys/file/${fileId}`, data);
|
||||
}
|
||||
|
||||
+3
-3
@@ -32,7 +32,7 @@ import {
|
||||
import { createImportTaskApi } from '#/api/ecommerce/import-task';
|
||||
import { getAllOrderStatusListApi } from '#/api/ecommerce/order-status';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
import { uploadFileApi } from '#/api/media/file';
|
||||
import { batchUploadFilesApi } from '#/api/system/file';
|
||||
import { useImportTaskStore } from '#/store';
|
||||
|
||||
// 定义映射项数据结构
|
||||
@@ -759,7 +759,7 @@ const handleCreateTask = async () => {
|
||||
|
||||
// 先上传文件
|
||||
message.loading('正在上传文件...', 0);
|
||||
const fileInfo = await uploadFileApi(selectedFile.value);
|
||||
const [fileInfo] = await batchUploadFilesApi([selectedFile.value]);
|
||||
message.destroy();
|
||||
|
||||
// 构建字段映射 JSON(基于 ImportFieldDefInfoVO 结构)
|
||||
@@ -790,7 +790,7 @@ const handleCreateTask = async () => {
|
||||
shopId: selectedShopId.value!,
|
||||
type: 'order',
|
||||
fileName: selectedFile.value.name,
|
||||
filePath: fileInfo.url,
|
||||
filePath: fileInfo.storagePath,
|
||||
mapping: JSON.stringify(fullMapping),
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import type { FileDTO, FileVO } from '#/api/media/file/types';
|
||||
import type { FileDTO, FileVO } from '#/api/system/file/types';
|
||||
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
@@ -7,7 +7,7 @@ import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Form, Input, message } from 'ant-design-vue';
|
||||
|
||||
import { updateFileApi } from '#/api/media/file';
|
||||
import { updateFileApi } from '#/api/system/file';
|
||||
|
||||
defineOptions({ name: 'FileEditModal' });
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { FileDTO, FileVO } from '#/api/media/file/types';
|
||||
import type { FileDTO, FileVO } from '#/api/system/file/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
@@ -23,8 +23,7 @@ import {
|
||||
batchUploadFilesApi,
|
||||
deleteFileApi,
|
||||
getFilePageApi,
|
||||
uploadFileApi,
|
||||
} from '#/api/media/file';
|
||||
} from '#/api/system/file';
|
||||
|
||||
import FileEditModal from './components/FileEditModal.vue';
|
||||
|
||||
@@ -212,7 +211,7 @@ function refreshTable() {
|
||||
const handleUpload = async (file: File) => {
|
||||
uploadLoading.value = true;
|
||||
try {
|
||||
await uploadFileApi(file);
|
||||
await batchUploadFilesApi([file]);
|
||||
message.success('文件上传成功');
|
||||
refreshTable();
|
||||
} catch {
|
||||
@@ -241,12 +240,12 @@ const handleEdit = (record: FileVO.Info) => {
|
||||
};
|
||||
|
||||
const handlePreview = (record: FileVO.Info) => {
|
||||
window.open(record.url, '_blank');
|
||||
window.open(record.accessUrl, '_blank');
|
||||
};
|
||||
|
||||
const handleDownload = (record: FileVO.Info) => {
|
||||
const link = document.createElement('a');
|
||||
link.href = record.url;
|
||||
link.href = record.accessUrl;
|
||||
link.download = record.filename;
|
||||
link.click();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user