Skip to content

Commit

Permalink
feat : 회원가입 즉시 최근 재생 목록 생성
Browse files Browse the repository at this point in the history
* PlaylistService 를 주입하여 signup 을 한 후에 최근 재생 목록 플레이리스트를 바로 생성하도록 구현
  • Loading branch information
khw3754 committed Nov 22, 2023
1 parent b6dd096 commit dcfd560
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
8 changes: 6 additions & 2 deletions server/src/auth/auth.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -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],
})
Expand Down
5 changes: 5 additions & 0 deletions server/src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -12,6 +13,7 @@ export class AuthService {
constructor(
@InjectRepository(User) private userRepository: Repository<User>,
private jwtService: JwtService,
private readonly playlistService: PlaylistService,
) {}

async login(email: string): Promise<{ accessToken: string }> {
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion server/src/playlist/playlist.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}

0 comments on commit dcfd560

Please sign in to comment.