From dcfd56029cd43f2dda964caf89ec3771930a6b2c Mon Sep 17 00:00:00 2001 From: hyungun Date: Wed, 22 Nov 2023 20:58:07 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20=ED=9A=8C=EC=9B=90=EA=B0=80=EC=9E=85?= =?UTF-8?q?=20=EC=A6=89=EC=8B=9C=20=EC=B5=9C=EA=B7=BC=20=EC=9E=AC=EC=83=9D?= =?UTF-8?q?=20=EB=AA=A9=EB=A1=9D=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * PlaylistService 를 주입하여 signup 을 한 후에 최근 재생 목록 플레이리스트를 바로 생성하도록 구현 --- server/src/auth/auth.module.ts | 8 ++++++-- server/src/auth/auth.service.ts | 5 +++++ server/src/playlist/playlist.module.ts | 6 +++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/server/src/auth/auth.module.ts b/server/src/auth/auth.module.ts index 37a18b2..1159b2c 100644 --- a/server/src/auth/auth.module.ts +++ b/server/src/auth/auth.module.ts @@ -7,6 +7,10 @@ import { TypeOrmModule } from '@nestjs/typeorm'; import { User } from 'src/entity/user.entity'; import { AuthController } from './auth.controller'; import { AuthService } from './auth.service'; +import { PlaylistService } from 'src/playlist/playlist.service'; +import { Playlist } from 'src/entity/playlist.entity'; +import { Music } from 'src/entity/music.entity'; +import { Music_Playlist } from 'src/entity/music_playlist.entity'; @Module({ imports: [ @@ -19,9 +23,9 @@ import { AuthService } from './auth.service'; }), inject: [ConfigService], }), - TypeOrmModule.forFeature([User]), + TypeOrmModule.forFeature([User, Playlist, Music, Music_Playlist]), ], - providers: [JwtStrategy, AuthService], + providers: [JwtStrategy, AuthService, PlaylistService], exports: [JwtStrategy, PassportModule], controllers: [AuthController], }) diff --git a/server/src/auth/auth.service.ts b/server/src/auth/auth.service.ts index c43b711..31b6da2 100644 --- a/server/src/auth/auth.service.ts +++ b/server/src/auth/auth.service.ts @@ -4,6 +4,7 @@ import { InjectRepository } from '@nestjs/typeorm'; import { UserCreateDto } from 'src/dto/userCreate.dto'; import { User } from 'src/entity/user.entity'; import { HTTP_STATUS_CODE } from 'src/httpStatusCode.enum'; +import { PlaylistService } from 'src/playlist/playlist.service'; import { Repository } from 'typeorm'; import { v4 as uuid } from 'uuid'; @@ -12,6 +13,7 @@ export class AuthService { constructor( @InjectRepository(User) private userRepository: Repository, private jwtService: JwtService, + private readonly playlistService: PlaylistService, ) {} async login(email: string): Promise<{ accessToken: string }> { @@ -49,6 +51,9 @@ export class AuthService { }); await this.userRepository.save(newUser); + this.playlistService.createPlaylist(newUser.user_id, { + title: '최근 재생 목록', + }); return this.login(email); } throw new HttpException('WRONG_TOKEN', HTTP_STATUS_CODE.WRONG_TOKEN); diff --git a/server/src/playlist/playlist.module.ts b/server/src/playlist/playlist.module.ts index 3e4d88a..b458076 100644 --- a/server/src/playlist/playlist.module.ts +++ b/server/src/playlist/playlist.module.ts @@ -8,8 +8,12 @@ import { Music_Playlist } from 'src/entity/music_playlist.entity'; import { Music } from 'src/entity/music.entity'; @Module({ - imports: [TypeOrmModule.forFeature([Playlist, Music_Playlist, Music]), AuthModule], + imports: [ + TypeOrmModule.forFeature([Playlist, Music_Playlist, Music]), + AuthModule, + ], controllers: [PlaylistController], providers: [PlaylistService], + exports: [PlaylistService], }) export class PlaylistModule {}