2025-09-11 22:06:19 +08:00
|
|
|
import {
|
|
|
|
|
Controller,
|
|
|
|
|
Get,
|
|
|
|
|
Post,
|
|
|
|
|
Put,
|
|
|
|
|
Delete,
|
|
|
|
|
Body,
|
|
|
|
|
Param,
|
|
|
|
|
Query,
|
|
|
|
|
UseGuards,
|
|
|
|
|
} from '@nestjs/common';
|
|
|
|
|
import { JwtAuthGuard } from '../../../auth/guards/JwtAuthGuard';
|
|
|
|
|
import { RolesGuard } from '../../../auth/guards/RolesGuard';
|
2025-09-13 08:35:59 +08:00
|
|
|
import { Roles } from '../../../auth/decorators/RolesDecorator';
|
2025-09-11 22:06:19 +08:00
|
|
|
import { AddonDevelopService } from '../../services/admin/AddonDevelopService';
|
|
|
|
|
|
|
|
|
|
@Controller('adminapi/addon/develop')
|
|
|
|
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
2025-09-13 08:35:59 +08:00
|
|
|
@Roles('admin')
|
2025-09-11 22:06:19 +08:00
|
|
|
export class AddonDevelopController {
|
|
|
|
|
constructor(private readonly addonDevelopService: AddonDevelopService) {}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 开发插件列表
|
|
|
|
|
*/
|
|
|
|
|
@Get('lists')
|
|
|
|
|
async lists(@Query() query: any) {
|
|
|
|
|
return this.addonDevelopService.getPage(query);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 开发插件信息
|
|
|
|
|
*/
|
|
|
|
|
@Get('info/:addon_id')
|
|
|
|
|
async info(@Param('addon_id') addon_id: string) {
|
|
|
|
|
return this.addonDevelopService.getInfo(parseInt(addon_id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 创建开发插件
|
|
|
|
|
*/
|
|
|
|
|
@Post('create')
|
|
|
|
|
async create(@Body() data: {
|
|
|
|
|
addon_name: string;
|
|
|
|
|
addon_key: string;
|
|
|
|
|
addon_desc?: string;
|
|
|
|
|
addon_version?: string;
|
|
|
|
|
addon_author?: string;
|
|
|
|
|
addon_config?: any;
|
|
|
|
|
}) {
|
|
|
|
|
return this.addonDevelopService.create(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 编辑开发插件
|
|
|
|
|
*/
|
|
|
|
|
@Put('edit/:addon_id')
|
|
|
|
|
async edit(
|
|
|
|
|
@Param('addon_id') addon_id: string,
|
|
|
|
|
@Body() data: {
|
|
|
|
|
addon_name?: string;
|
|
|
|
|
addon_key?: string;
|
|
|
|
|
addon_desc?: string;
|
|
|
|
|
addon_version?: string;
|
|
|
|
|
addon_author?: string;
|
|
|
|
|
addon_config?: any;
|
|
|
|
|
},
|
|
|
|
|
) {
|
|
|
|
|
return this.addonDevelopService.edit(parseInt(addon_id), data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除开发插件
|
|
|
|
|
*/
|
|
|
|
|
@Delete('delete/:addon_id')
|
|
|
|
|
async delete(@Param('addon_id') addon_id: string) {
|
|
|
|
|
return this.addonDevelopService.delete(parseInt(addon_id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 构建插件
|
|
|
|
|
*/
|
|
|
|
|
@Post('build/:addon_id')
|
|
|
|
|
async build(@Param('addon_id') addon_id: string) {
|
|
|
|
|
return this.addonDevelopService.build(parseInt(addon_id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 下载插件
|
|
|
|
|
*/
|
|
|
|
|
@Get('download/:addon_id')
|
|
|
|
|
async download(@Param('addon_id') addon_id: string) {
|
|
|
|
|
return this.addonDevelopService.download(parseInt(addon_id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取插件模板
|
|
|
|
|
*/
|
|
|
|
|
@Get('templates')
|
|
|
|
|
async getTemplates() {
|
|
|
|
|
return this.addonDevelopService.getTemplates();
|
|
|
|
|
}
|
|
|
|
|
}
|