Skip to content

Commit 225656b

Browse files
committed
Merge branch 'feat/#372', remote-tracking branch 'origin' into develop
2 parents a6d9cf1 + 00f0ebc commit 225656b

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

src/reports/dtos/report.dto.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const toCreateReportResponse = ({
3030

3131

3232

33-
// 신고된 프롬프트 목록 조회 응답 인터페이스
33+
// 개별 신고 항목 DTO
3434
export interface ReportedPromptDTO {
3535
report_id: number;
3636
prompt_id: number;
@@ -40,33 +40,42 @@ export interface ReportedPromptDTO {
4040
created_at: string;
4141
is_read: boolean;
4242
}
43-
// 전체 신고 목록 응답 타입
43+
44+
45+
// 전체 응답 DTO
4446
export interface ReportedPromptListResponse {
4547
reports: ReportedPromptDTO[];// 신고 목록 배열
4648
has_more: boolean; // 다음 페이지 여부
49+
total_count: number; // 전체 신고 수
4750
}
48-
// 변환 함수(신고목록->api응답)
51+
52+
53+
// 변환 함수
4954
export const toReportedPromptListResponse = (
5055
reports: (PromptReport & {
5156
prompt: { prompt_id: number; title: string };// 프롬프트 정보 (프롬프트 ID & 제목)
5257
reporter: { user_id: number; nickname: string };// 신고자 정보 (ID & 닉네임)
5358
})[],
54-
hasMore: boolean
59+
hasMore: boolean,
60+
totalCount: number
5561
): ReportedPromptListResponse => {
56-
// DB 원본 데이터를 ReportedPromptDTO 배열로 변환
62+
63+
// 개별 신고 항목 변환
5764
const transformed: ReportedPromptDTO[] = reports.map((report) => ({
5865
report_id: report.report_id,
5966
prompt_id: report.prompt.prompt_id,
6067
prompt_title: report.prompt.title,
6168
reporter_id: report.reporter.user_id,
6269
reporter_nickname: report.reporter.nickname,
6370
created_at: report.created_at.toISOString(),
64-
is_read: report.is_read
71+
is_read: report.is_read,
6572
}));
73+
6674
// 최종 응답 객체 반환 (has_more은 페이징 기준으로 판단)
6775
return {
6876
reports: transformed,
69-
has_more: hasMore
77+
has_more: hasMore,
78+
total_count: totalCount
7079
};
7180
};
7281

src/reports/repositories/report.repository.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ export const findAllReports = async (
7878
});
7979
};
8080

81+
// 시스템 전체 신고 개수 조회
82+
export const countTotalReports = async () => {
83+
return await prisma.promptReport.count();
84+
}
85+
8186
// 읽음 처리
8287
export const markReportAsRead = async (reportId: number) => {
8388
return await prisma.promptReport.update({

src/reports/services/report.service.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
findAllReports,
1010
markReportAsRead,
1111
findReportById,
12+
countTotalReports,
1213
} from '../repositories/report.repository';
1314
import eventBus from '../../config/eventBus';
1415

@@ -36,6 +37,7 @@ export const createReportService = async (
3637
return toCreateReportResponse(newReport);
3738
};
3839

40+
// 신고된 프롬프트 목록 조회
3941
export const getReportedPromptsService = async (
4042
userId: number,
4143
rawCursor?: string,
@@ -66,8 +68,8 @@ export const getReportedPromptsService = async (
6668
const rawreportedPrompts = await findAllReports(cursor, limit);
6769
const hasMore = rawreportedPrompts.length > limit;
6870
const slicedNotifications = hasMore ? rawreportedPrompts.slice(0, limit) : rawreportedPrompts;
69-
70-
return toReportedPromptListResponse(slicedNotifications, hasMore);
71+
const totalCount = await countTotalReports();
72+
return toReportedPromptListResponse(slicedNotifications, hasMore, totalCount);
7173
};
7274

7375

0 commit comments

Comments
 (0)