diff --git a/src/prompts/dtos/prompt.download.dto.ts b/src/prompts/dtos/prompt.download.dto.ts index 218e218..dfece09 100644 --- a/src/prompts/dtos/prompt.download.dto.ts +++ b/src/prompts/dtos/prompt.download.dto.ts @@ -10,6 +10,8 @@ export interface PromptDownloadResponseDTO { export interface DownloadedPromptResponseDTO { message: string; prompt_id: number; + purchase_id: number; + is_refunded: boolean; title: string; description: string; models: string[]; diff --git a/src/prompts/repositories/prompt.download.repository.ts b/src/prompts/repositories/prompt.download.repository.ts index 4712bd4..a6b116a 100644 --- a/src/prompts/repositories/prompt.download.repository.ts +++ b/src/prompts/repositories/prompt.download.repository.ts @@ -28,6 +28,7 @@ export const PromptDownloadRepository = { return prisma.purchase.findMany({ where: { user_id: userId }, include: { + refund: { select: { refund_id: true } }, prompt: { select: { prompt_id: true, diff --git a/src/prompts/routes/prompt.download.route.ts b/src/prompts/routes/prompt.download.route.ts index 09af072..89ba6ff 100644 --- a/src/prompts/routes/prompt.download.route.ts +++ b/src/prompts/routes/prompt.download.route.ts @@ -98,6 +98,8 @@ router.get('/:promptId/downloads', authenticateJwt, PromptDownloadController.get * type: object * properties: * prompt_id: { type: integer } + * purchase_id: { type: integer, description: 환불 API 호출에 필요한 구매 ID } + * is_refunded: { type: boolean, description: 환불 완료 여부 } * title: { type: string } * description: { type: string, nullable: true } * price: { type: integer } diff --git a/src/prompts/services/prompt.download.service.ts b/src/prompts/services/prompt.download.service.ts index 3932f15..2af7c65 100644 --- a/src/prompts/services/prompt.download.service.ts +++ b/src/prompts/services/prompt.download.service.ts @@ -95,7 +95,8 @@ async getDownloadedPrompts(userId: number): Promise { + return downloads.map((purchase) => { + const { prompt } = purchase; const userReviewRaw = prompt.reviews[0]; const hasReview = !!userReviewRaw; const isRecentReview = hasReview && new Date(userReviewRaw.created_at) >= THIRTY_DAYS_AGO; @@ -111,17 +112,19 @@ async getDownloadedPrompts(userId: number): Promise m.model.name), imageUrls: imageUrls, - + has_review: hasReview, - is_recent_review: isRecentReview, - + is_recent_review: isRecentReview, + userNickname: userNickname, userProfileImageUrl: userProfileImageUrl, userReview: userReview, diff --git a/swagger.json b/swagger.json index aeb7ebd..43b660f 100644 --- a/swagger.json +++ b/swagger.json @@ -3938,6 +3938,14 @@ "prompt_id": { "type": "integer" }, + "purchase_id": { + "type": "integer", + "description": "환불 API 호출에 필요한 구매 ID" + }, + "is_refunded": { + "type": "boolean", + "description": "환불 완료 여부" + }, "title": { "type": "string" },