Skip to content

Commit 30481cf

Browse files
committed
modify: totla stats 의 서비스 arguments 에 모두 default 값 넣는 방향으로
1 parent eb05ca8 commit 30481cf

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

src/controllers/totalStats.controller.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { NextFunction, Request, RequestHandler, Response } from 'express';
22
import logger from '@/configs/logger.config';
3-
import { BadRequestError } from '@/exception';
43
import { GetTotalStatsQuery, TotalStatsResponseDto } from '@/types';
54
import { TotalStatsService } from '@/services/totalStats.service';
65

@@ -16,9 +15,6 @@ export class TotalStatsController {
1615
const { id } = req.user;
1716
const { period, type } = req.query;
1817

19-
// 미들웨어에서 GetTotalStatsQueryDto 에 의해 걸리는데 런타임과 IDE 에서 구분을 못함, 이를 위해 추가
20-
if (!type) throw new BadRequestError('type 파라미터가 필요합니다.');
21-
2218
const stats = await this.totalStatsService.getTotalStats(id, period, type);
2319
const message = this.totalStatsService.getSuccessMessage(type);
2420

src/services/totalStats.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { TotalStatsRepository } from '@/repositories/totalStats.repository';
55
export class TotalStatsService {
66
constructor(private totalStatsRepo: TotalStatsRepository) {}
77

8-
async getTotalStats(userId: number, period: TotalStatsPeriod = 7, type: TotalStatsType): Promise<TotalStatsItem[]> {
8+
async getTotalStats(userId: number, period: TotalStatsPeriod = 7, type: TotalStatsType = 'view'): Promise<TotalStatsItem[]> {
99
try {
1010
const rawStats = await this.totalStatsRepo.getTotalStats(userId, period, type);
1111

@@ -19,7 +19,7 @@ export class TotalStatsService {
1919
}
2020
}
2121

22-
getSuccessMessage(type: TotalStatsType): string {
22+
getSuccessMessage(type: TotalStatsType = 'view'): string {
2323
const messages = {
2424
view: '전체 조회수 변동 조회에 성공하였습니다.',
2525
like: '전체 좋아요 변동 조회에 성공하였습니다.',

0 commit comments

Comments
 (0)