diff --git a/src/controllers/trust.controller.ts b/src/controllers/trust.controller.ts index b2d5c12..2de6946 100644 --- a/src/controllers/trust.controller.ts +++ b/src/controllers/trust.controller.ts @@ -4,6 +4,91 @@ import {SearchNoResultsError,ServerError,DataValidationError} from 'src/errors.j import {StatusCodes} from 'http-status-codes'; export const handleImageStatus = async (req: Request, res: Response, next:NextFunction): Promise => { + /* + #swagger.tags = ['Trust'] + #swagger.summary = '휴지통으로 이미지 이동 API' + #swagger.description = '선택한 이미지를 휴지통으로 이동시키는 API입니다.' + #swagger.requestBody = { + required: true, + content: { + "application/json": { + schema: { + type: "object", + properties: { + mediaId: { + type: "integer", + description: "특정 이미지의 mediaId" + } + }, + required: ["mediaId"] + } + } + } + } + #swagger.responses[200] = { + description: "휴지통으로 이동 성공", + content: { + "application/json": { + schema: { + type: "object", + properties: { + resultType: { type: "string", example: "SUCCESS" }, + error: { type: "object", nullable: true, example: null }, + success: { + type: "object", + properties: { + mediaId: { type: "integer", example: 100001 }, + status: { type: "integer", example: 0 } + } + } + } + } + } + } + } + + #swagger.responses[500] = { + description: "잘못된 요청 (mediaId가 올바르지 않음)", + content: { + "application/json": { + schema: { + type: "object", + properties: { + resultType: { type: "string", example: "FAILURE" }, + error: { + type: "object", + properties: { + reason: { type: "string", example: "mediaId가 올바르지 않습니다" } + } + }, + success: { type: "object", nullable: true, example: null } + } + } + } + } + } + + #swagger.responses[500] = { + description: "해당 mediaId에 대한 데이터를 찾을 수 없음", + content: { + "application/json": { + schema: { + type: "object", + properties: { + resultType: { type: "string", example: "FAILURE" }, + error: { + type: "object", + properties: { + reason: { type: "string", example: "해당 mediaId에 대한 이미지가 존재하지 않습니다" } + } + }, + success: { type: "object", nullable: true, example: null } + } + } + } + } + } + */ try { const {mediaId} = req.body; const parsedMediaId = parseInt(mediaId); @@ -24,7 +109,99 @@ export const handleImageStatus = async (req: Request, res: Response, next:NextFu } }; -export const handleImageRestore = async (req: Request, res: Response, next: NextFunction): Promise => { +export const handleImageRestore = async ( + req: Request, + res: Response, + next: NextFunction +): Promise => { + /* + #swagger.tags = ['Trust'] + #swagger.summary = '휴지통에서 이미지 복구 API' + #swagger.description = '선택한 이미지를 휴지통에서 복구하는 API입니다.' + #swagger.requestBody = { + required: true, + content: { + "application/json": { + schema: { + type: "object", + properties: { + mediaIds: { + type: "array", + items: { type: "integer" }, + description: "복구할 이미지의 mediaId 리스트" + } + }, + required: ["mediaIds"] + } + } + } + } + + #swagger.responses[200] = { + description: "복구 성공", + content: { + "application/json": { + schema: { + type: "object", + properties: { + resultType: { type: "string", example: "SUCCESS" }, + error: { type: "object", nullable: true, example: null }, + success: { + type: "array", + items: { + type: "object", + properties: { + mediaId: { type: "integer", example: 10000001 }, + status: { type: "integer", example: 1 } + } + } + } + } + } + } + } + } + #swagger.responses[500] = { + description: "잘못된 요청 (mediaId가 올바르지 않음)", + content: { + "application/json": { + schema: { + type: "object", + properties: { + resultType: { type: "string", example: "FAILURE" }, + error: { + type: "object", + properties: { + reason: { type: "string", example: "mediaId가 올바르지 않습니다" } + } + }, + success: { type: "object", nullable: true, example: null } + } + } + } + } + } + #swagger.responses[500] = { + description: "해당 mediaId에 대한 데이터를 찾을 수 없음", + content: { + "application/json": { + schema: { + type: "object", + properties: { + resultType: { type: "string", example: "FAILURE" }, + error: { + type: "object", + properties: { + reason: { type: "string", example: "해당 mediaId에 대한 이미지가 존재하지 않습니다" } + } + }, + success: { type: "object", nullable: true, example: null } + } + } + } + } + } +*/ try { const {mediaIds} = req.body; if (!Array.isArray(mediaIds)) { @@ -44,7 +221,125 @@ export const handleImageRestore = async (req: Request, res: Response, next: Next } }; -export const handleImageDelete = async (req: Request, res: Response, next: NextFunction): Promise => { +export const handleImageDelete = async ( + req: Request, + res: Response, + next: NextFunction +): Promise => { + /* + #swagger.tags = ['Trust'] + #swagger.summary = '휴지통에서 이미지 삭제 API' + #swagger.description = '선택한 이미지를 휴지통에서 삭제하는 API입니다.' + + #swagger.requestBody = { + required: true, + content: { + "application/json": { + schema: { + type: "object", + properties: { + imageIds: { + type: "array", + items: { type: "integer" }, + description: "삭제할 이미지의 imageId 리스트" + } + }, + required: ["imageIds"] + } + } + } + } + #swagger.responses[200] = { + description: "삭제 성공", + content: { + "application/json": { + schema: { + type: "object", + properties: { + resultType: { type: "string", example: "SUCCESS" }, + error: { type: "object", nullable: true, example: null }, + success: { + type: "object", + properties: { + success: { type: "boolean", example: true }, + } + } + } + } + } + } + } + #swagger.responses[404] = { + description: "잘못된 요청 (imageIds가 올바르지 않음)", + content: { + "application/json": { + schema: { + type: "object", + properties: { + resultType: { type: "string", example: "FAILURE" }, + error: { + type: "object", + properties: { + errorCode: { type: "string", example: "SRH-404" }, + reason: { type: "string", example: "imageIds가 올바르지 않습니다" }, + } + }, + success: { type: "object", nullable: true, example: null } + } + }, + examples: { + "유효하지 않은 imageIds": { + summary: "유효하지 않은 imageIds", + description: "전송된 imageIds 값이 배열이 아니거나 올바른 숫자가 아닐 때 발생합니다.", + value: { + resultType: "FAILURE", + error: { + errorCode: "SRH-404", + reason: "imageIds가 올바르지 않습니다", }, + success: null + } + } + } + } + } + } + + #swagger.responses[400] = { + description: "삭제할 이미지가 존재하지 않음", + content: { + "application/json": { + schema: { + type: "object", + properties: { + resultType: { type: "string", example: "FAILURE" }, + error: { + type: "object", + properties: { + errorCode: { type: "string", example: "SRH-400" }, + reason: { type: "string", example: "해당 사진이 휴지통에 존재하지 않습니다" }, } + }, + success: { type: "object", nullable: true, example: null } + } + }, + examples: { + "삭제할 이미지가 존재하지 않음": { + summary: "삭제할 이미지가 존재하지 않음", + description: "전달된 imageIds 중 일부 또는 전체가 존재하지 않는 경우 발생합니다.", + value: { + resultType: "FAILURE", + error: { + errorCode: "SRH-400", + reason: "해당 사진이 휴지통에 존재하지 않습니다", + }, + success: null + } + } + } + } + } + } + */ + try { const { mediaIds } = req.body; if (!Array.isArray(mediaIds)) { diff --git a/src/controllers/user.mypage.controllers.ts b/src/controllers/user.mypage.controllers.ts index 6c873a1..1c4e8a8 100644 --- a/src/controllers/user.mypage.controllers.ts +++ b/src/controllers/user.mypage.controllers.ts @@ -9,6 +9,56 @@ export const getUser = async ( res: Response, next: NextFunction, ): Promise => { + /* + #swagger.tags = ['User'] + #swagger.summary = '사용자 정보 가져오기 API' + #swagger.description = '사용자 정보를 가져오는 API입니다.' + #swagger.responses[200] = { + description: "사용자 정보 가져오기 성공", + content: { + "application/json": { + schema: { + type: "object", + properties: { + resultType: { type: "string", example: "SUCCESS" }, + error: { type: "object", nullable: true, example: null }, + success: { + type: "object", + properties: { + id: { type: "integer", example: 1 }, + email: { type: "string", example: "yein117@naver.com"}, + name: { type: "string", example: "예인" }, + goalCount: { type: "integer", example: 0 }, + createdAt: { type: "string", example: "2025-01-23T12:26:19.188Z" }, + updatedAt: { type: "string", format: "date-time" } + } + } + } + } + } + } + } + #swagger.responses[401] = { + description: "잘못된 요청", + content: { + "application/json": { + schema: { + type: "object", + properties: { + resultType: { type: "string", example: "FAILURE" }, + error: { + type: "object", + properties: { + reason: { type: "string", example: "User_id를 찾을 수 없습니다" } + } + }, + success: { type: "object", nullable: true, example: null } + } + } + } + } + } + */ try { if (!req.user?.id) { throw new AuthError({reason: 'User_id를 찾을 수 없습니다'}); @@ -26,6 +76,34 @@ export const logOutUser = async ( res: Response, next: NextFunction, ): Promise => { + /* + #swagger.tags = ['User'] + #swagger.summary = '사용자 로그아웃 API' + #swagger.description = '로그아웃 API입니다.' + #swagger.responses[204] = { + description: "사용자 로그아웃 성공", + } + #swagger.responses[401] = { + description: "잘못된 요청", + content: { + "application/json": { + schema: { + type: "object", + properties: { + resultType: { type: "string", example: "FAILURE" }, + error: { + type: "object", + properties: { + reason: { type: "string", example: "Session ID가 존재하지 않습니다" } + } + }, + success: { type: "object", nullable: true, example: null } + } + } + } + } + } + */ try { const sessionId = req.sessionID; if (!sessionId) { @@ -44,6 +122,34 @@ export const deleteUser = async ( res: Response, next: NextFunction, ) => { + /* + #swagger.tags = ['User'] + #swagger.summary = '회원탈퇴 API' + #swagger.description = '사용자 상태를 비활성화하는 API입니다.' + #swagger.responses[204] = { + description: "회원탈퇴 성공", + } + #swagger.responses[401] = { + description: "잘못된 요청", + content: { + "application/json": { + schema: { + type: "object", + properties: { + resultType: { type: "string", example: "FAILURE" }, + error: { + type: "object", + properties: { + reason: { type: "string", example: "Session ID가 존재하지 않습니다" } + } + }, + success: { type: "object", nullable: true, example: null } + } + } + } + } + } + */ try { if (!req.user?.id) { throw new AuthError({reason: 'User_id를 찾을 수 없습니다'});