Skip to content

Commit

Permalink
Merge pull request #46 from Boost-Coder/feature/grade-delete-#45
Browse files Browse the repository at this point in the history
[#45] 학접 삭제 구현
  • Loading branch information
koomin1227 authored Apr 9, 2024
2 parents 3b74207 + 259ae6f commit 9963cc7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/grade/grade.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class GradeController {

@Delete(':id')
@UseGuards(OwnershipGuard)
public async deleteGrade() {
await this.gradeService.gradeDelete();
public async deleteGrade(@Param('id') userId: string) {
await this.gradeService.gradeDelete(userId);
}
}
4 changes: 3 additions & 1 deletion src/grade/grade.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,7 @@ export class GradeRepository extends BaseRepository {
);
}

public async delete(id: string) {}
public async delete(id: string) {
await this.repository.delete({ userId: id });
}
}
18 changes: 15 additions & 3 deletions src/grade/grade.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { BadRequestException, Injectable } from '@nestjs/common';
import {
BadRequestException,
Injectable,
NotFoundException,
} from '@nestjs/common';
import { GradeRepository } from './grade.repository';
import { Grade } from '../Entity/grade';

Expand All @@ -23,7 +27,7 @@ export class GradeService {
const isExist = await this.gradeRepository.findOne(userId);

if (!isExist) {
throw new BadRequestException('등록된 학점정보가 없습니다');
throw new NotFoundException('등록된 학점정보가 없습니다');
}

const newGrade = new Grade();
Expand All @@ -34,7 +38,15 @@ export class GradeService {
await this.gradeRepository.update(newGrade);
}

public async gradeDelete() {}
public async gradeDelete(userId: string) {
const isExist = await this.gradeRepository.findOne(userId);

if (!isExist) {
throw new NotFoundException('등록된 학점정보가 없습니다');
}

await this.gradeRepository.delete(userId);
}

public calculatePoint(grade: number) {
return 0;
Expand Down

0 comments on commit 9963cc7

Please sign in to comment.