From 830e550664ea4fdf2ac33b883be68ddd851d4593 Mon Sep 17 00:00:00 2001 From: seoyeoneel02 Date: Fri, 27 Sep 2024 16:16:20 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20follow=20=EB=93=B1=EB=A1=9D=20#132?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/domains/search/search.controller.js | 8 ++- src/domains/search/search.dao.js | 19 +++++- src/domains/search/search.dto.js | 4 ++ src/domains/search/search.service.js | 8 ++- src/domains/search/search.sql.js | 6 +- src/routes/search.js | 8 ++- src/swagger/search.swagger.yaml | 78 +++++++++++++++++++++++++ 7 files changed, 124 insertions(+), 7 deletions(-) diff --git a/src/domains/search/search.controller.js b/src/domains/search/search.controller.js index 87509ef..e8c3cc7 100644 --- a/src/domains/search/search.controller.js +++ b/src/domains/search/search.controller.js @@ -1,7 +1,7 @@ import { response } from "../../config/response.js"; import { status } from "../../config/response.status.js"; import { getSearch, getCloth, getSearchResult, getSearchBrand, getMyCloth, getMyWish } from "./search.provider.js"; -import { addMyCloth, addMyWish, delMyWish } from "./search.service.js"; +import { addMyCloth, addMyWish, delMyWish, addMyFollow } from "./search.service.js"; export const searchPreview = async (req, res, next) => { console.log("검색 메인화면을 조회합니다"); @@ -51,4 +51,10 @@ export const getWish = async (req, res, next) => { console.log("관심 있는 옷 조회를 요청하였습니다!"); const userId = res.locals.uuid; res.send(response(status.SUCCESS, await getMyWish(userId, req.params.clothId))); +} + +export const addFollow = async (req, res, next) => { + console.log("팔로우를 요청하였습니다!"); + const userId = res.locals.uuid; + res.send(response(status.SUCCESS, await addMyFollow(userId, req.params.clothId))); } \ No newline at end of file diff --git a/src/domains/search/search.dao.js b/src/domains/search/search.dao.js index 153d311..121c97e 100644 --- a/src/domains/search/search.dao.js +++ b/src/domains/search/search.dao.js @@ -8,7 +8,7 @@ import { UserNicknameToClothId, UserCategoryToClothId, brandToBrandName, userIdToNickname, userToNickname, getBrandToBrandId, userToBrand, categoryToBrand, clothToBrand, clothCategoryToBrand, insertCloth, insertRealSize, getCloth, - addWishSQL, delWishSQL, getWishSQL } from "./search.sql.js"; + addWishSQL, delWishSQL, getWishSQL, getFollowSQL, addFollowSQL } from "./search.sql.js"; // nickname+cloth 반환 export const getNicknameToClothId = async (category) => { @@ -269,4 +269,21 @@ export const getWishDAO = async (userId, clothId) => { }catch (err) { throw new BaseError(status.PARAMETER_IS_WRONG); } +} + +// Follow 추가 +export const addFollowDAO = async (userId, clothId) => { + try{ + const conn = await pool.getConnection(); + const to_user = await pool.query(getUserIdToClothId, clothId); + const is_exist = await pool.query(getFollowSQL, [userId, to_user[0][0].uuid]); + if(is_exist[0].length !== 0){ + throw new BaseError(status.PARAMETER_IS_WRONG); + } + const follow = await pool.query(addFollowSQL, [userId, to_user[0][0].uuid]); + conn.release(); + return follow[0].insertId; + }catch (err) { + throw new BaseError(status.PARAMETER_IS_WRONG); + } } \ No newline at end of file diff --git a/src/domains/search/search.dto.js b/src/domains/search/search.dto.js index 6ed6d28..a7886d0 100644 --- a/src/domains/search/search.dto.js +++ b/src/domains/search/search.dto.js @@ -195,4 +195,8 @@ export const getWishDTO = (wish) => { } return {"wish_id": wish_id}; +} + +export const addFollowDTO = (follow) => { + return {"follow_id": follow}; } \ No newline at end of file diff --git a/src/domains/search/search.service.js b/src/domains/search/search.service.js index 442c853..290a32a 100644 --- a/src/domains/search/search.service.js +++ b/src/domains/search/search.service.js @@ -1,7 +1,7 @@ import { BaseError } from "../../config/error.js"; import { status } from "../../config/response.status.js"; -import { addClothResponseDTO, addWishDTO, delWishDTO } from "./search.dto.js"; -import { clothAdd, getAddCloth, addWishDAO, delWishDAO } from "./search.dao.js"; +import { addClothResponseDTO, addWishDTO, delWishDTO, addFollowDTO } from "./search.dto.js"; +import { clothAdd, getAddCloth, addWishDAO, delWishDAO, addFollowDAO } from "./search.dao.js"; export const addMyCloth = async (userId, body) => { const requiredFields = ['name', 'product_code', 'category', 'size', 'fit']; @@ -54,4 +54,8 @@ export const addMyWish = async (userId, clothId) => { export const delMyWish = async (userId, clothId) => { return delWishDTO(await delWishDAO(userId, clothId)); +} + +export const addMyFollow = async (userId, clothId) => { + return addFollowDTO(await addFollowDAO(userId, clothId)); } \ No newline at end of file diff --git a/src/domains/search/search.sql.js b/src/domains/search/search.sql.js index ebe4685..7acff20 100644 --- a/src/domains/search/search.sql.js +++ b/src/domains/search/search.sql.js @@ -111,4 +111,8 @@ export const addWishSQL = "INSERT INTO wish (cloth_id, wisher_uuid) VALUES (?, ? export const delWishSQL = "DELETE FROM wish WHERE cloth_id = ? AND wisher_uuid = ? ;" -export const getWishSQL = "SELECT id FROM wish WHERE cloth_id = ? AND wisher_uuid = ? ;" \ No newline at end of file +export const getWishSQL = "SELECT id FROM wish WHERE cloth_id = ? AND wisher_uuid = ? ;" + +export const getFollowSQL = "SELECT id FROM follow WHERE from_uuid = ? AND to_uuid = ? ;" + +export const addFollowSQL = "INSERT INTO follow (from_uuid, to_uuid) VALUES (?, ?) ;" \ No newline at end of file diff --git a/src/routes/search.js b/src/routes/search.js index 31c5508..9304932 100644 --- a/src/routes/search.js +++ b/src/routes/search.js @@ -1,7 +1,8 @@ import express from "express"; import asyncHandler from 'express-async-handler'; import { LoginCheck } from "../middlewares/logincheck.js"; -import { searchPreview, clothView, searchView, brandView, addClothPreview, addCloth, addWish, delWish, getWish } from "../domains/search/search.controller.js"; +import { searchPreview, clothView, searchView, brandView, addClothPreview, addCloth, + addWish, delWish, getWish, addFollow } from "../domains/search/search.controller.js"; export const searchRouter = express.Router({mergeParams: true}); @@ -30,4 +31,7 @@ searchRouter.post('/:clothId/wish', LoginCheck, asyncHandler(addWish)); searchRouter.delete('/:clothId/wish', LoginCheck, asyncHandler(delWish)); //검색-wish -searchRouter.get('/:clothId/wish', LoginCheck, asyncHandler(getWish)); \ No newline at end of file +searchRouter.get('/:clothId/wish', LoginCheck, asyncHandler(getWish)); + +//검색-follow에 추가 +searchRouter.post('/:clothId/follow', LoginCheck, asyncHandler(addFollow)); \ No newline at end of file diff --git a/src/swagger/search.swagger.yaml b/src/swagger/search.swagger.yaml index 318a85b..1a4b8aa 100644 --- a/src/swagger/search.swagger.yaml +++ b/src/swagger/search.swagger.yaml @@ -832,6 +832,84 @@ paths: type: string example: 잘못된 요청입니다 + '500': + description: 서버 에러 + schema: + type: object + properties: + status: + type: integer + example: 500 + isSuccess: + type: boolean + example: false + code: + type: integer + example: COMMON000 + message: + type: string + example: 서버 에러, 관리자에게 문의 바랍니다. + + /FITple/search/{clothId}/follow: + post: + tags: + - Search + summary: follow 등록 로직 + operationId: addFollow + security: + - bearerAuth: [] + parameters: + - name: clothId + in: path + required: true + schema: + type: integer + responses: + '200': + description: follow 등록 성공 + schema: + type: object + properties: + status: + type: integer + example: 200 + isSuccess: + type: boolean + example: true + code: + type: integer + example: 200 + message: + type: string + example: "success!" + data: + type: array + example: { + "clothData": [ + { + "wish_id": 20 + } + ] + } + + '400': + description: 잘못된 요청 + schema: + type: object + properties: + status: + type: integer + example: 400 + isSuccess: + type: boolean + example: false + code: + type: integer + example: COMMON001 + message: + type: string + example: 잘못된 요청입니다 + '500': description: 서버 에러 schema: From 44634227fa100f795888b50e25524d7b23a637a0 Mon Sep 17 00:00:00 2001 From: seoyeoneel02 Date: Fri, 27 Sep 2024 16:18:00 +0900 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=EB=B3=B8=EC=9D=B8=20follow=20?= =?UTF-8?q?=EB=B6=88=EA=B0=80=20#132?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/domains/search/search.dao.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/domains/search/search.dao.js b/src/domains/search/search.dao.js index 121c97e..fd22a3a 100644 --- a/src/domains/search/search.dao.js +++ b/src/domains/search/search.dao.js @@ -276,6 +276,9 @@ export const addFollowDAO = async (userId, clothId) => { try{ const conn = await pool.getConnection(); const to_user = await pool.query(getUserIdToClothId, clothId); + if(userId == to_user[0][0].uuid){ + throw new BaseError(status.PARAMETER_IS_WRONG); + } const is_exist = await pool.query(getFollowSQL, [userId, to_user[0][0].uuid]); if(is_exist[0].length !== 0){ throw new BaseError(status.PARAMETER_IS_WRONG); From b7e008f2423ac50bece492efe9bb73ae1604054a Mon Sep 17 00:00:00 2001 From: seoyeoneel02 Date: Sat, 19 Oct 2024 15:47:54 +0900 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20follow=20=EC=82=AD=EC=A0=9C=20#132?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/domains/search/search.controller.js | 8 +- src/domains/search/search.dao.js | 20 ++++- src/domains/search/search.dto.js | 9 +++ src/domains/search/search.service.js | 8 +- src/domains/search/search.sql.js | 4 +- src/routes/search.js | 7 +- src/swagger/search.swagger.yaml | 97 ++++++++++++++++++++----- 7 files changed, 126 insertions(+), 27 deletions(-) diff --git a/src/domains/search/search.controller.js b/src/domains/search/search.controller.js index e8c3cc7..5e14dc9 100644 --- a/src/domains/search/search.controller.js +++ b/src/domains/search/search.controller.js @@ -1,7 +1,7 @@ import { response } from "../../config/response.js"; import { status } from "../../config/response.status.js"; import { getSearch, getCloth, getSearchResult, getSearchBrand, getMyCloth, getMyWish } from "./search.provider.js"; -import { addMyCloth, addMyWish, delMyWish, addMyFollow } from "./search.service.js"; +import { addMyCloth, addMyWish, delMyWish, addMyFollow, delMyFollow } from "./search.service.js"; export const searchPreview = async (req, res, next) => { console.log("검색 메인화면을 조회합니다"); @@ -57,4 +57,10 @@ export const addFollow = async (req, res, next) => { console.log("팔로우를 요청하였습니다!"); const userId = res.locals.uuid; res.send(response(status.SUCCESS, await addMyFollow(userId, req.params.clothId))); +} + +export const delFollow = async (req, res, next) => { + console.log("팔로우 취소를 요청하였습니다!"); + const userId = res.locals.uuid; + res.send(response(status.SUCCESS, await delMyFollow(userId, req.params.clothId))); } \ No newline at end of file diff --git a/src/domains/search/search.dao.js b/src/domains/search/search.dao.js index fd22a3a..56a685c 100644 --- a/src/domains/search/search.dao.js +++ b/src/domains/search/search.dao.js @@ -8,7 +8,7 @@ import { UserNicknameToClothId, UserCategoryToClothId, brandToBrandName, userIdToNickname, userToNickname, getBrandToBrandId, userToBrand, categoryToBrand, clothToBrand, clothCategoryToBrand, insertCloth, insertRealSize, getCloth, - addWishSQL, delWishSQL, getWishSQL, getFollowSQL, addFollowSQL } from "./search.sql.js"; + addWishSQL, delWishSQL, getWishSQL, getFollowSQL, addFollowSQL, delFollowSQL } from "./search.sql.js"; // nickname+cloth 반환 export const getNicknameToClothId = async (category) => { @@ -289,4 +289,22 @@ export const addFollowDAO = async (userId, clothId) => { }catch (err) { throw new BaseError(status.PARAMETER_IS_WRONG); } +} + +// Follow 취소 +export const delFollowDAO = async (userId, clothId) => { + try{ + const conn = await pool.getConnection(); + const to_user = await pool.query(getUserIdToClothId, clothId); + const is_exist = await pool.query(getFollowSQL, [userId, to_user[0][0].uuid]); + if(is_exist[0].length == 0){ + throw new BaseError(status.PARAMETER_IS_WRONG); + } + await pool.query(delFollowSQL, [userId, to_user[0][0].uuid]); + const follow = await pool.query(getFollowSQL, [userId, to_user[0][0].uuid]); + conn.release(); + return follow; + }catch (err) { + throw new BaseError(status.PARAMETER_IS_WRONG); + } } \ No newline at end of file diff --git a/src/domains/search/search.dto.js b/src/domains/search/search.dto.js index a7886d0..5ca8ab6 100644 --- a/src/domains/search/search.dto.js +++ b/src/domains/search/search.dto.js @@ -199,4 +199,13 @@ export const getWishDTO = (wish) => { export const addFollowDTO = (follow) => { return {"follow_id": follow}; +} + +export const delFollowDTO = (follow) => { + let follow_id; + if(follow[0].length == 0){ + follow_id = 0; + } + + return {"follow_id": follow_id}; } \ No newline at end of file diff --git a/src/domains/search/search.service.js b/src/domains/search/search.service.js index 290a32a..17813ec 100644 --- a/src/domains/search/search.service.js +++ b/src/domains/search/search.service.js @@ -1,7 +1,7 @@ import { BaseError } from "../../config/error.js"; import { status } from "../../config/response.status.js"; -import { addClothResponseDTO, addWishDTO, delWishDTO, addFollowDTO } from "./search.dto.js"; -import { clothAdd, getAddCloth, addWishDAO, delWishDAO, addFollowDAO } from "./search.dao.js"; +import { addClothResponseDTO, addWishDTO, delWishDTO, addFollowDTO, delFollowDTO } from "./search.dto.js"; +import { clothAdd, getAddCloth, addWishDAO, delWishDAO, addFollowDAO, delFollowDAO } from "./search.dao.js"; export const addMyCloth = async (userId, body) => { const requiredFields = ['name', 'product_code', 'category', 'size', 'fit']; @@ -58,4 +58,8 @@ export const delMyWish = async (userId, clothId) => { export const addMyFollow = async (userId, clothId) => { return addFollowDTO(await addFollowDAO(userId, clothId)); +} + +export const delMyFollow = async (userId, clothId) => { + return delFollowDTO(await delFollowDAO(userId, clothId)); } \ No newline at end of file diff --git a/src/domains/search/search.sql.js b/src/domains/search/search.sql.js index 7acff20..be3a4e6 100644 --- a/src/domains/search/search.sql.js +++ b/src/domains/search/search.sql.js @@ -115,4 +115,6 @@ export const getWishSQL = "SELECT id FROM wish WHERE cloth_id = ? AND wisher_uui export const getFollowSQL = "SELECT id FROM follow WHERE from_uuid = ? AND to_uuid = ? ;" -export const addFollowSQL = "INSERT INTO follow (from_uuid, to_uuid) VALUES (?, ?) ;" \ No newline at end of file +export const addFollowSQL = "INSERT INTO follow (from_uuid, to_uuid) VALUES (?, ?) ;" + +export const delFollowSQL = "DELETE FROM follow WHERE from_uuid = ? AND to_uuid = ? ;" \ No newline at end of file diff --git a/src/routes/search.js b/src/routes/search.js index 9304932..39b8fa5 100644 --- a/src/routes/search.js +++ b/src/routes/search.js @@ -2,7 +2,7 @@ import express from "express"; import asyncHandler from 'express-async-handler'; import { LoginCheck } from "../middlewares/logincheck.js"; import { searchPreview, clothView, searchView, brandView, addClothPreview, addCloth, - addWish, delWish, getWish, addFollow } from "../domains/search/search.controller.js"; + addWish, delWish, getWish, addFollow, delFollow } from "../domains/search/search.controller.js"; export const searchRouter = express.Router({mergeParams: true}); @@ -34,4 +34,7 @@ searchRouter.delete('/:clothId/wish', LoginCheck, asyncHandler(delWish)); searchRouter.get('/:clothId/wish', LoginCheck, asyncHandler(getWish)); //검색-follow에 추가 -searchRouter.post('/:clothId/follow', LoginCheck, asyncHandler(addFollow)); \ No newline at end of file +searchRouter.post('/:clothId/follow', LoginCheck, asyncHandler(addFollow)); + +//검색-follow에서 삭제 +searchRouter.delete('/:clothId/follow', LoginCheck, asyncHandler(delFollow)); \ No newline at end of file diff --git a/src/swagger/search.swagger.yaml b/src/swagger/search.swagger.yaml index 1a4b8aa..408deff 100644 --- a/src/swagger/search.swagger.yaml +++ b/src/swagger/search.swagger.yaml @@ -653,11 +653,7 @@ paths: data: type: array example: { - "clothData": [ - { - "wish_id": 20 - } - ] + "wish_id": 20 } '400': @@ -730,11 +726,7 @@ paths: data: type: array example: { - "clothData": [ - { - "wish_id": 20 - } - ] + "wish_id": 20 } '400': @@ -807,11 +799,7 @@ paths: data: type: array example: { - "clothData": [ - { - "wish_id": 20 - } - ] + "wish_id": 20 } '400': @@ -885,11 +873,80 @@ paths: data: type: array example: { - "clothData": [ - { - "wish_id": 20 - } - ] + "follow_id": 20 + } + + '400': + description: 잘못된 요청 + schema: + type: object + properties: + status: + type: integer + example: 400 + isSuccess: + type: boolean + example: false + code: + type: integer + example: COMMON001 + message: + type: string + example: 잘못된 요청입니다 + + '500': + description: 서버 에러 + schema: + type: object + properties: + status: + type: integer + example: 500 + isSuccess: + type: boolean + example: false + code: + type: integer + example: COMMON000 + message: + type: string + example: 서버 에러, 관리자에게 문의 바랍니다. + + delete: + tags: + - Search + summary: follow 취소 로직 + operationId: delFollow + security: + - bearerAuth: [] + parameters: + - name: clothId + in: path + required: true + schema: + type: integer + responses: + '200': + description: follow 취소 성공 + schema: + type: object + properties: + status: + type: integer + example: 200 + isSuccess: + type: boolean + example: true + code: + type: integer + example: 200 + message: + type: string + example: "success!" + data: + type: array + example: { + "follow_id": 0 } '400': From 33336dea05e148443c1ef403552e0ec7d50430e0 Mon Sep 17 00:00:00 2001 From: seoyeoneel02 Date: Sat, 19 Oct 2024 16:10:32 +0900 Subject: [PATCH 4/4] =?UTF-8?q?feat:=20follow=20=EC=A1=B0=ED=9A=8C=20#132?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/domains/search/search.controller.js | 8 ++- src/domains/search/search.dao.js | 14 +++++ src/domains/search/search.dto.js | 12 ++++ src/domains/search/search.provider.js | 9 ++- src/routes/search.js | 9 ++- src/swagger/search.swagger.yaml | 73 +++++++++++++++++++++++++ 6 files changed, 119 insertions(+), 6 deletions(-) diff --git a/src/domains/search/search.controller.js b/src/domains/search/search.controller.js index 5e14dc9..c425c25 100644 --- a/src/domains/search/search.controller.js +++ b/src/domains/search/search.controller.js @@ -1,6 +1,6 @@ import { response } from "../../config/response.js"; import { status } from "../../config/response.status.js"; -import { getSearch, getCloth, getSearchResult, getSearchBrand, getMyCloth, getMyWish } from "./search.provider.js"; +import { getSearch, getCloth, getSearchResult, getSearchBrand, getMyCloth, getMyWish, getMyFollow } from "./search.provider.js"; import { addMyCloth, addMyWish, delMyWish, addMyFollow, delMyFollow } from "./search.service.js"; export const searchPreview = async (req, res, next) => { @@ -63,4 +63,10 @@ export const delFollow = async (req, res, next) => { console.log("팔로우 취소를 요청하였습니다!"); const userId = res.locals.uuid; res.send(response(status.SUCCESS, await delMyFollow(userId, req.params.clothId))); +} + +export const getFollow = async (req, res, next) => { + console.log("팔로우 조회를 요청하였습니다!"); + const userId = res.locals.uuid; + res.send(response(status.SUCCESS, await getMyFollow(userId, req.params.clothId))); } \ No newline at end of file diff --git a/src/domains/search/search.dao.js b/src/domains/search/search.dao.js index 56a685c..91a08a6 100644 --- a/src/domains/search/search.dao.js +++ b/src/domains/search/search.dao.js @@ -302,6 +302,20 @@ export const delFollowDAO = async (userId, clothId) => { } await pool.query(delFollowSQL, [userId, to_user[0][0].uuid]); const follow = await pool.query(getFollowSQL, [userId, to_user[0][0].uuid]); + conn.release(); + return follow; + }catch (err) { + throw new BaseError(status.PARAMETER_IS_WRONG); + } +} + +// Follow 조회 +export const getFollowDAO = async (userId, clothId) => { + try{ + const conn = await pool.getConnection(); + const to_user = await pool.query(getUserIdToClothId, clothId); + const follow = await pool.query(getFollowSQL, [userId, to_user[0][0].uuid]); + conn.release(); return follow; }catch (err) { diff --git a/src/domains/search/search.dto.js b/src/domains/search/search.dto.js index 5ca8ab6..74bc4e0 100644 --- a/src/domains/search/search.dto.js +++ b/src/domains/search/search.dto.js @@ -207,5 +207,17 @@ export const delFollowDTO = (follow) => { follow_id = 0; } + return {"follow_id": follow_id}; +} + +export const getFollowDTO = (follow) => { + + let follow_id; + if(follow[0].length == 0){ + follow_id = 0; + } else if(follow[0].length == 1){ + follow_id = follow[0][0].id + } + return {"follow_id": follow_id}; } \ No newline at end of file diff --git a/src/domains/search/search.provider.js b/src/domains/search/search.provider.js index 5e80289..88f294c 100644 --- a/src/domains/search/search.provider.js +++ b/src/domains/search/search.provider.js @@ -1,7 +1,7 @@ import { previewSearchResponseDTO, previewClothResponseDTO, SearchResultResponseDTO, SearchBrandResponseDTO, - previewMyClothResponseDTO, getWishDTO } from "./search.dto.js" + previewMyClothResponseDTO, getWishDTO, getFollowDTO } from "./search.dto.js" import { getNicknameToClothId, getPreviewCloth, getUserToClothId, getNicknameToClothName, getPreviewBrand, getPreviewUser, - getBrand, getNicknameToBrand, getPreviewMyCloth, getWishDAO } from "./search.dao.js"; + getBrand, getNicknameToBrand, getPreviewMyCloth, getWishDAO, getFollowDAO } from "./search.dao.js"; export const getSearch = async (query) => { const { category } = query; @@ -34,4 +34,9 @@ export const getMyCloth = async (userId, clothId) => { export const getMyWish = async (userId, clothId) => { return getWishDTO(await getWishDAO(userId, clothId)); +} + +export const getMyFollow = async (userId, clothId) => { + + return getFollowDTO(await getFollowDAO(userId, clothId)); } \ No newline at end of file diff --git a/src/routes/search.js b/src/routes/search.js index 39b8fa5..bb6ce5e 100644 --- a/src/routes/search.js +++ b/src/routes/search.js @@ -2,7 +2,7 @@ import express from "express"; import asyncHandler from 'express-async-handler'; import { LoginCheck } from "../middlewares/logincheck.js"; import { searchPreview, clothView, searchView, brandView, addClothPreview, addCloth, - addWish, delWish, getWish, addFollow, delFollow } from "../domains/search/search.controller.js"; + addWish, delWish, getWish, addFollow, delFollow, getFollow } from "../domains/search/search.controller.js"; export const searchRouter = express.Router({mergeParams: true}); @@ -30,11 +30,14 @@ searchRouter.post('/:clothId/wish', LoginCheck, asyncHandler(addWish)); //검색-wish에서 삭제 searchRouter.delete('/:clothId/wish', LoginCheck, asyncHandler(delWish)); -//검색-wish +//검색-wish 조회 searchRouter.get('/:clothId/wish', LoginCheck, asyncHandler(getWish)); //검색-follow에 추가 searchRouter.post('/:clothId/follow', LoginCheck, asyncHandler(addFollow)); //검색-follow에서 삭제 -searchRouter.delete('/:clothId/follow', LoginCheck, asyncHandler(delFollow)); \ No newline at end of file +searchRouter.delete('/:clothId/follow', LoginCheck, asyncHandler(delFollow)); + +//검색-follow 조회 +searchRouter.get('/:clothId/follow', LoginCheck, asyncHandler(getFollow)); \ No newline at end of file diff --git a/src/swagger/search.swagger.yaml b/src/swagger/search.swagger.yaml index 408deff..b9e7224 100644 --- a/src/swagger/search.swagger.yaml +++ b/src/swagger/search.swagger.yaml @@ -967,6 +967,79 @@ paths: type: string example: 잘못된 요청입니다 + '500': + description: 서버 에러 + schema: + type: object + properties: + status: + type: integer + example: 500 + isSuccess: + type: boolean + example: false + code: + type: integer + example: COMMON000 + message: + type: string + example: 서버 에러, 관리자에게 문의 바랍니다. + + get: + tags: + - Search + summary: follow 조회 로직 + operationId: getFollow + security: + - bearerAuth: [] + parameters: + - name: clothId + in: path + required: true + schema: + type: integer + responses: + '200': + description: follow 조회 성공 + schema: + type: object + properties: + status: + type: integer + example: 200 + isSuccess: + type: boolean + example: true + code: + type: integer + example: 200 + message: + type: string + example: "success!" + data: + type: array + example: { + "follow_id": 20 + } + + '400': + description: 잘못된 요청 + schema: + type: object + properties: + status: + type: integer + example: 400 + isSuccess: + type: boolean + example: false + code: + type: integer + example: COMMON001 + message: + type: string + example: 잘못된 요청입니다 + '500': description: 서버 에러 schema: