diff --git a/packages/backend/src/alarm/alarm.controller.ts b/packages/backend/src/alarm/alarm.controller.ts index 98b28e08..9d3586fb 100644 --- a/packages/backend/src/alarm/alarm.controller.ts +++ b/packages/backend/src/alarm/alarm.controller.ts @@ -45,6 +45,45 @@ export class AlarmController { return await this.alarmService.create(alarmRequest, userId); } + @Get('user') + @ApiOperation({ + summary: '사용자별 알림 조회', + description: '사용자 아이디를 기준으로 모든 알림을 조회한다.', + }) + @ApiOkResponse({ + description: '사용자에게 등록되어 있는 모든 알림 조회', + type: [AlarmResponse], + }) + @UseGuards(SessionGuard) + async getByUserId(@GetUser() user: User) { + const userId = user.id; + + return await this.alarmService.findByUserId(userId); + } + + @Get('stock/:stockId') + @ApiOperation({ + summary: '주식별 알림 조회', + description: '주식 아이디를 기준으로 알림을 조회한다.', + }) + @ApiOkResponse({ + description: + '주식 아이디에 등록되어 있는 알림 중 유저에 해당하는 알림 조회', + type: [AlarmResponse], + }) + @ApiParam({ + name: 'id', + type: String, + description: '주식 아이디', + example: '005930', + }) + @UseGuards(SessionGuard) + async getByStockId(@Param('id') stockId: string, @GetUser() user: User) { + const userId = user.id; + + return await this.alarmService.findByStockId(stockId, userId); + } + @Get(':id') @ApiOperation({ summary: '등록된 알림 확인', @@ -110,43 +149,4 @@ export class AlarmController { return new AlarmSuccessResponse('알림 삭제를 성공했습니다.'); } - - @Get('user') - @ApiOperation({ - summary: '사용자별 알림 조회', - description: '사용자 아이디를 기준으로 모든 알림을 조회한다.', - }) - @ApiOkResponse({ - description: '사용자에게 등록되어 있는 모든 알림 조회', - type: [AlarmResponse], - }) - @UseGuards(SessionGuard) - async getByUserId(@GetUser() user: User) { - const userId = user.id; - - return await this.alarmService.findByUserId(userId); - } - - @Get('stock/:stockId') - @ApiOperation({ - summary: '주식별 알림 조회', - description: '주식 아이디를 기준으로 알림을 조회한다.', - }) - @ApiOkResponse({ - description: - '주식 아이디에 등록되어 있는 알림 중 유저에 해당하는 알림 조회', - type: [AlarmResponse], - }) - @ApiParam({ - name: 'id', - type: String, - description: '주식 아이디', - example: '005930', - }) - @UseGuards(SessionGuard) - async getByStockId(@Param('stockId') stockId: string, @GetUser() user: User) { - const userId = user.id; - - return await this.alarmService.findByStockId(stockId, userId); - } } diff --git a/packages/backend/src/alarm/alarm.service.ts b/packages/backend/src/alarm/alarm.service.ts index d8e6343d..6b8eb969 100644 --- a/packages/backend/src/alarm/alarm.service.ts +++ b/packages/backend/src/alarm/alarm.service.ts @@ -47,11 +47,12 @@ export class AlarmService { return result.map((val) => new AlarmResponse(val)); } - async findByStockId(stockId: string, userId: number): Promise { - return await this.alarmRepository.find({ + async findByStockId(stockId: string, userId: number) { + const result = await this.alarmRepository.find({ where: { stock: { id: stockId }, user: { id: userId } }, relations: ['user', 'stock'], }); + return result.map((val) => new AlarmResponse(val)); } async findOne(id: number) { diff --git a/packages/backend/src/alarm/domain/alarm.entity.ts b/packages/backend/src/alarm/domain/alarm.entity.ts index 4d33d215..c3461198 100644 --- a/packages/backend/src/alarm/domain/alarm.entity.ts +++ b/packages/backend/src/alarm/domain/alarm.entity.ts @@ -26,7 +26,13 @@ export class Alarm { @Column({ type: 'int', name: 'target_price', nullable: true }) targetPrice?: number; - @Column({ type: 'bigint', name: 'target_volume', nullable: true }) + @Column({ + type: 'decimal', + precision: 15, + scale: 2, + name: 'target_volume', + nullable: true, + }) targetVolume?: number; @Column({ type: 'timestamp', name: 'alarm_date', nullable: true }) diff --git a/packages/backend/src/auth/auth.module.ts b/packages/backend/src/auth/auth.module.ts index bb43faf7..f5bb46a0 100644 --- a/packages/backend/src/auth/auth.module.ts +++ b/packages/backend/src/auth/auth.module.ts @@ -1,9 +1,9 @@ import { Module } from '@nestjs/common'; import { PassportModule } from '@nestjs/passport'; +import { AuthController } from '@/auth/auth.controller'; import { GoogleAuthController } from '@/auth/google/googleAuth.controller'; import { GoogleAuthService } from '@/auth/google/googleAuth.service'; import { GoogleStrategy } from '@/auth/google/strategy/google.strategy'; -import { AuthController } from '@/auth/auth.controller'; import { SessionSerializer } from '@/auth/session/session.serializer'; import { TesterStrategy } from '@/auth/tester/strategy/tester.strategy'; import { TesterAuthController } from '@/auth/tester/testerAuth.controller'; diff --git a/packages/backend/src/utils/date.ts b/packages/backend/src/utils/date.ts index 4d3987b9..9ab15522 100644 --- a/packages/backend/src/utils/date.ts +++ b/packages/backend/src/utils/date.ts @@ -1,4 +1,6 @@ export function getFormattedDate(date: Date): string { - return `${date.getFullYear()}-${String(date.getMonth() + 1) - .padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`; -} \ No newline at end of file + return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart( + 2, + '0', + )}-${String(date.getDate()).padStart(2, '0')}`; +}