Skip to content

Commit 915706d

Browse files
authored
Merge pull request #519 from PromptPlace/feat/#518
[FEAT] 다운로드 목록 응답에 purchase_id / is_refunded 추가 (#518)
2 parents 1f146fd + 0a02f6a commit 915706d

5 files changed

Lines changed: 21 additions & 5 deletions

File tree

src/prompts/dtos/prompt.download.dto.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export interface PromptDownloadResponseDTO {
1010
export interface DownloadedPromptResponseDTO {
1111
message: string;
1212
prompt_id: number;
13+
purchase_id: number;
14+
is_refunded: boolean;
1315
title: string;
1416
description: string;
1517
models: string[];

src/prompts/repositories/prompt.download.repository.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export const PromptDownloadRepository = {
2828
return prisma.purchase.findMany({
2929
where: { user_id: userId },
3030
include: {
31+
refund: { select: { refund_id: true } },
3132
prompt: {
3233
select: {
3334
prompt_id: true,

src/prompts/routes/prompt.download.route.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ router.get('/:promptId/downloads', authenticateJwt, PromptDownloadController.get
9898
* type: object
9999
* properties:
100100
* prompt_id: { type: integer }
101+
* purchase_id: { type: integer, description: 환불 API 호출에 필요한 구매 ID }
102+
* is_refunded: { type: boolean, description: 환불 완료 여부 }
101103
* title: { type: string }
102104
* description: { type: string, nullable: true }
103105
* price: { type: integer }

src/prompts/services/prompt.download.service.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ async getDownloadedPrompts(userId: number): Promise<DownloadedPromptResponseDTO[
9595
const THIRTY_DAYS_AGO = new Date();
9696
THIRTY_DAYS_AGO.setDate(THIRTY_DAYS_AGO.getDate() - 30);
9797

98-
return downloads.map(({ prompt }) => {
98+
return downloads.map((purchase) => {
99+
const { prompt } = purchase;
99100
const userReviewRaw = prompt.reviews[0];
100101
const hasReview = !!userReviewRaw;
101102
const isRecentReview = hasReview && new Date(userReviewRaw.created_at) >= THIRTY_DAYS_AGO;
@@ -111,17 +112,19 @@ async getDownloadedPrompts(userId: number): Promise<DownloadedPromptResponseDTO[
111112
return {
112113
message: "다운로드한 프롬프트 목록 조회 성공",
113114
statusCode: 200,
114-
115+
115116
prompt_id: prompt.prompt_id,
117+
purchase_id: purchase.purchase_id,
118+
is_refunded: !!purchase.refund,
116119
title: prompt.title,
117120
description: prompt.description,
118121
price: prompt.price,
119122
models: prompt.models.map((m) => m.model.name),
120123
imageUrls: imageUrls,
121-
124+
122125
has_review: hasReview,
123-
is_recent_review: isRecentReview,
124-
126+
is_recent_review: isRecentReview,
127+
125128
userNickname: userNickname,
126129
userProfileImageUrl: userProfileImageUrl,
127130
userReview: userReview,

swagger.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3938,6 +3938,14 @@
39383938
"prompt_id": {
39393939
"type": "integer"
39403940
},
3941+
"purchase_id": {
3942+
"type": "integer",
3943+
"description": "환불 API 호출에 필요한 구매 ID"
3944+
},
3945+
"is_refunded": {
3946+
"type": "boolean",
3947+
"description": "환불 완료 여부"
3948+
},
39413949
"title": {
39423950
"type": "string"
39433951
},

0 commit comments

Comments
 (0)