74 lines
1.5 KiB
TypeScript
74 lines
1.5 KiB
TypeScript
import {
|
|
Controller,
|
|
Get,
|
|
Post,
|
|
Body,
|
|
Query,
|
|
UseGuards,
|
|
} from '@nestjs/common';
|
|
import { JwtAuthGuard } from '../../../auth/guards/JwtAuthGuard';
|
|
import { RolesGuard } from '../../../auth/guards/RolesGuard';
|
|
import { UeditorService } from '../../services/admin/UeditorService';
|
|
|
|
@Controller('adminapi/sys/ueditor')
|
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
|
export class UeditorController {
|
|
constructor(private readonly ueditorService: UeditorService) {}
|
|
|
|
/**
|
|
* 获取UEditor配置
|
|
*/
|
|
@Get('config')
|
|
async getConfig() {
|
|
return this.ueditorService.getConfig();
|
|
}
|
|
|
|
/**
|
|
* 上传图片
|
|
*/
|
|
@Post('upload/image')
|
|
async uploadImage(@Body() data: any) {
|
|
return this.ueditorService.uploadImage(data);
|
|
}
|
|
|
|
/**
|
|
* 上传文件
|
|
*/
|
|
@Post('upload/file')
|
|
async uploadFile(@Body() data: any) {
|
|
return this.ueditorService.uploadFile(data);
|
|
}
|
|
|
|
/**
|
|
* 上传视频
|
|
*/
|
|
@Post('upload/video')
|
|
async uploadVideo(@Body() data: any) {
|
|
return this.ueditorService.uploadVideo(data);
|
|
}
|
|
|
|
/**
|
|
* 获取文件列表
|
|
*/
|
|
@Get('list')
|
|
async getList(@Query() query: any) {
|
|
return this.ueditorService.getList(query);
|
|
}
|
|
|
|
/**
|
|
* 删除文件
|
|
*/
|
|
@Post('delete')
|
|
async deleteFile(@Body() data: { file_name: string }) {
|
|
return this.ueditorService.deleteFile(data.file_name);
|
|
}
|
|
|
|
/**
|
|
* 获取文件信息
|
|
*/
|
|
@Get('info')
|
|
async getFileInfo(@Query('file_name') file_name: string) {
|
|
return this.ueditorService.getFileInfo(file_name);
|
|
}
|
|
}
|