mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 22:29:19 +08:00
优化部分模块
This commit is contained in:
@@ -1,110 +0,0 @@
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
import type { MediaFileDTO, MediaFileVO, MediaImageDTO, MediaImageVO } from './types';
|
||||
import type { PageQueryDTO, PageResultVO } from '#/types/common';
|
||||
|
||||
/**
|
||||
* 文件管理相关API
|
||||
*/
|
||||
|
||||
// 文件上传
|
||||
export async function uploadFileApi(file: File) {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
return requestClient.post<MediaFileVO.MediaFileInfoVO>('/media/file/upload', formData, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// 批量文件上传
|
||||
export async function batchUploadFilesApi(files: File[]) {
|
||||
const formData = new FormData();
|
||||
files.forEach(file => {
|
||||
formData.append('files', file);
|
||||
});
|
||||
return requestClient.post<MediaFileVO.MediaFileInfoVO[]>('/media/file/batch-upload', formData, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// 更新文件信息
|
||||
export async function updateFileApi(data: MediaFileDTO.UpdateFileDTO) {
|
||||
return requestClient.put<MediaFileVO.MediaFileInfoVO>('/media/file/update', data);
|
||||
}
|
||||
|
||||
// 删除文件
|
||||
export async function deleteFileApi(id: number) {
|
||||
return requestClient.delete(`/media/file/delete/${id}`);
|
||||
}
|
||||
|
||||
// 根据哈希查询文件
|
||||
export async function getFileByHashApi(fileHash: string) {
|
||||
return requestClient.get<MediaFileVO.MediaFileInfoVO>(`/media/file/hash/${fileHash}`);
|
||||
}
|
||||
|
||||
// 批量根据哈希查询文件
|
||||
export async function getFilesByHashesApi(fileHashes: string[]) {
|
||||
return requestClient.post<MediaFileVO.MediaFileInfoVO[]>('/media/file/batch-hash', fileHashes);
|
||||
}
|
||||
|
||||
// 分页获取文件列表
|
||||
export async function getFilePageApi(params: PageQueryDTO<MediaFileDTO.MediaFileFilterDTO>) {
|
||||
return requestClient.post<PageResultVO<MediaFileVO.MediaFileInfoVO>>('/media/file/page', params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 图片管理相关API
|
||||
*/
|
||||
|
||||
// 图片上传
|
||||
export async function uploadImageApi(file: File) {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
return requestClient.post<MediaImageVO.MediaImageInfoVO>('/media/image/upload', formData, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// 批量图片上传
|
||||
export async function batchUploadImagesApi(files: File[]) {
|
||||
const formData = new FormData();
|
||||
files.forEach(file => {
|
||||
formData.append('files', file);
|
||||
});
|
||||
return requestClient.post<MediaImageVO.MediaImageInfoVO[]>('/media/image/batch-upload', formData, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// 更新图片信息
|
||||
export async function updateImageApi(data: MediaImageDTO.UpdateImageDTO) {
|
||||
return requestClient.put<MediaImageVO.MediaImageInfoVO>('/media/image/update', data);
|
||||
}
|
||||
|
||||
// 删除图片
|
||||
export async function deleteImageApi(id: number) {
|
||||
return requestClient.delete(`/media/image/delete/${id}`);
|
||||
}
|
||||
|
||||
// 根据哈希查询图片
|
||||
export async function getImageByHashApi(fileHash: string) {
|
||||
return requestClient.get<MediaImageVO.MediaImageInfoVO>(`/media/image/hash/${fileHash}`);
|
||||
}
|
||||
|
||||
// 批量根据哈希查询图片
|
||||
export async function getImagesByHashesApi(fileHashes: string[]) {
|
||||
return requestClient.post<MediaImageVO.MediaImageInfoVO[]>('/media/image/batch-hash', fileHashes);
|
||||
}
|
||||
|
||||
// 分页获取图片列表
|
||||
export async function getImagePageApi(params: PageQueryDTO<MediaImageDTO.MediaImageFilterDTO>) {
|
||||
return requestClient.post<PageResultVO<MediaImageVO.MediaImageInfoVO>>('/media/image/page', params);
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
import type { PageQueryDTO, PageResultVO } from '#/types/common';
|
||||
import type { FileDTO, FileVO } from './types';
|
||||
|
||||
/**
|
||||
* 文件管理API
|
||||
*/
|
||||
|
||||
/**
|
||||
* 分页获取文件列表
|
||||
*/
|
||||
export async function getFilePageApi(params: PageQueryDTO<FileDTO.Filters>) {
|
||||
return requestClient.post<PageResultVO<FileVO.Info>>('/media/file/page', params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*/
|
||||
export async function uploadFileApi(file: File) {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
return requestClient.post<FileVO.Info>('/media/file/upload', formData, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量上传文件
|
||||
*/
|
||||
export async function batchUploadFilesApi(files: File[]) {
|
||||
const formData = new FormData();
|
||||
files.forEach(file => {
|
||||
formData.append('files', file);
|
||||
});
|
||||
return requestClient.post<FileVO.Info[]>('/media/file/batch-upload', formData, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新文件信息
|
||||
*/
|
||||
export async function updateFileApi(id: number, data: FileDTO.Update) {
|
||||
return requestClient.put<FileVO.Info>(`/media/file/update/${id}`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
*/
|
||||
export async function deleteFileApi(id: number) {
|
||||
return requestClient.delete<void>(`/media/file/delete/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件详情
|
||||
*/
|
||||
export async function getFileByIdApi(id: number) {
|
||||
return requestClient.get<FileVO.Info>(`/media/file/detail/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除文件
|
||||
*/
|
||||
export async function batchDeleteFilesApi(ids: number[]) {
|
||||
return requestClient.delete<void>('/media/file/batch-delete', { data: { ids } });
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
*/
|
||||
export async function downloadFileApi(id: number) {
|
||||
return requestClient.get(`/media/file/download/${id}`, {
|
||||
responseType: 'blob',
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
import type { PageQueryDTO, PageResultVO } from '#/types/common';
|
||||
import type { ImageDTO, ImageVO } from './types';
|
||||
|
||||
/**
|
||||
* 图片管理API
|
||||
*/
|
||||
|
||||
/**
|
||||
* 分页获取图片列表
|
||||
*/
|
||||
export async function getImagePageApi(params: PageQueryDTO<ImageDTO.Filters>) {
|
||||
return requestClient.post<PageResultVO<ImageVO.Info>>('/media/image/page', params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传图片
|
||||
*/
|
||||
export async function uploadImageApi(file: File) {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
return requestClient.post<ImageVO.Info>('/media/image/upload', formData, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量上传图片
|
||||
*/
|
||||
export async function batchUploadImagesApi(files: File[]) {
|
||||
const formData = new FormData();
|
||||
files.forEach(file => {
|
||||
formData.append('files', file);
|
||||
});
|
||||
return requestClient.post<ImageVO.Info[]>('/media/image/batch-upload', formData, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新图片信息
|
||||
*/
|
||||
export async function updateImageApi(id: number, data: ImageDTO.Update) {
|
||||
return requestClient.put<ImageVO.Info>(`/media/image/update/${id}`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除图片
|
||||
*/
|
||||
export async function deleteImageApi(id: number) {
|
||||
return requestClient.delete<void>(`/media/image/delete/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图片详情
|
||||
*/
|
||||
export async function getImageByIdApi(id: number) {
|
||||
return requestClient.get<ImageVO.Info>(`/media/image/detail/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除图片
|
||||
*/
|
||||
export async function batchDeleteImagesApi(ids: number[]) {
|
||||
return requestClient.delete<void>('/media/image/batch-delete', { data: { ids } });
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图片缩略图
|
||||
*/
|
||||
export async function getImageThumbnailApi(id: number, width?: number, height?: number) {
|
||||
const params = new URLSearchParams();
|
||||
if (width) params.append('width', width.toString());
|
||||
if (height) params.append('height', height.toString());
|
||||
|
||||
return requestClient.get(`/media/image/thumbnail/${id}?${params.toString()}`, {
|
||||
responseType: 'blob',
|
||||
});
|
||||
}
|
||||
@@ -1,2 +1,12 @@
|
||||
export * from './apis';
|
||||
export * from './types';
|
||||
/**
|
||||
* 媒体管理模块API导出
|
||||
*/
|
||||
|
||||
// 文件相关API
|
||||
export * from './file.apis';
|
||||
|
||||
// 图片相关API
|
||||
export * from './image.apis';
|
||||
|
||||
// 类型定义
|
||||
export * from './types';
|
||||
@@ -1,63 +0,0 @@
|
||||
/**
|
||||
* 媒体文件相关类型定义
|
||||
*/
|
||||
|
||||
export namespace MediaFileVO {
|
||||
export interface MediaFileInfoVO {
|
||||
id: number;
|
||||
companyId: number;
|
||||
url: string;
|
||||
filename: string;
|
||||
fileType: string;
|
||||
fileHash: string;
|
||||
tags: string;
|
||||
remark: string;
|
||||
uploadBy: number;
|
||||
uploadTime: string;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace MediaImageVO {
|
||||
export interface MediaImageInfoVO {
|
||||
id: number;
|
||||
companyId: number;
|
||||
url: string;
|
||||
filename: string;
|
||||
type: string;
|
||||
fileHash: string;
|
||||
tags: string;
|
||||
remark: string;
|
||||
uploadBy: number;
|
||||
uploadTime: string;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace MediaFileDTO {
|
||||
export interface UpdateFileDTO {
|
||||
id: number;
|
||||
fileType?: string;
|
||||
tags?: string;
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
export interface MediaFileFilterDTO {
|
||||
filename?: string;
|
||||
fileType?: string;
|
||||
tags?: string;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace MediaImageDTO {
|
||||
export interface UpdateImageDTO {
|
||||
id: number;
|
||||
type?: string;
|
||||
tags?: string;
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
export interface MediaImageFilterDTO {
|
||||
filename?: string;
|
||||
type?: string;
|
||||
tags?: string;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 文件管理相关DTO类型定义
|
||||
*/
|
||||
|
||||
export namespace FileDTO {
|
||||
/** 文件查询过滤条件 */
|
||||
export interface Filters {
|
||||
/** 文件名 */
|
||||
filename?: string;
|
||||
/** 文件格式 */
|
||||
fileFormat?: string;
|
||||
/** 标签 */
|
||||
tags?: string;
|
||||
/** 上传人ID */
|
||||
uploadBy?: number;
|
||||
/** 上传时间范围-开始 */
|
||||
uploadTimeStart?: string;
|
||||
/** 上传时间范围-结束 */
|
||||
uploadTimeEnd?: string;
|
||||
}
|
||||
|
||||
/** 更新文件 */
|
||||
export interface Update {
|
||||
tags?: string;
|
||||
/** 文件描述 */
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
/** 批量上传文件 */
|
||||
export interface BatchUpload {
|
||||
/** 文件列表 */
|
||||
files: File[];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* 图片管理相关DTO类型定义
|
||||
*/
|
||||
|
||||
export namespace ImageDTO {
|
||||
/** 图片查询过滤条件 */
|
||||
export interface Filters {
|
||||
/** 文件名 */
|
||||
filename?: string;
|
||||
/** 图片分类 (image,avatar,logo) */
|
||||
category?: string;
|
||||
/** 图片格式 */
|
||||
imageFormat?: string;
|
||||
/** 标签 */
|
||||
tags?: string;
|
||||
/** 上传人ID */
|
||||
uploadBy?: number;
|
||||
/** 上传时间范围-开始 */
|
||||
uploadTimeStart?: string;
|
||||
/** 上传时间范围-结束 */
|
||||
uploadTimeEnd?: string;
|
||||
}
|
||||
|
||||
/** 更新图片 */
|
||||
export interface Update {
|
||||
tags?: string;
|
||||
/** 图片说明 */
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
/** 批量上传图片 */
|
||||
export interface BatchUpload {
|
||||
/** 图片文件列表 */
|
||||
files: File[];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* 媒体管理模块类型定义导出
|
||||
*/
|
||||
|
||||
// DTO类型导出
|
||||
export * from './dto.file';
|
||||
export * from './dto.image';
|
||||
|
||||
// VO类型导出
|
||||
export * from './vo.file';
|
||||
export * from './vo.image';
|
||||
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* 文件管理相关VO类型定义
|
||||
*/
|
||||
|
||||
export namespace FileVO {
|
||||
/** 文件信息 */
|
||||
export interface Info {
|
||||
/** 文件ID */
|
||||
id: number;
|
||||
/** 公司ID */
|
||||
companyId: number;
|
||||
/** 文件URL */
|
||||
url: string;
|
||||
/** 文件名 */
|
||||
filename: string;
|
||||
/** 文件格式,如 pdf/cad/xlsx/doc */
|
||||
fileFormat?: string;
|
||||
/** 文件哈希值,用于去重 */
|
||||
fileHash?: string;
|
||||
/** 标签,逗号分隔 */
|
||||
tags?: string;
|
||||
/** 文件描述 */
|
||||
remark?: string;
|
||||
/** 上传人ID */
|
||||
uploadBy?: number;
|
||||
/** 上传时间 */
|
||||
uploadTime: string;
|
||||
/** 更新时间 */
|
||||
updateTime?: string;
|
||||
/** 更新人ID */
|
||||
updateBy?: number;
|
||||
/** 删除时间 */
|
||||
deleteTime?: string;
|
||||
/** 删除人ID */
|
||||
deleteBy?: number;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* 图片管理相关VO类型定义
|
||||
*/
|
||||
|
||||
export namespace ImageVO {
|
||||
/** 图片信息 */
|
||||
export interface Info {
|
||||
/** 图片ID */
|
||||
id: number;
|
||||
/** 公司ID */
|
||||
companyId: number;
|
||||
/** 图片URL */
|
||||
url: string;
|
||||
/** 原始文件名 */
|
||||
filename?: string;
|
||||
/** 图片分类 (image,avatar,logo) */
|
||||
category?: string;
|
||||
/** 图片格式,如 jpg/png/gif/webp */
|
||||
imageFormat?: string;
|
||||
/** 文件哈希值,用于去重 */
|
||||
fileHash?: string;
|
||||
/** 标签,逗号分隔 */
|
||||
tags?: string;
|
||||
/** 图片说明 */
|
||||
remark?: string;
|
||||
/** 上传人ID */
|
||||
uploadBy?: number;
|
||||
/** 上传时间 */
|
||||
uploadTime: string;
|
||||
/** 更新时间 */
|
||||
updateTime?: string;
|
||||
/** 更新人ID */
|
||||
updateBy?: number;
|
||||
/** 删除时间 */
|
||||
deleteTime?: string;
|
||||
/** 删除人ID */
|
||||
deleteBy?: number;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user