You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import { Controller, Get, Param, Post, Req, UseGuards } from '@nestjs/common';
|
|
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
|
import { Rank } from './rank.model';
|
|
import { RankService } from './rank.service';
|
|
|
|
@Controller('rank')
|
|
export class RankController {
|
|
constructor(private rankService: RankService) {}
|
|
|
|
@Get()
|
|
getRankList(): Promise<Rank[]> {
|
|
return this.rankService.findRankList();
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@Get('/:id')
|
|
getUserRank(@Param('id') userId: string): Promise<Rank> {
|
|
return this.rankService.findByUserLatest(userId);
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@Get('/:id/all')
|
|
getUserHistory(@Param('id') userId: string): Promise<Rank[]> {
|
|
return this.rankService.findByUser(userId);
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@Post('/add/20')
|
|
add20Points(@Req() req): Promise<Rank> {
|
|
return this.rankService.create(20, req.user.id);
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@Post('/add/60')
|
|
add60Points(@Req() req): Promise<Rank> {
|
|
return this.rankService.create(60, req.user.id);
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@Post('/add/100')
|
|
add100Points(@Req() req): Promise<Rank> {
|
|
return this.rankService.create(100, req.user.id);
|
|
}
|
|
}
|