Skip to content

Commit bb73948

Browse files
authored
post 관련 리소스 변수명 간소화 (#136)
2 parents 6dc5875 + baa5bcd commit bb73948

File tree

4 files changed

+100
-108
lines changed

4 files changed

+100
-108
lines changed

src/apis/free-post-comments/controllers/free-post-comments.controller.ts

+25-29
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ import { PutUpdateFreePostCommentDto } from '@src/apis/free-post-comments/dto/pu
2222
import { CreateReactionDto } from '@src/apis/reactions/dto/create-reaction.dto';
2323
import { RemoveReactionDto } from '@src/apis/reactions/dto/remove-reaction.dto';
2424
import { UserDto } from '@src/apis/users/dto/user.dto';
25+
import { ApiCommonResponse } from '@src/decorators/swagger/api-common-response.swagger';
2526
import { User } from '@src/decorators/user.decorator';
2627
import { ResponseType } from '@src/interceptors/success-interceptor/constants/success-interceptor.enum';
2728
import { SetResponse } from '@src/interceptors/success-interceptor/decorators/success-response.decorator';
2829
import { ParsePositiveIntPipe } from '@src/pipes/parse-positive-int.pipe';
2930
import { plainToInstance } from 'class-transformer';
3031
import { FreePostCommentsService } from '../services/free-post-comments.service';
31-
import { ApiCommonResponse } from '@src/decorators/swagger/api-common-response.swagger';
3232

3333
@ApiTags('free-post-comment')
3434
@ApiCommonResponse([HttpStatus.INTERNAL_SERVER_ERROR])
35-
@Controller('free-posts/:freePostId/comments')
35+
@Controller('free-posts/:postId/comments')
3636
export class FreePostCommentsController {
3737
constructor(
3838
private readonly freePostCommentsService: FreePostCommentsService,
@@ -43,13 +43,13 @@ export class FreePostCommentsController {
4343
@SetResponse({ key: 'freePostComment', type: ResponseType.Detail })
4444
@Post()
4545
create(
46-
@Param('freePostId', ParsePositiveIntPipe) freePostId: number,
46+
@Param('postId', ParsePositiveIntPipe) postId: number,
4747
@User() user: UserDto,
4848
@Body() createFreePostCommentDto: CreateFreePostCommentDto,
4949
): Promise<FreePostCommentDto> {
5050
return this.freePostCommentsService.create(
5151
user.id,
52-
freePostId,
52+
postId,
5353
createFreePostCommentDto,
5454
);
5555
}
@@ -60,12 +60,12 @@ export class FreePostCommentsController {
6060
@SetResponse({ type: ResponseType.Pagination, key: 'freePostComments' })
6161
@Get()
6262
async findAllAndCount(
63-
@Param('freePostId', ParsePositiveIntPipe) freePostId: number,
63+
@Param('postId', ParsePositiveIntPipe) postId: number,
6464
@Query() findFreePostCommentListQueryDto: FindFreePostCommentListQueryDto,
6565
): Promise<[FreePostCommentsItemDto[], number]> {
6666
const [freePosts, count] =
6767
await this.freePostCommentsService.findAllAndCount(
68-
freePostId,
68+
postId,
6969
findFreePostCommentListQueryDto,
7070
);
7171

@@ -75,17 +75,17 @@ export class FreePostCommentsController {
7575
@ApiFreePostComment.PutUpdate({ summary: '자유게시글 댓글 수정' })
7676
@SetResponse({ type: ResponseType.Detail, key: 'freePostComment' })
7777
@UseGuards(JwtAuthGuard)
78-
@Put(':freePostCommentId')
78+
@Put(':commentId')
7979
putUpdate(
8080
@User() user: UserDto,
81-
@Param('freePostId', ParsePositiveIntPipe) freePostId: number,
82-
@Param('freePostCommentId', ParsePositiveIntPipe) freePostCommentId: number,
81+
@Param('postId', ParsePositiveIntPipe) postId: number,
82+
@Param('commentId', ParsePositiveIntPipe) commentId: number,
8383
@Body() putUpdateFreePostCommentDto: PutUpdateFreePostCommentDto,
8484
): Promise<FreePostCommentDto> {
8585
return this.freePostCommentsService.putUpdate(
8686
user.id,
87-
freePostId,
88-
freePostCommentId,
87+
postId,
88+
commentId,
8989
putUpdateFreePostCommentDto,
9090
);
9191
}
@@ -95,35 +95,31 @@ export class FreePostCommentsController {
9595
})
9696
@SetResponse({ type: ResponseType.Delete })
9797
@UseGuards(JwtAuthGuard)
98-
@Delete(':freePostCommentId')
98+
@Delete(':commentId')
9999
remove(
100100
@User() user: UserDto,
101-
@Param('freePostId') freePostId: number,
102-
@Param('freePostCommentId', ParsePositiveIntPipe) freePostCommentId: number,
101+
@Param('postId', ParsePositiveIntPipe) postId: number,
102+
@Param('commentId', ParsePositiveIntPipe) commentId: number,
103103
): Promise<number> {
104-
return this.freePostCommentsService.remove(
105-
user.id,
106-
freePostId,
107-
freePostCommentId,
108-
);
104+
return this.freePostCommentsService.remove(user.id, postId, commentId);
109105
}
110106

111107
@ApiFreePostComment.CreateReaction({
112108
summary: '자유 게시글 댓글 reaction 생성',
113109
})
114110
@HttpCode(HttpStatus.NO_CONTENT)
115111
@UseGuards(JwtAuthGuard)
116-
@Post(':freePostCommentId/reaction')
112+
@Post(':commentId/reaction')
117113
createReaction(
118114
@User() user: UserDto,
119-
@Param('freePostId', ParsePositiveIntPipe) freePostId: number,
120-
@Param('freePostCommentId', ParsePositiveIntPipe) freePostCommentId: number,
115+
@Param('postId', ParsePositiveIntPipe) postId: number,
116+
@Param('commentId', ParsePositiveIntPipe) commentId: number,
121117
@Body() createReactionDto: CreateReactionDto,
122118
): Promise<void> {
123119
return this.freePostCommentsService.createReaction(
124120
user.id,
125-
freePostId,
126-
freePostCommentId,
121+
postId,
122+
commentId,
127123
createReactionDto,
128124
);
129125
}
@@ -133,17 +129,17 @@ export class FreePostCommentsController {
133129
})
134130
@HttpCode(HttpStatus.NO_CONTENT)
135131
@UseGuards(JwtAuthGuard)
136-
@Delete(':freePostCommentId/reaction')
132+
@Delete(':commentId/reaction')
137133
removeReaction(
138134
@User() user: UserDto,
139-
@Param('freePostId', ParsePositiveIntPipe) freePostId: number,
140-
@Param('freePostCommentId', ParsePositiveIntPipe) freePostCommentId: number,
135+
@Param('postId', ParsePositiveIntPipe) postId: number,
136+
@Param('commentId', ParsePositiveIntPipe) commentId: number,
141137
@Body() removeReactionDto: RemoveReactionDto,
142138
): Promise<void> {
143139
return this.freePostCommentsService.removeReaction(
144140
user.id,
145-
freePostId,
146-
freePostCommentId,
141+
postId,
142+
commentId,
147143
removeReactionDto,
148144
);
149145
}

src/apis/free-post-reply-comments/controllers/free-post-reply-comments.controller.ts

+37-41
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import { plainToInstance } from 'class-transformer';
3232

3333
@ApiTags('free-post-reply-comment')
3434
@ApiCommonResponse([HttpStatus.INTERNAL_SERVER_ERROR])
35-
@Controller('free-posts/:freePostId/comments/:freePostCommentId/reply')
35+
@Controller('free-posts/:postId/comments/:commentId/reply')
3636
export class FreePostReplyCommentsController {
3737
constructor(
3838
private readonly freePostReplyCommentsService: FreePostReplyCommentsService,
@@ -46,14 +46,14 @@ export class FreePostReplyCommentsController {
4646
@Post()
4747
create(
4848
@User() user: UserDto,
49-
@Param('freePostId', ParsePositiveIntPipe) freePostId: number,
50-
@Param('freePostCommentId', ParsePositiveIntPipe) freePostCommentId: number,
49+
@Param('postId', ParsePositiveIntPipe) postId: number,
50+
@Param('commentId', ParsePositiveIntPipe) commentId: number,
5151
@Body() createFreePostReplyCommentDto: CreateFreePostReplyCommentDto,
5252
): Promise<FreePostReplyCommentDto> {
5353
return this.freePostReplyCommentsService.create(
5454
user.id,
55-
freePostId,
56-
freePostCommentId,
55+
postId,
56+
commentId,
5757
createFreePostReplyCommentDto,
5858
);
5959
}
@@ -64,15 +64,15 @@ export class FreePostReplyCommentsController {
6464
@SetResponse({ type: ResponseType.Pagination, key: 'freePostReplyComments' })
6565
@Get()
6666
async findAllAndCount(
67-
@Param('freePostId', ParsePositiveIntPipe) freePostId: number,
68-
@Param('freePostCommentId', ParsePositiveIntPipe) freePostCommentId: number,
67+
@Param('postId', ParsePositiveIntPipe) postId: number,
68+
@Param('commentId', ParsePositiveIntPipe) commentId: number,
6969
@Query()
7070
findFreePostReplyCommentListQueryDto: FindFreePostReplyCommentListQueryDto,
7171
): Promise<[FreePostReplyCommentsItemDto[], number]> {
7272
const [freePosts, count] =
7373
await this.freePostReplyCommentsService.findAllAndCount(
74-
freePostId,
75-
freePostCommentId,
74+
postId,
75+
commentId,
7676
findFreePostReplyCommentListQueryDto,
7777
);
7878

@@ -84,20 +84,19 @@ export class FreePostReplyCommentsController {
8484
})
8585
@SetResponse({ type: ResponseType.Detail, key: 'freePostReplyComment' })
8686
@UseGuards(JwtAuthGuard)
87-
@Put(':freePostReplyCommentId')
87+
@Put(':replyId')
8888
putUpdate(
8989
@User() user: UserDto,
90-
@Param('freePostId', ParsePositiveIntPipe) freePostId: number,
91-
@Param('freePostCommentId', ParsePositiveIntPipe) freePostCommentId: number,
92-
@Param('freePostReplyCommentId', ParsePositiveIntPipe)
93-
freePostReplyCommentId: number,
90+
@Param('postId', ParsePositiveIntPipe) postId: number,
91+
@Param('commentId', ParsePositiveIntPipe) commentId: number,
92+
@Param('replyId', ParsePositiveIntPipe) replyId: number,
9493
@Body() putUpdateFreePostReplyCommentDto: PutUpdateFreePostReplyCommentDto,
9594
): Promise<FreePostReplyCommentDto> {
9695
return this.freePostReplyCommentsService.putUpdate(
9796
user.id,
98-
freePostId,
99-
freePostCommentId,
100-
freePostReplyCommentId,
97+
postId,
98+
commentId,
99+
replyId,
101100
putUpdateFreePostReplyCommentDto,
102101
);
103102
}
@@ -107,19 +106,18 @@ export class FreePostReplyCommentsController {
107106
})
108107
@SetResponse({ type: ResponseType.Delete })
109108
@UseGuards(JwtAuthGuard)
110-
@Delete(':freePostReplyCommentId')
109+
@Delete(':replyId')
111110
remove(
112111
@User() user: UserDto,
113-
@Param('freePostId') freePostId: number,
114-
@Param('freePostCommentId', ParsePositiveIntPipe) freePostCommentId: number,
115-
@Param('freePostReplyCommentId', ParsePositiveIntPipe)
116-
freePostReplyCommentId: number,
112+
@Param('postId', ParsePositiveIntPipe) postId: number,
113+
@Param('commentId', ParsePositiveIntPipe) commentId: number,
114+
@Param('replyId', ParsePositiveIntPipe) replyId: number,
117115
): Promise<number> {
118116
return this.freePostReplyCommentsService.remove(
119117
user.id,
120-
freePostId,
121-
freePostCommentId,
122-
freePostReplyCommentId,
118+
postId,
119+
commentId,
120+
replyId,
123121
);
124122
}
125123

@@ -128,20 +126,19 @@ export class FreePostReplyCommentsController {
128126
})
129127
@HttpCode(HttpStatus.NO_CONTENT)
130128
@UseGuards(JwtAuthGuard)
131-
@Post(':freePostReplyCommentId/reaction')
129+
@Post(':replyId/reaction')
132130
createReaction(
133131
@User() user: UserDto,
134-
@Param('freePostId', ParsePositiveIntPipe) freePostId: number,
135-
@Param('freePostCommentId', ParsePositiveIntPipe) freePostCommentId: number,
136-
@Param('freePostReplyCommentId', ParsePositiveIntPipe)
137-
freePostReplyCommentId: number,
132+
@Param('postId', ParsePositiveIntPipe) postId: number,
133+
@Param('commentId', ParsePositiveIntPipe) commentId: number,
134+
@Param('replyId', ParsePositiveIntPipe) replyId: number,
138135
@Body() createReactionDto: CreateReactionDto,
139136
): Promise<void> {
140137
return this.freePostReplyCommentsService.createReaction(
141138
user.id,
142-
freePostId,
143-
freePostCommentId,
144-
freePostReplyCommentId,
139+
postId,
140+
commentId,
141+
replyId,
145142
createReactionDto,
146143
);
147144
}
@@ -151,20 +148,19 @@ export class FreePostReplyCommentsController {
151148
})
152149
@HttpCode(HttpStatus.NO_CONTENT)
153150
@UseGuards(JwtAuthGuard)
154-
@Delete(':freePostReplyCommentId/reaction')
151+
@Delete(':replyId/reaction')
155152
removeReaction(
156153
@User() user: UserDto,
157-
@Param('freePostId', ParsePositiveIntPipe) freePostId: number,
158-
@Param('freePostCommentId', ParsePositiveIntPipe) freePostCommentId: number,
159-
@Param('freePostReplyCommentId', ParsePositiveIntPipe)
160-
freePostReplyCommentId: number,
154+
@Param('postId', ParsePositiveIntPipe) postId: number,
155+
@Param('commentId', ParsePositiveIntPipe) commentId: number,
156+
@Param('replyId', ParsePositiveIntPipe) replyId: number,
161157
@Body() removeReactionDto: RemoveReactionDto,
162158
): Promise<void> {
163159
return this.freePostReplyCommentsService.removeReaction(
164160
user.id,
165-
freePostId,
166-
freePostCommentId,
167-
freePostReplyCommentId,
161+
postId,
162+
commentId,
163+
replyId,
168164
removeReactionDto,
169165
);
170166
}

0 commit comments

Comments
 (0)