Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/prompts/dtos/prompt.download.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down
1 change: 1 addition & 0 deletions src/prompts/repositories/prompt.download.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/prompts/routes/prompt.download.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
13 changes: 8 additions & 5 deletions src/prompts/services/prompt.download.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ async getDownloadedPrompts(userId: number): Promise<DownloadedPromptResponseDTO[
const THIRTY_DAYS_AGO = new Date();
THIRTY_DAYS_AGO.setDate(THIRTY_DAYS_AGO.getDate() - 30);

return downloads.map(({ prompt }) => {
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;
Expand All @@ -111,17 +112,19 @@ async getDownloadedPrompts(userId: number): Promise<DownloadedPromptResponseDTO[
return {
message: "λ‹€μš΄λ‘œλ“œν•œ ν”„λ‘¬ν”„νŠΈ λͺ©λ‘ 쑰회 성곡",
statusCode: 200,

prompt_id: prompt.prompt_id,
purchase_id: purchase.purchase_id,
is_refunded: !!purchase.refund,
title: prompt.title,
description: prompt.description,
price: prompt.price,
models: prompt.models.map((m) => m.model.name),
imageUrls: imageUrls,

has_review: hasReview,
is_recent_review: isRecentReview,
is_recent_review: isRecentReview,

userNickname: userNickname,
userProfileImageUrl: userProfileImageUrl,
userReview: userReview,
Expand Down
8 changes: 8 additions & 0 deletions swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -3938,6 +3938,14 @@
"prompt_id": {
"type": "integer"
},
"purchase_id": {
"type": "integer",
"description": "ν™˜λΆˆ API ν˜ΈμΆœμ— ν•„μš”ν•œ ꡬ맀 ID"
},
"is_refunded": {
"type": "boolean",
"description": "ν™˜λΆˆ μ™„λ£Œ μ—¬λΆ€"
},
"title": {
"type": "string"
},
Expand Down
Loading