Skip to content

Commit 31f053a

Browse files
committed
2 parents b5b46ea + f93b01a commit 31f053a

11 files changed

+50
-46
lines changed

src/matching/dto/get-matching.response.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class GetMatchingsResponse {
7070
description: '받은 매칭 수',
7171
example: 10,
7272
})
73-
matchingCount: number;
73+
matchingsCount: number;
7474

7575
@ApiProperty({
7676
description: '매칭 정보',

src/matching/matching.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export class MatchingService {
106106

107107
const response: GetMatchingsResponse = {
108108
isMatching: matchings.length > 0,
109-
matchingCount: matchings.length,
109+
matchingsCount: matchings.length,
110110
matching: matchings.map((matching) => {
111111
const requesterPost = matching.requester.posts[0];
112112

src/post-comment/dtos/get-comment.dto.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@ export class GetCommentsDto {
4343

4444
@ApiProperty({ example: '10' })
4545
@IsBoolean()
46-
totalComments: number;
46+
totalCount: number;
4747
}

src/post-comment/post-comment.controller.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class PostCommentController {
7575
},
7676
isCommentWriter: comment.user.id == currentUserId,
7777
})),
78-
totalComments: comments.length,
78+
totalCount: comments.length,
7979
};
8080

8181
return new BaseResponse(true, '댓글 목록 조회 성공', commenteResponse);

src/post-like/dtos/post-like.response.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ export class PostLikeResponseDto {
1717
example: 1,
1818
description: '좋아요 개수',
1919
})
20-
likeCount: number;
20+
postLikeCount: number;
2121
}

src/post-like/post-like.service.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export class PostLikeService {
102102
return {
103103
id: existingLike[0].post.id,
104104
isPostLike: existingLike[0].status === 'activated',
105-
likeCount:
105+
postLikeCount:
106106
existingLike[0].status === 'activated'
107107
? likeData.length + 1
108108
: likeData.length - 1,
@@ -118,7 +118,7 @@ export class PostLikeService {
118118
return {
119119
id: newLike.post.id,
120120
isPostLike: newLike.status === 'activated',
121-
likeCount: likeData.length + 1,
121+
postLikeCount: likeData.length + 1,
122122
};
123123
}
124124
}

src/post/dtos/post.response.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,13 @@ export class PostDetailResponse extends PostDetailDto {
134134
example: 10,
135135
description: '게시글에 달린 댓글 수입니다.',
136136
})
137-
commentCount: number;
137+
postCommentsCount: number;
138138

139139
@ApiProperty({
140140
example: 5,
141141
description: '게시글의 좋아요 수입니다.',
142142
})
143-
likeCount: number;
143+
postLikesCount: number;
144144

145145
@ApiProperty({
146146
example: false,

src/post/dtos/user-posts.response.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ class PostDto {
3535
example: 10,
3636
description: '게시글에 달린 댓글 수입니다.',
3737
})
38-
commentCount: number;
38+
postCommentsCount: number;
3939

4040
@ApiProperty({
4141
example: 5,
4242
description: '게시글의 좋아요 수입니다.',
4343
})
44-
likeCount: number;
44+
postLikesCount: number;
4545

4646
@ApiProperty({
4747
example: true,
@@ -66,23 +66,23 @@ export class GetMyPostsResponse {
6666
example: 20,
6767
description: '사용자의 게시글에 달린 총 댓글 수입니다.',
6868
})
69-
totalComments: number;
69+
totalPostCommentsCount: number;
7070

7171
@ApiProperty({
7272
example: 50,
7373
description: '사용자가 작성한 총 게시글 수입니다.',
7474
})
75-
totalPosts: number;
75+
totalPostsCount: number;
7676

7777
@ApiProperty({
7878
example: 100,
7979
description: '사용자가 받은 총 좋아요 수입니다.',
8080
})
81-
totalLikes: number;
81+
totalPostLikesCount: number;
8282
}
8383

8484
class OtherUserPostDto extends OmitType(PostDto, [
85-
'commentCount',
85+
'postCommentsCount',
8686
'isPostComment',
8787
]) {}
8888

@@ -97,11 +97,11 @@ export class GetOtherPostsResponse {
9797
example: 30,
9898
description: '다른 사용자가 작성한 총 게시글 수입니다.',
9999
})
100-
totalPosts: number;
100+
totalPostsCount: number;
101101

102102
@ApiProperty({
103103
example: 200,
104104
description: '다른 사용자가 받은 총 좋아요 수입니다.',
105105
})
106-
totalLikes: number;
106+
totalPostLikesCount: number;
107107
}

src/post/post.controller.ts

+1-19
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
PatchIsRepresentativeSwagger,
2525
PatchPostSwagger,
2626
} from './post.swagger';
27-
import { ApiBearerAuth, ApiQuery, ApiTags } from '@nestjs/swagger';
27+
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
2828
import { CreatePostRequest } from './dtos/post.request';
2929
import { BaseResponse } from 'src/common/response/dto';
3030
import { AuthGuard } from 'src/auth/guards/jwt.auth.guard';
@@ -48,24 +48,6 @@ export class PostController {
4848
constructor(private readonly postService: PostService) {}
4949
@Get()
5050
@GetPostsSwagger('게시글 리스트 조회 API')
51-
@ApiQuery({
52-
name: 'userId',
53-
required: false,
54-
description:
55-
'User ID가 제공되면 사용자 게시글 조회, 제공되지 않으면 전체 게시글이 조회됩니다. User ID가 현재 사용자면 내 게시물 조회, 다른 사용자면 다른 사용자 게시물 조회입니다.',
56-
type: Number,
57-
})
58-
@ApiQuery({
59-
name: 'page',
60-
required: false,
61-
description: '페이지 번호',
62-
type: Number,
63-
})
64-
@ApiQuery({
65-
name: 'take',
66-
required: false,
67-
description: '한 페이지에 불러올 데이터 개수',
68-
})
6951
async getPosts(
7052
@Req() req: Request,
7153
@Query() pageOptionsDto?: PageOptionsDto,

src/post/post.service.ts

+13-10
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ export class PostService {
6060
)
6161
.leftJoinAndSelect('post.postLikes', 'postLike')
6262
.where('post.status = :status', { status: 'activated' })
63+
.andWhere('post.user.id NOT IN (:currentUserId)', {
64+
currentUserId: [currentUserId],
65+
})
6366
.andWhere(
6467
blockedUserIds.length > 0
6568
? 'post.user.id NOT IN (:...blockedUserIds)'
@@ -170,12 +173,12 @@ export class PostService {
170173
isRepresentative: post.isRepresentative,
171174
isPostLike: this.checkIsPostLiked(post, currentUserId),
172175
isPostComment: this.checkIsPostCommented(post, currentUserId),
173-
likeCount: post.postLikes.length,
174-
commentCount: post.postComments.length,
176+
postLikesCount: post.postLikes.length,
177+
postCommentsCount: post.postComments.length,
175178
})),
176-
totalComments: this.calculateTotalComments(posts),
177-
totalPosts: posts.length,
178-
totalLikes: this.calculateTotalLikes(posts),
179+
totalPostCommentsCount: this.calculateTotalComments(posts),
180+
totalPostsCount: posts.length,
181+
totalPostLikesCount: this.calculateTotalLikes(posts),
179182
};
180183
}
181184

@@ -191,10 +194,10 @@ export class PostService {
191194
imageUrl: post.postImages[0]?.url,
192195
isRepresentative: post.isRepresentative,
193196
isPostLike: this.checkIsPostLiked(post, currentUserId),
194-
likeCount: post.postLikes.length,
197+
postLikesCount: post.postLikes.length,
195198
})),
196-
totalPosts: posts.length,
197-
totalLikes: this.calculateTotalLikes(posts),
199+
totalPostsCount: posts.length,
200+
totalPostLikesCount: this.calculateTotalLikes(posts),
198201
};
199202
}
200203

@@ -460,8 +463,8 @@ export class PostService {
460463
modelNumber: postClothing.clothing.modelNumber,
461464
url: postClothing.clothing.url,
462465
})),
463-
likeCount: post.postLikes.length,
464-
commentCount: post.postComments.length,
466+
postLikesCount: post.postLikes.length,
467+
postCommentsCount: post.postComments.length,
465468
isPostLike: this.checkIsPostLiked(post, currentUserId),
466469
createdAt: dayjs(post.createdAt).format('YYYY-MM-DDTHH:mm:ssZ'),
467470
updatedAt: dayjs(post.updatedAt).format('YYYY-MM-DDTHH:mm:ssZ'),

src/post/post.swagger.ts

+19
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
ApiInternalServerErrorResponse,
44
ApiNotFoundResponse,
55
ApiOkResponse,
6+
ApiQuery,
67
} from '@nestjs/swagger';
78
import { BaseSwaggerDecorator } from 'nestjs-swagger-decorator';
89
import { BaseResponse } from 'src/common/response/dto';
@@ -51,6 +52,24 @@ export function GetPostsSwagger(text: string) {
5152
ApiInternalServerErrorResponse({
5253
description: 'Internal Server Error',
5354
}),
55+
ApiQuery({
56+
name: 'userId',
57+
required: false,
58+
description:
59+
'User ID가 제공되면 사용자 게시글 조회, 제공되지 않으면 전체 게시글이 조회됩니다. User ID가 현재 사용자면 내 게시물 조회, 다른 사용자면 다른 사용자 게시물 조회입니다.',
60+
type: Number,
61+
}),
62+
ApiQuery({
63+
name: 'page',
64+
required: false,
65+
description: '페이지 번호',
66+
type: Number,
67+
}),
68+
ApiQuery({
69+
name: 'take',
70+
required: false,
71+
description: '한 페이지에 불러올 데이터 개수',
72+
}),
5473
],
5574
),
5675
);

0 commit comments

Comments
 (0)