From 6661897521988bdfdb71dd9184ea4f8c862abb43 Mon Sep 17 00:00:00 2001 From: koomin1227 Date: Wed, 12 Jun 2024 01:00:01 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20=EC=97=AD=EB=9F=89=EC=9D=98=20=EC=A0=90?= =?UTF-8?q?=EC=88=98=EC=99=80=20=EC=9C=A0=EC=A0=80=EC=9D=98=20=EB=8B=89?= =?UTF-8?q?=EB=84=A4=EC=9E=84=20=EA=B0=99=EC=9D=B4=20=EB=B0=98=ED=99=98=20?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stat/dto/rank-find.dto.ts | 32 +++++++++++++++++++++++++++++++- src/stat/rank.controller.ts | 21 +++++++++++++++++++-- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/stat/dto/rank-find.dto.ts b/src/stat/dto/rank-find.dto.ts index 96c07ad..dc0f674 100644 --- a/src/stat/dto/rank-find.dto.ts +++ b/src/stat/dto/rank-find.dto.ts @@ -20,10 +20,40 @@ export class RankFindDto { @ApiProperty() grade: number; - constructor(total, algorithm, github, grade) { + @ApiProperty() + totalScore: number; + + @ApiProperty() + algorithmScore: number; + + @ApiProperty() + githubScore: number; + + @ApiProperty() + gradeScore: number; + + @ApiProperty() + nickname: string; + + constructor( + total, + algorithm, + github, + grade, + totalScore, + algorithmScore, + githubScore, + gradeScore, + nickname, + ) { this.total = total; this.algorithm = algorithm; this.github = github; this.grade = grade; + this.totalScore = totalScore; + this.algorithmScore = algorithmScore; + this.githubScore = githubScore; + this.gradeScore = gradeScore; + this.nickname = nickname; } } diff --git a/src/stat/rank.controller.ts b/src/stat/rank.controller.ts index 61d053d..157809a 100644 --- a/src/stat/rank.controller.ts +++ b/src/stat/rank.controller.ts @@ -1,4 +1,11 @@ -import { Controller, Get, Param, Query, UseGuards } from '@nestjs/common'; +import { + BadRequestException, + Controller, + Get, + Param, + Query, + UseGuards, +} from '@nestjs/common'; import { JwtAuthGuard } from '../auth/guard/jwt-auth.guard'; import { AlgorithmService } from './service/algorithm.service'; import { RankListDto, RankListOptionDto } from './dto/rank-list-option.dto'; @@ -155,33 +162,43 @@ export class RankController { const user = await this.userService.findUserByUserId(userId); if (options.major && user.major !== options.major) { - return new RankFindDto(null, null, null, null); + throw new BadRequestException(); } else { const algorithmRank = await this.algorithmService.getIndividualAlgorithmRank( userId, options, ); + const algorithm = await this.algorithmService.findAlgorithm(userId); const githubRank = await this.githubService.getIndividualGithubRank( userId, options, ); + const github = await this.githubService.findGithub(userId); const gradeRank = await this.gradeService.getIndividualGradeRank( userId, options, ); + const grade = await this.gradeService.findGrade(userId); const totalRank = await this.totalService.getIndividualTotalRank( userId, options, ); + const total = await this.totalService.findStat(userId); + return new RankFindDto( totalRank ? totalRank.rank : null, algorithmRank ? algorithmRank.rank : null, githubRank ? githubRank.rank : null, gradeRank ? gradeRank.rank : null, + total ? total.totalPoint : null, + algorithm ? algorithm.score : null, + github ? github.score : null, + grade ? grade.score : null, + user.nickname, ); } }