Skip to content

Commit 887704e

Browse files
authored
Merge pull request #87 from oodd-team/dev
Dev
2 parents d327b40 + 4a20511 commit 887704e

24 files changed

Lines changed: 731 additions & 12266 deletions

package-lock.json

Lines changed: 0 additions & 12122 deletions
This file was deleted.

src/app.module.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import { AuthModule } from './auth/auth.module';
2222
import { DayjsModule } from './common/dayjs/dayjs.module'; // DayjsModule 추가
2323
import { EventsGateway } from './eventGateway';
2424
import { ConfigService } from '@nestjs/config';
25+
import { MatchingEventsGateway } from './matchingEventGateway';
26+
import { UserStyletagModule } from './user-styletag/user-styletag.module';
2527

2628
const configService: ConfigService = new ConfigService();
2729

@@ -64,8 +66,9 @@ const configService: ConfigService = new ConfigService();
6466
UserBlockModule,
6567
UserReportModule,
6668
AuthModule,
69+
UserStyletagModule,
6770
],
6871
controllers: [AppController],
69-
providers: [AppService, EventsGateway],
72+
providers: [AppService, EventsGateway, MatchingEventsGateway],
7073
})
7174
export class AppModule {}

src/auth/auth.controller.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { Controller, Get, Query, Req, Res, UseGuards } from '@nestjs/common';
1+
import {
2+
BadRequestException,
3+
Controller,
4+
Get,
5+
Query,
6+
Req,
7+
Res,
8+
UseGuards,
9+
} from '@nestjs/common';
210
import { UserService } from 'src/user/user.service';
311
import {
412
GetJwtInfoSwagger,
@@ -13,8 +21,6 @@ import { NaverAuthGuard } from './guards/naver.auth.guard';
1321
import { AuthGuard } from './guards/jwt.auth.guard';
1422
import { BaseResponse } from '../common/response/dto';
1523
import { GetUserInfo } from 'src/user/dto/response/user.response';
16-
import dayjs from 'dayjs';
17-
1824
@Controller('auth')
1925
@ApiTags('[서비스] Auth 관련')
2026
export class AuthController {
@@ -66,16 +72,12 @@ export class AuthController {
6672
@GetJwtInfoSwagger('JWT 토큰 정보 조회 API')
6773
@Get('/me')
6874
async test(@Req() req: Request): Promise<BaseResponse<GetUserInfo>> {
69-
const user = await this.userService.getUserById(req.user?.id);
70-
return new BaseResponse<GetUserInfo>(true, 'SUCCESS', {
71-
id: user.id,
72-
email: user.email,
73-
nickname: user.nickname,
74-
profilePictureUrl: user.profilePictureUrl,
75-
name: user.name,
76-
phoneNumber: user.phoneNumber,
77-
birthDate: dayjs(user.birthDate).format('YYYY-MM-DD'),
78-
bio: user.bio,
79-
});
75+
console.log(req.user);
76+
const user = await this.userService.getUserWithTag(req.user?.id);
77+
if (!user) throw new BadRequestException('User not found');
78+
79+
const userInfo = new GetUserInfo(user);
80+
81+
return new BaseResponse<GetUserInfo>(true, 'SUCCESS', userInfo);
8082
}
8183
}

src/auth/strategies/kakao.strategy.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { PassportStrategy } from '@nestjs/passport';
33
import { Profile, Strategy } from 'passport-kakao';
44
import { SocialUser } from '../dto/auth.dto';
55
import { ConfigService } from '@nestjs/config';
6-
import { Request } from 'express';
76

87
@Injectable()
98
export class JwtKakaoStrategy extends PassportStrategy(Strategy, 'kakao') {
@@ -16,19 +15,20 @@ export class JwtKakaoStrategy extends PassportStrategy(Strategy, 'kakao') {
1615
});
1716
}
1817

19-
async authenticate(req: Request) {
18+
authenticate(req: any, options?: any) {
2019
if (req.query.redirectUrl) {
2120
// /auth
2221
return super.authenticate(req, {
22+
...options,
2323
state: encodeURIComponent(req.query.redirectUrl as string),
2424
});
2525
}
2626
// /auth/callback
27-
return super.authenticate(req);
27+
return super.authenticate(req, options);
2828
}
2929

3030
async validate(
31-
req: Request,
31+
req: any,
3232
accessToken: string,
3333
refreshToken: string,
3434
profile: Profile,

src/chat-message/chat-message.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { InjectRepository } from '@nestjs/typeorm';
33
import { ChatMessage } from 'src/common/entities/chat-message.entity';
44
import { ChatRoom } from 'src/common/entities/chat-room.entity';
55
import { StatusEnum } from 'src/common/enum/entityStatus';
6-
import { CreateMatchingReqeust } from 'src/matching/dto/matching.request';
6+
import { CreateMatchingRequest } from 'src/matching/dto/matching.request';
77
import { QueryRunner, Repository } from 'typeorm';
88

99
@Injectable()
@@ -80,7 +80,7 @@ export class ChatMessageService {
8080
async createChatMessage(
8181
queryRunner: QueryRunner,
8282
chatRoom: ChatRoom,
83-
body: CreateMatchingReqeust,
83+
body: CreateMatchingRequest,
8484
): Promise<ChatMessage> {
8585
return queryRunner.manager.save(ChatMessage, {
8686
chatRoom: chatRoom,

src/chat-room/chat-room.service.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Matching } from 'src/common/entities/matching.entity';
66
import { StatusEnum } from 'src/common/enum/entityStatus';
77
import { MatchingRequestStatusEnum } from 'src/common/enum/matchingRequestStatus';
88
import { DataNotFoundException } from 'src/common/exception/service.exception';
9-
import { CreateMatchingReqeust } from 'src/matching/dto/matching.request';
9+
import { CreateMatchingRequest } from 'src/matching/dto/matching.request';
1010
import { Repository, QueryRunner } from 'typeorm';
1111

1212
@Injectable()
@@ -60,6 +60,7 @@ export class ChatRoomService {
6060

6161
const latestMessage =
6262
room.chatMessages.length > 0 ? room.chatMessages[0] : null; // 가장 최근 메시지 선택
63+
6364
return {
6465
id: room.id,
6566
otherUser: otherUserInfo,
@@ -72,7 +73,7 @@ export class ChatRoomService {
7273
async createChatRoom(
7374
queryRunner: QueryRunner,
7475
matching: Matching,
75-
body: CreateMatchingReqeust,
76+
body: CreateMatchingRequest,
7677
): Promise<ChatRoom> {
7778
// 채팅방 생성 로직
7879
return await queryRunner.manager.save(ChatRoom, {
@@ -116,6 +117,7 @@ export class ChatRoomService {
116117
matching: { id: matchingId },
117118
},
118119
relations: ['matching'],
120+
withDeleted: true, // 소프트 딜리트된 데이터도 조회
119121
});
120122
}
121123
}

src/common/entities/styletag.entity.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Entity, Column, OneToMany } from 'typeorm';
22
import { BaseEntity } from './base.entity';
33
import { PostStyletag } from './post-styletag.entity';
4+
import { UserStyletag } from './user-styletag.entity';
45

56
@Entity('Styletag')
67
export class Styletag extends BaseEntity {
@@ -9,4 +10,7 @@ export class Styletag extends BaseEntity {
910

1011
@OneToMany(() => PostStyletag, (postStyletag) => postStyletag.styletag)
1112
postStyletags!: PostStyletag[];
13+
14+
@OneToMany(() => UserStyletag, (userStyletag) => userStyletag.styletag)
15+
userStyletags!: UserStyletag[];
1216
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Entity, JoinColumn, ManyToOne } from 'typeorm';
2+
import { BaseEntity } from './base.entity';
3+
import { Styletag } from './styletag.entity';
4+
import { User } from './user.entity';
5+
6+
@Entity('UserStyletag')
7+
export class UserStyletag extends BaseEntity {
8+
@ManyToOne(() => User, (user) => user.userStyletags)
9+
@JoinColumn({ name: 'userId' })
10+
user!: User;
11+
12+
@ManyToOne(() => Styletag, (styletag) => styletag.userStyletags)
13+
@JoinColumn({ name: 'styletagId' })
14+
styletag!: Styletag;
15+
}

src/common/entities/user.entity.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { PostLike } from './post-like.entity';
88
import { PostReport } from './post-report.entity';
99
import { ChatMessage } from './chat-message.entity';
1010
import { ApiProperty } from '@nestjs/swagger';
11+
import { UserStyletag } from './user-styletag.entity';
1112

1213
@Entity('User')
1314
export class User extends BaseEntity {
@@ -96,6 +97,9 @@ export class User extends BaseEntity {
9697
@OneToMany(() => PostReport, (postReport) => postReport.reporter)
9798
postReports!: PostReport[];
9899

100+
@OneToMany(() => UserStyletag, (userStyletag) => userStyletag.user)
101+
userStyletags!: UserStyletag[];
102+
99103
// 대표 게시물 필드 추가
100104
@OneToOne(() => Post, (post) => post.user)
101105
representativePost?: Post | null;

src/matching/dto/matching.request.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ApiProperty } from '@nestjs/swagger';
22
import { IsIn, IsInt, IsString, MaxLength, MinLength } from 'class-validator';
33

4-
export class CreateMatchingReqeust {
4+
export class CreateMatchingRequest {
55
@ApiProperty({ example: 1, description: '신청하는 유저 아이디' })
66
@IsInt()
77
requesterId: number;
@@ -21,6 +21,10 @@ export class CreateMatchingReqeust {
2121
}
2222

2323
export class PatchMatchingRequest {
24+
@ApiProperty({ example: 1, description: '매칭 아이디' })
25+
@IsInt()
26+
id: number;
27+
2428
@ApiProperty({
2529
example: 'accept',
2630
enum: ['accept', 'reject'],

0 commit comments

Comments
 (0)