forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrestore.controller.ts
More file actions
36 lines (33 loc) · 1.66 KB
/
Copy pathrestore.controller.ts
File metadata and controls
36 lines (33 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { Controller, Post, Param, UseGuards } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse, ApiParam, ApiBearerAuth } from '@nestjs/swagger';
import { SoftDeleteService } from './soft-delete.service';
import { Split } from '../entities/split.entity';
import { Participant } from '../entities/participant.entity';
// Admin guard: uncomment and use when auth is configured
// import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
// import { RolesGuard } from '../security/roles.guard';
// import { Roles } from '../security/roles.decorator';
@ApiTags('Admin')
@Controller('admin')
// @UseGuards(JwtAuthGuard, RolesGuard)
// @Roles('admin')
// @ApiBearerAuth()
export class RestoreController {
constructor(private readonly softDeleteService: SoftDeleteService) {}
@Post('splits/:id/restore')
@ApiOperation({ summary: 'Restore a soft-deleted split (admin only)' })
@ApiParam({ name: 'id', description: 'Split UUID' })
@ApiResponse({ status: 200, description: 'Split restored' })
@ApiResponse({ status: 404, description: 'Split not found or not soft-deleted' })
async restoreSplit(@Param('id') id: string): Promise<Split> {
return this.softDeleteService.restoreSplit(id);
}
@Post('participants/:id/restore')
@ApiOperation({ summary: 'Restore a soft-deleted participant (admin only)' })
@ApiParam({ name: 'id', description: 'Participant UUID' })
@ApiResponse({ status: 200, description: 'Participant restored' })
@ApiResponse({ status: 404, description: 'Participant not found or not soft-deleted' })
async restoreParticipant(@Param('id') id: string): Promise<Participant> {
return this.softDeleteService.restoreParticipant(id);
}
}