Skip to content

Commit 2c565f2

Browse files
committed
feat: 게시글 형변환, matching 수정
1 parent b9871a6 commit 2c565f2

File tree

6 files changed

+20
-4
lines changed

6 files changed

+20
-4
lines changed

src/auth/strategies/jwt.strategy.ts

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export class JwtStrategy extends PassportStrategy(Strategy) {
2626
if (!user) {
2727
throw UnauthorizedException('유효하지 않은 토큰입니다.');
2828
}
29-
console.log(user);
3029
return { id: payload.id, email: payload.email, nickname: payload.nickname };
3130
}
3231
}
+6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
import { Entity, Column, ManyToOne, JoinColumn } from 'typeorm';
22
import { BaseEntity } from './base.entity';
33
import { Post } from './post.entity';
4+
import { ApiProperty } from '@nestjs/swagger';
45

56
@Entity('PostImage')
67
export class PostImage extends BaseEntity {
78
@ManyToOne(() => Post, (post) => post.postImages)
89
@JoinColumn({ name: 'postId' })
910
post!: Post;
1011

12+
@ApiProperty({
13+
example: 'http://imageurl.example',
14+
description: '게시글 이미지 URL',
15+
})
1116
@Column({ type: 'text' })
1217
url!: string;
1318

19+
@ApiProperty({ example: 1, description: '게시글 이미지 순서' })
1420
@Column({ type: 'bigint' })
1521
orderNum!: number;
1622
}

src/main.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ import { IoAdapter } from '@nestjs/platform-socket.io';
88
async function bootstrap() {
99
const app = await NestFactory.create(AppModule);
1010
app.useGlobalFilters(new ServiceExceptionToHttpExceptionFilter());
11-
app.useGlobalPipes(new ValidationPipe());
11+
app.useGlobalPipes(
12+
new ValidationPipe({
13+
transform: true,
14+
}),
15+
);
1216
app.useWebSocketAdapter(new IoAdapter(app));
1317
setupSwagger(app);
1418
await app.listen(process.env.PORT);

src/matching/matching.service.ts

+3
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ export class MatchingService {
117117
.andWhere('matching.status = :activated', {
118118
activated: StatusEnum.ACTIVATED,
119119
})
120+
.andWhere('requester.status = :activated', {
121+
activated: StatusEnum.ACTIVATED,
122+
})
120123
.orderBy(
121124
// 우선순위: isRepresentative가 true인 게시물 먼저, 그 다음은 최신 게시물
122125
'CASE WHEN post.isRepresentative = true THEN 0 ELSE 1 END',

src/post/dto/all-posts.response.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ export class PostDto extends GetAllPostDto {
2828
this.id = post.id;
2929
this.content = post.content;
3030
this.createdAt = dayjs(post.createdAt).format('YYYY-MM-DDTHH:mm:ssZ');
31-
this.postImages = post.postImages ?? [];
31+
this.postImages =
32+
post.postImages.map((image) => ({
33+
...image,
34+
orderNum: Number(image.orderNum), // 강제로 숫자로 변환
35+
})) ?? [];
3236
this.isPostLike = post.postLikes.length > 0 ? true : false;
3337
this.requestStatus = requestStatus;
3438
this.user = new UserDto(post.user);

src/post/dto/dto/get-all-posts.dto.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class PostImageDto extends PickType(PostImage, [
2727
super();
2828
this.id = postImage.id;
2929
this.url = postImage.url;
30-
this.orderNum = postImage.orderNum;
30+
this.orderNum = Number(postImage.orderNum);
3131
}
3232
}
3333

0 commit comments

Comments
 (0)