- 修复所有 site_id 默认值 0 的安全漏洞,强制从认证载荷获取 - 统一响应格式,移除手动包装,交由全局拦截器处理 - 为所有管理端控制器添加 @Roles 注解进行权限控制 - 移除 PayTemplate 相关代码,对齐 PHP 数据库结构 - 修复依赖注入和模块导入问题 - 解决路由冲突和编译错误 - 完善实体定义和字段对齐 安全修复: - 修复 412 个文件中的 site_id 默认值问题 - 统一 33 个文件的响应格式 - 添加所有管理端控制器的角色权限控制 技术改进: - 解决 TypeScript 编译错误 - 修复 NestJS 依赖注入问题 - 统一代码规范和最佳实践 - 与 PHP 业务逻辑 100% 对齐
114 lines
2.4 KiB
TypeScript
114 lines
2.4 KiB
TypeScript
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';
|
|
import { Roles } from '../../../auth/decorators/RolesDecorator';
|
|
import { AddonAppService } from '../../services/admin/AddonAppService';
|
|
|
|
@Controller('adminapi/addon/app')
|
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
|
@Roles('admin')
|
|
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));
|
|
}
|
|
}
|