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 { AppService } from '../../services/admin/AppService'; @Controller('adminapi/sys/app') @UseGuards(JwtAuthGuard, RolesGuard) export class AppController { constructor(private readonly appService: AppService) {} /** * 应用列表 */ @Get('lists') async lists(@Query() query: any) { return this.appService.getPage(query); } /** * 应用信息 */ @Get('info/:app_id') async info(@Param('app_id') app_id: string) { return this.appService.getInfo(parseInt(app_id)); } /** * 添加应用 */ @Post('add') async add(@Body() data: { app_name: string; app_key: string; app_secret: string; app_type: string; status?: number; description?: string; }) { return this.appService.add(data); } /** * 编辑应用 */ @Put('edit/:app_id') async edit( @Param('app_id') app_id: string, @Body() data: { app_name?: string; app_key?: string; app_secret?: string; app_type?: string; status?: number; description?: string; }, ) { return this.appService.edit(parseInt(app_id), data); } /** * 删除应用 */ @Delete('delete/:app_id') async delete(@Param('app_id') app_id: string) { return this.appService.delete(parseInt(app_id)); } /** * 获取应用类型 */ @Get('types') async getTypes() { return this.appService.getTypes(); } }