Skip to content

Commit

Permalink
Merge pull request #48 from Romantic-Yeojido/develop
Browse files Browse the repository at this point in the history
feature/#46-deploy
  • Loading branch information
bulee5328 authored Dec 20, 2024
2 parents 47344eb + 40af1d9 commit bc2747f
Show file tree
Hide file tree
Showing 4 changed files with 293 additions and 6 deletions.
164 changes: 161 additions & 3 deletions src/controllers/memo.controller.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { StatusCodes } from "http-status-codes";
import { responseFromMemories , responseFromGetMemories} from "../dtos/memo.dto.js";
import { responseFromMemories, responseFromGetMemories } from "../dtos/memo.dto.js";
import { postMemories, updateMemory, deleteMemory, getMemory } from "../services/memo.service.js";


Expand All @@ -17,13 +17,81 @@ export const handleMemories = async (req, res, next) => {
title: { type: "string" },
visit_date: { type: "string", format: "date" },
friends: { type: "string" },
content: { type: "string", example: "남자친구와 100일 기념으로 롯데월드에 갔다. 겨울이라 그런지 날씨가 밤이 되니 너무 추웠다. 오늘 날씨가 꽤 추워서 사람들이 많이 없어서 놀이기구를 4개나 탔다. 굉장히 만족스러웠다. 놀이기구 기다리는 동안 남자친구와 대화를 많이 했다. 그 덕에 우리가 전보다 더 가까워진 것 같은 기분이 들어 좋았다. 앞으로도 200일 300일까지 오늘처럼 잘 지냈으면 좋겠다." }
content: {
type: "string",
example: "남자친구와 100일 기념으로 롯데월드에 갔다. 겨울이라 그런지 날씨가 밤이 되니 너무 추웠다. 오늘 날씨가 꽤 추워서 사람들이 많이 없어서 놀이기구를 4개나 탔다. 굉장히 만족스러웠다. 놀이기구 기다리는 동안 남자친구와 대화를 많이 했다. 그 덕에 우리가 전보다 더 가까워진 것 같은 기분이 들어 좋았다. 앞으로도 200일 300일까지 오늘처럼 잘 지냈으면 좋겠다."
}
}
}
}
}
};
*/
#swagger.responses[200] = {
description: '추억 등록 성공',
content: {
"application/json": {
schema: {
type: "object",
properties: {
result: {
type: "object",
properties: {
user_id: {
type: "integer",
example: 1
},
location_id: {
type: "integer",
example: 1
},
title: {
type: "string",
example: "String"
},
visit_date: {
type: "string",
format: "date-time",
example: "2024-12-16T15:00:00:000Z"
},
friends: {
type: "string",
example: "String"
},
content: {
type: "string",
example: "String"
},
summary: {
type: "string",
example: "String"
}
}
}
}
}
}
}
}
#swagger.responses[400] = {
description: '추억 등록 실패',
content: {
"application/json": {
schema: {
type: "object",
properties: {
success: {
type: "boolean",
example: false
},
message: {
type: "string"
}
}
}
}
}
}
*/


try {
Expand Down Expand Up @@ -93,6 +161,96 @@ export const handleDeleteMemory = async (req, res) => {
};

export const handleGetMemory = async (req, res) => {

/*
#swagger.summary = '나만의 보관함 - 추억 불러오기 API';
#swagger.responses[200] = {
description: '추억 불러오기 성공',
content: {
"application/json": {
schema: {
type: "object",
properties: {
result: {
type: "object",
properties: {
id: {
type: "integer",
example: 1
},
user_id: {
type: "integer",
example: 1
},
location_id: {
type: "integer",
example: 1
},
title: {
type: "string",
example: "String"
},
visit_date: {
type: "string",
format: "date-time",
example: "2024-12-16T15:00:00:000Z"
},
friends: {
type: "string",
example: "String"
},
content: {
type: "string",
example: "String"
},
summary: {
type: "string",
example: "String"
},
is_deleted: {
type: "integer",
example: 0
},
created_at: {
type: "string",
format: "date-time",
example: "2024-12-16T22:43:56.000Z"
},
updated_at: {
type: "string",
format: "date-time",
example: "2024-12-19T21:22:06.000Z"
}
}
}
}
}
}
}
}
#swagger.responses[404] = {
description: '추억 불러오기 실패',
content: {
"application/json": {
schema: {
type: "object",
properties: {
success: {
type: "boolean",
example: false
},
message: {
type: "string"
}
}
}
}
}
}
*/



try {
const userId = parseInt(req.params.userId);
const locationId = parseInt(req.params.locationId);
Expand Down
129 changes: 128 additions & 1 deletion src/controllers/memoryImage.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,67 @@ export const handleMemoryImages = async (req, res, next) => {
}
}
};
*/
#swagger.responses[200] = {
description: '이미지 등록 성공',
content: {
"application/json": {
schema: {
type: "object",
properties: {
result: {
type: "array",
items: {
type: "object",
properties: {
id: {
type: "integer",
example: 1
},
memory_id: {
type: "integer",
example: 1
},
image_url: {
type: "string",
example: "https://romactic-yeojido-s3.s3.ap-northeast-2.amazonaws.com/memory_images/c4fa41df-4b5e-4beb-ab55-b8e2d6e531a2_%C2%BA%C2%AD.jpeg"
},
image_order: {
type: "integer",
example: 1
},
created_at: {
type: "string",
format: "date-time",
example: "2024-12-18T18:24:08.000Z"
}
}
}
}
}
}
}
}
}
#swagger.responses[400] = {
description: '이미지 등록 실패',
content: {
"application/json": {
schema: {
type: "object",
properties: {
success: {
type: "boolean",
example: false
},
message: {
type: "string"
}
}
}
}
}
}
*/


try {
Expand All @@ -50,6 +110,73 @@ export const handleMemoryImages = async (req, res, next) => {
};

export const getMemoryImages = async (req, res, next) => {

/*
#swagger.summary = '나만의 보관함 - 사진 불러오기 API';
#swagger.responses[200] = {
description: '사진 불러오기 성공',
content: {
"application/json": {
schema: {
type: "object",
properties: {
result: {
type: "array",
items: {
type: "object",
properties: {
id: {
type: "integer",
example: 1
},
memory_id: {
type: "integer",
example: 1
},
image_url: {
type: "string",
example: "https://romactic-yeojido-s3.s3.ap-northeast-2.amazonaws.com/memory_images/6f0cd7a3-d063-4173-9c4a-d3bb4aec2dab_%C2%B0%C2%AD%C2%BE%C3%86%C3%81%C3%B6.jpeg"
},
image_order: {
type: "integer",
example: 1
},
created_at: {
type: "string",
format: "date-time",
example: "2024-12-18T18:24:08.000Z"
}
}
}
}
}
}
}
}
}
#swagger.responses[404] = {
description: '사진 불러오기 실패',
content: {
"application/json": {
schema: {
type: "object",
properties: {
success: {
type: "boolean",
example: false
},
message: {
type: "string"
}
}
}
}
}
}
*/



try {
const { memoryId } = req.params;

Expand Down
4 changes: 3 additions & 1 deletion src/dtos/memoryImage.dto.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ export const responseFromMemoryImages = (memoryId, imageUrl, imageOrder) => {
};
};

export const responseFromGetMemoryImages = (memoryId, imageUrl, imageOrder) => {
export const responseFromGetMemoryImages = (id, memoryId, imageUrl, imageOrder, createdAt) => {
return {
id: id,
memory_id: memoryId,
image_url: imageUrl, // S3에서 반환된 이미지 URL
image_order: imageOrder,
created_at: createdAt,
};
};

2 changes: 1 addition & 1 deletion src/services/memoryImage.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const getMemoryImagesByMemoryId = async (memoryId) => {

// 이미지 URL 반환
return memoryImages.map(image => {
return responseFromGetMemoryImages(image.memory_id, image.image_url, image.image_order);
return responseFromGetMemoryImages(image.id, image.memory_id, image.image_url, image.image_order, image.created_at);
})
} catch (error) {
throw error;
Expand Down

0 comments on commit bc2747f

Please sign in to comment.