You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.2 KiB
37 lines
1.2 KiB
import { Body, Controller, Get, Param, Post, UseGuards } from '@nestjs/common';
|
|
import { SeasonsService } from './seasons.service';
|
|
import { SeasonStandingsService } from 'src/season-standings/season-standings.service';
|
|
import { AuthGuard } from '@nestjs/passport';
|
|
import { JwtAuthGuard } from 'src/authz/authz.guard';
|
|
import { RolesGuard } from 'src/authorization/roles.guard';
|
|
import { Roles } from 'src/authorization/roles.decorator';
|
|
|
|
@Controller('seasons')
|
|
export class SeasonsController {
|
|
constructor(
|
|
private seasonsService: SeasonsService,
|
|
private seasonStandingsService: SeasonStandingsService,
|
|
) {}
|
|
|
|
@Get()
|
|
findAll() {
|
|
return this.seasonsService.findAll();
|
|
}
|
|
|
|
@Get(':id')
|
|
findOne(@Param() params: any) {
|
|
return this.seasonsService.findOne(params.id);
|
|
}
|
|
|
|
@Get(':id/refresh')
|
|
updateSeason(@Param() params: any) {
|
|
return this.seasonStandingsService.updateStandings(params.id);
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
|
@Post('create')
|
|
@Roles(['create:seasons'])
|
|
create(@Body() body: any) {
|
|
return this.seasonsService.create(body.title, body.subTitle, body.startingDate);
|
|
}
|
|
}
|
|
|