Skip to content

Commit

Permalink
merge #342: DELETE 메서드의 반환 형식 수정
Browse files Browse the repository at this point in the history
[refactor] DELETE 메서드의 반환 형식 수정
  • Loading branch information
yaongmeow authored Dec 11, 2023
2 parents 41f1375 + 2b64201 commit ebdf3db
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 86 deletions.
18 changes: 8 additions & 10 deletions BE/src/postings/postings.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,16 @@ import {
ApiTags,
ApiUnauthorizedResponse,
} from '@nestjs/swagger';
import { Posting } from './entities/posting.entity';
import { Report } from './entities/report.entity';
import { AuthGuard } from '../auth/auth.guard';
import {
create_OK,
create_update_remove_OK,
findMyPosting_OK,
findOne_OK,
like_OK,
remove_OK,
report_OK,
searchByWord_OK,
search_OK,
update_OK,
} from './postings.swagger';

@ApiBearerAuth('accessToken')
Expand Down Expand Up @@ -74,7 +71,7 @@ export class PostingsController {
summary: '게시글 생성',
description: '사용자가 입력한 정보를 토대로 새로운 게시글을 생성합니다.',
})
@ApiCreatedResponse({ schema: { example: create_OK } })
@ApiCreatedResponse({ schema: { example: create_update_remove_OK } })
@ApiBadRequestResponse({
schema: {
example: {
Expand Down Expand Up @@ -166,7 +163,7 @@ export class PostingsController {
summary: '게시글 수정',
description: 'id 값에 해당되는 게시글을 수정합니다.',
})
@ApiOkResponse({ schema: { example: update_OK } })
@ApiOkResponse({ schema: { example: create_update_remove_OK } })
@ApiForbiddenResponse({
schema: {
example: {
Expand All @@ -180,7 +177,7 @@ export class PostingsController {
@Req() request,
@Param('id', ParseUUIDPipe) id: string,
@Body() updatePostingDto: UpdatePostingDto
) {
): Promise<{ id: string }> {
const userId = request['user'].id;
await this.postingsService.update(id, userId, updatePostingDto);
return { id };
Expand All @@ -191,7 +188,7 @@ export class PostingsController {
summary: '게시글 삭제',
description: 'id 값에 해당되는 게시글을 삭제합니다.',
})
@ApiOkResponse({ schema: { example: remove_OK } })
@ApiOkResponse({ schema: { example: create_update_remove_OK } })
@ApiForbiddenResponse({
schema: {
example: {
Expand All @@ -204,9 +201,10 @@ export class PostingsController {
async remove(
@Req() request,
@Param('id', ParseUUIDPipe) id: string
): Promise<Posting> {
): Promise<{ id: string }> {
const userId = request['user'].id;
return this.postingsService.remove(id, userId);
await this.postingsService.remove(id, userId);
return { id };
}

@Post(':id/like')
Expand Down
33 changes: 2 additions & 31 deletions BE/src/postings/postings.swagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,37 +100,8 @@ export const search_OK = [
},
];

export const create_OK = { id: 'c89f207a-f528-4d53-8ac2-1356fa22eb21' };

export const update_OK = { id: '4d365e7c-3e82-472d-bf87-7faf65d9377d' };

export const remove_OK = {
title: 'bread lover',
createdAt: '2023-11-28T09:14:32.247Z',
thumbnail: null,
startDate: '2023-08-16',
endDate: '2023-08-18',
days: 3,
period: '2박 3일',
headcount: '5인 이상',
budget: '10 - 50만 원',
location: '대전',
season: '여름',
vehicle: null,
theme: ['힐링', '맛집'],
withWho: ['가족'],
writer: {
id: '123456789012345678901234567890123456',
name: 'lemon',
avatar: null,
resourceId: 'temp',
socialType: 1,
email: '[email protected]',
allowedIp: ['아이피', '아이피'],
bannedIp: ['아이피', '아이피'],
},
likeds: [],
reports: [],
export const create_update_remove_OK = {
id: 'c89f207a-f528-4d53-8ac2-1356fa22eb21',
};

export const like_OK = { isLiked: false };
Expand Down
21 changes: 11 additions & 10 deletions BE/src/timelines/timelines.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@ import {
import { Timeline } from './entities/timeline.entity';
import { AuthGuard } from 'src/auth/auth.guard';
import {
create_OK,
create_update_remove_OK,
findAll_OK,
findCoordinates_OK,
findOne_OK,
remove_OK,
translate_OK,
update_OK,
} from './timelines.swagger';

@ApiBearerAuth('accessToken')
Expand Down Expand Up @@ -78,7 +76,7 @@ export class TimelinesController {
description: '사용자가 입력한 정보를 토대로 새로운 타임라인을 생성합니다.',
})
@ApiConsumes('multipart/form-data')
@ApiCreatedResponse({ schema: { example: create_OK } })
@ApiCreatedResponse({ schema: { example: create_update_remove_OK } })
@ApiForbiddenResponse({
schema: {
example: {
Expand All @@ -102,7 +100,7 @@ export class TimelinesController {
@Req() request,
@UploadedFile() image: Express.Multer.File,
@Body() createTimelineDto: CreateTimelineDto
) {
): Promise<{ id: string }> {
const userId = request['user'].id;
const { id } = await this.timelinesService.create(
userId,
Expand Down Expand Up @@ -177,7 +175,7 @@ export class TimelinesController {
description: 'id에 해당하는 타임라인을 수정합니다.',
})
@ApiConsumes('multipart/form-data')
@ApiOkResponse({ schema: { example: update_OK } })
@ApiOkResponse({ schema: { example: create_update_remove_OK } })
@ApiBadRequestResponse({
schema: {
example: {
Expand All @@ -192,7 +190,7 @@ export class TimelinesController {
@Param('id', ParseUUIDPipe) id: string,
@UploadedFile() image: Express.Multer.File,
@Body() updateTimelineDto: UpdateTimelineDto
) {
): Promise<{ id: string }> {
const userId = request['user'].id;
await this.timelinesService.update(id, userId, image, updateTimelineDto);
return { id };
Expand All @@ -203,9 +201,12 @@ export class TimelinesController {
summary: 'id에 해당하는 타임라인 삭제',
description: 'id에 해당하는 상세 타임라인을 삭제합니다.',
})
@ApiOkResponse({ schema: { example: remove_OK } })
async remove(@Param('id', ParseUUIDPipe) id: string): Promise<Timeline> {
return this.timelinesService.remove(id);
@ApiOkResponse({ schema: { example: create_update_remove_OK } })
async remove(
@Param('id', ParseUUIDPipe) id: string
): Promise<{ id: string }> {
await this.timelinesService.remove(id);
return { id };
}

@Get(':id/translate')
Expand Down
38 changes: 3 additions & 35 deletions BE/src/timelines/timelines.swagger.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,8 @@
export const create_OK = { id: 'f2a7a09c-70d4-46d1-84e1-67b2f8a8b30d' };

export const findOne_OK = {
id: '01d97f2b-515c-4a44-91b8-dfa48d806b00',
title: '두근두근 출발 날 😍',
day: 1,
description:
'서울역의 상징성은 정치적으로도 연관이 깊다. 호남선, 전라선, 장항선은 2004년 KTX 개통으로 인해서 용산역이 주 출발역으로 바뀌었을 때에 국회의원들이 들고 일어났다. 그 후 일부 KTX가 용산 경유 서울역 착발로 바뀌었다. 강릉선 KTX은 특히 서울역에서 영동 지방으로 직접 가는 정기 열차이며 서울역 착발임을 한국철도공사가 크게 알렸고, 이는 신의 한 수가 된다. 그 전에는 강원도 가는 기차는 청량리역이 진리였다. 영서 지방은 ITX-청춘 용산발 춘천행, DMZ-train 서울발 백마고지행 둘뿐이었다.',
image: null,
coordX: 126.970606917394,
coordY: 37.5546788388674,
date: '2023-08-16',
place: '서울역',
time: '07:30',
posting: {
id: '9a0396ba-4892-436a-a97c-58be59b59327',
title: '대전 여행😎 ',
createdAt: '2023-12-02T08:36:04.676Z',
thumbnail:
'123456789012345678901234567890123456/9a0396ba-4892-436a-a97c-58be59b59327e735eca5-21e8-4c0b-bbce-abd54f0643dc.jpg',
startDate: '2023-08-16',
endDate: '2023-08-18',
days: 3,
period: '2박 3일',
headcount: '5인 이상',
budget: '10 - 50만 원',
location: '대전',
season: '여름',
vehicle: null,
theme: ['힐링', '맛집'],
withWho: ['가족'],
},
export const create_update_remove_OK = {
id: 'f2a7a09c-70d4-46d1-84e1-67b2f8a8b30d',
};

export const update_OK = { id: 'f2a7a09c-70d4-46d1-84e1-67b2f8a8b30d' };

export const remove_OK = {
export const findOne_OK = {
id: '01d97f2b-515c-4a44-91b8-dfa48d806b00',
title: '두근두근 출발 날 😍',
day: 1,
Expand Down

0 comments on commit ebdf3db

Please sign in to comment.