Skip to content

Commit

Permalink
[BE#468] user 삭제 api
Browse files Browse the repository at this point in the history
  • Loading branch information
yeongbinim authored Dec 14, 2023
1 parent af8d25f commit 3468387
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
28 changes: 18 additions & 10 deletions BE/src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
UploadedFile,
BadRequestException,
Patch,
Delete,
} from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { Response } from 'express';
Expand All @@ -30,7 +31,7 @@ import { FileInterceptor } from '@nestjs/platform-express';
import { ConfigService } from '@nestjs/config';
import { ENV } from 'src/common/const/env-keys.const';
import { getImageUrl } from 'src/common/utils/utils';
import { identity } from 'rxjs';
import { ResponseDto } from 'src/common/response.dto';

@ApiTags('로그인 페이지')
@Controller('auth')
Expand Down Expand Up @@ -145,14 +146,21 @@ export class AuthController {
async patchTimezone(
@User('id') user_id: number,
@Body('timezone') timezone: string,
): Promise<any> {
const updatedUser = await this.usersService.updateTimezone(
user_id,
timezone,
);
return {
statusCode: 200,
message: '타임존 설정 성공',
};
): Promise<ResponseDto> {
await this.usersService.updateTimezone(user_id, timezone);
return new ResponseDto(200, '타임존 설정 성공');
}

@Delete()
@UseGuards(AccessTokenGuard)
@ApiOperation({ summary: '유저 회원 탈퇴 (완)' })
@ApiResponse({
type: ResponseDto,
description: '카테고리 삭제 성공',
})
@ApiBearerAuth()
async deleteUser(@User('id') user_id: number): Promise<ResponseDto> {
await this.usersService.remove(user_id);
return new ResponseDto(200, '성공적으로 삭제되었습니다.');
}
}
7 changes: 7 additions & 0 deletions BE/src/users/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,11 @@ export class UsersService {
async s3Upload(file: Express.Multer.File): Promise<string> {
return this.s3Service.uploadFile(file);
}

remove(user_id: number) {
if (!user_id) {
throw new BadRequestException('인자의 형식이 잘못되었습니다.');
}
return this.usersRepository.delete(user_id);
}
}

0 comments on commit 3468387

Please sign in to comment.