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 { AddonAppService } from '../../services/admin/AddonAppService';
|
|
|
|
|
|
|
|
|
|
@Controller('adminapi/addon/app')
|
|
|
|
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
2025-09-13 08:35:59 +08:00
|
|
|
@Roles('admin')
|
2025-09-11 22:06:19 +08:00
|
|
|
export class AppController {
|
|
|
|
|
constructor(private readonly addonAppService: AddonAppService) {}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 插件应用列表
|
|
|
|
|
*/
|
|
|
|
|
@Get('lists')
|
|
|
|
|
async lists(@Query() query: any) {
|
|
|
|
|
return this.addonAppService.getPage(query);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 插件应用信息
|
|
|
|
|
*/
|
|
|
|
|
@Get('info/:app_id')
|
|
|
|
|
async info(@Param('app_id') app_id: string) {
|
|
|
|
|
return this.addonAppService.getInfo(parseInt(app_id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 添加插件应用
|
|
|
|
|
*/
|
|
|
|
|
@Post('add')
|
|
|
|
|
async add(@Body() data: {
|
|
|
|
|
app_name: string;
|
|
|
|
|
app_key: string;
|
|
|
|
|
app_desc?: string;
|
|
|
|
|
app_version?: string;
|
|
|
|
|
app_author?: string;
|
|
|
|
|
app_config?: any;
|
|
|
|
|
status?: number;
|
|
|
|
|
}) {
|
|
|
|
|
return this.addonAppService.add(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 编辑插件应用
|
|
|
|
|
*/
|
|
|
|
|
@Put('edit/:app_id')
|
|
|
|
|
async edit(
|
|
|
|
|
@Param('app_id') app_id: string,
|
|
|
|
|
@Body() data: {
|
|
|
|
|
app_name?: string;
|
|
|
|
|
app_key?: string;
|
|
|
|
|
app_desc?: string;
|
|
|
|
|
app_version?: string;
|
|
|
|
|
app_author?: string;
|
|
|
|
|
app_config?: any;
|
|
|
|
|
status?: number;
|
|
|
|
|
},
|
|
|
|
|
) {
|
|
|
|
|
return this.addonAppService.edit(parseInt(app_id), data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除插件应用
|
|
|
|
|
*/
|
|
|
|
|
@Delete('delete/:app_id')
|
|
|
|
|
async delete(@Param('app_id') app_id: string) {
|
|
|
|
|
return this.addonAppService.delete(parseInt(app_id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 安装插件应用
|
|
|
|
|
*/
|
|
|
|
|
@Post('install/:app_id')
|
|
|
|
|
async install(@Param('app_id') app_id: string) {
|
|
|
|
|
return this.addonAppService.install(parseInt(app_id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 卸载插件应用
|
|
|
|
|
*/
|
|
|
|
|
@Post('uninstall/:app_id')
|
|
|
|
|
async uninstall(@Param('app_id') app_id: string) {
|
|
|
|
|
return this.addonAppService.uninstall(parseInt(app_id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 启用插件应用
|
|
|
|
|
*/
|
|
|
|
|
@Post('enable/:app_id')
|
|
|
|
|
async enable(@Param('app_id') app_id: string) {
|
|
|
|
|
return this.addonAppService.enable(parseInt(app_id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 禁用插件应用
|
|
|
|
|
*/
|
|
|
|
|
@Post('disable/:app_id')
|
|
|
|
|
async disable(@Param('app_id') app_id: string) {
|
|
|
|
|
return this.addonAppService.disable(parseInt(app_id));
|
|
|
|
|
}
|
|
|
|
|
}
|