Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 3x 3x 9x 1x 1x 9x 5x 5x 9x 5x 5x 1x 4x 1x 9x 1x 1x 9x 5x 5x | import {
BadRequestException,
Body,
Controller,
Delete,
Get,
Post,
Put,
Query,
Req,
UseGuards,
} from '@nestjs/common';
import { AuthGuard } from '../auth/auth.guard';
import { BandApplicationService } from './band-application.service';
import { ApiRequest } from '../auth/types/api-request';
import { ApplyForSlotDto } from './dto/apply-for-slot.dto';
import {
ApiBearerAuth,
ApiBody,
ApiOperation,
ApiQuery,
ApiTags,
} from '@nestjs/swagger';
import { StatusDto } from './dto/status.dto';
@ApiTags('Applications')
@ApiBearerAuth()
@Controller('applications')
@UseGuards(AuthGuard)
export class BandApplicationController {
constructor(private readonly applicationService: BandApplicationService) {}
@Get('applicable-slots')
@ApiOperation({ summary: 'Get applicable slots for the user' })
async getApplicationSlots(@Req() req: ApiRequest) {
const userId = req.user.userId;
return this.applicationService.getApplicationSlots(userId);
}
@Get('inbox')
@ApiOperation({ summary: 'Get applications inbox for the user' })
async getApplicationsInbox(@Req() req: ApiRequest) {
const userId = req.user.userId;
return this.applicationService.getApplicationsInbox(userId);
}
@Post()
@ApiOperation({ summary: 'Apply for a slot' })
@ApiBody({
type: ApplyForSlotDto,
description: 'Details for applying to a slot',
})
async applyForSlot(
@Req() req: ApiRequest,
@Body() applyForSlotDto: ApplyForSlotDto,
) {
const userId = req.user.userId;
return this.applicationService.applyForSlot(userId, applyForSlotDto);
}
@Delete()
@ApiOperation({ summary: 'Delete an application by ID' })
@ApiQuery({
name: 'id',
type: String,
description: 'ID of the application to delete',
})
async deleteApplication(@Req() req: ApiRequest, @Query('id') id: string) {
const userId = req.user.userId;
if (!id) {
throw new BadRequestException('Application id is required');
}
await this.applicationService.deleteApplication(userId, id);
return {
message: `Application with id ${id} has been successfully deleted`,
};
}
@Get()
@ApiOperation({ summary: 'Get all applications for the user' })
async getApplications(@Req() req: ApiRequest) {
const userId = req.user.userId;
return this.applicationService.getApplications(userId);
}
@Put('status')
async updateApplicationStatus(
@Req() req: ApiRequest,
@Body() applicationStatusDto: StatusDto,
) {
const userId = req.user.userId;
return this.applicationService.updateApplicationResult(
applicationStatusDto,
userId,
);
}
}
|