From 73a383981ca6579d72cd0021f0ac1d595982263c Mon Sep 17 00:00:00 2001 From: suhwan2004 Date: Mon, 4 Nov 2024 00:16:16 +0900 Subject: [PATCH 01/12] =?UTF-8?q?feat:=20=ED=94=BC=EB=93=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95,=20=EC=9E=91=EC=84=B1=20Request=20DTO=EB=A5=BC=20enti?= =?UTF-8?q?ties/feed/model/types.ts=20=EC=97=90=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entities/feed/model/types.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/entities/feed/model/types.ts diff --git a/src/entities/feed/model/types.ts b/src/entities/feed/model/types.ts new file mode 100644 index 0000000..800c871 --- /dev/null +++ b/src/entities/feed/model/types.ts @@ -0,0 +1,13 @@ +export interface IReportFeedReqDTO { + category: string; + content: string; + isBlind: boolean; +} + +export interface IWriteFeedReqDTO { + content: string; + images: string[]; + scope: TFeedScope; +} + +export type TFeedScope = 'public' | 'friends' | 'private'; From 42dffa7db7730d1cd7c9392967bdfc00fd617877 Mon Sep 17 00:00:00 2001 From: suhwan2004 Date: Sun, 17 Nov 2024 14:27:54 +0900 Subject: [PATCH 02/12] =?UTF-8?q?feat:=20=EA=B8=B0=EC=A1=B4=20mocks?= =?UTF-8?q?=EC=97=90=20=EB=93=A4=EC=96=B4=EC=9E=88=EB=8D=98=20=ED=83=80?= =?UTF-8?q?=EC=9E=85=EC=9D=84=20entities=EB=A1=9C=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/mocks/data/feed.ts | 3 +-- src/app/mocks/handlers/feed.ts | 13 +++++++++---- src/entities/.gitkeep | 0 src/entities/search/index.ts | 1 + src/entities/search/model/index.ts | 1 + src/entities/search/model/types.ts | 19 +++++++++++++++++++ src/entities/user/model/index.ts | 2 +- src/entities/user/model/types.ts | 5 +++++ 8 files changed, 37 insertions(+), 7 deletions(-) delete mode 100644 src/entities/.gitkeep create mode 100644 src/entities/search/index.ts create mode 100644 src/entities/search/model/index.ts create mode 100644 src/entities/search/model/types.ts create mode 100644 src/entities/user/model/types.ts diff --git a/src/app/mocks/data/feed.ts b/src/app/mocks/data/feed.ts index 83a48f5..6780bbe 100644 --- a/src/app/mocks/data/feed.ts +++ b/src/app/mocks/data/feed.ts @@ -1,5 +1,4 @@ -import { IFeed } from '@/entities/feed'; -import { IImage } from '@/shared/types'; +import { IFeed, IImage } from '@/entities/feed'; import { userMockData } from './user'; diff --git a/src/app/mocks/handlers/feed.ts b/src/app/mocks/handlers/feed.ts index 60a3b1d..b87d038 100644 --- a/src/app/mocks/handlers/feed.ts +++ b/src/app/mocks/handlers/feed.ts @@ -1,6 +1,11 @@ import { http } from 'msw'; -import { IReportFeedReqDTO, IWriteFeedReqDTO } from '@/entities/feed'; +import { + IReportFeedReqDTO, + IReportFeedResDTO, + TModifyFeedReqDTO, + TWriteFeedReqDTO, +} from '@/entities/feed'; import { feedMockData } from '../data'; import { createHttpErrorResponse, createHttpSuccessResponse } from '../lib'; @@ -24,14 +29,14 @@ export const feedHandlers = [ }); } - return createHttpSuccessResponse({ + return createHttpSuccessResponse({ isReported: true, }); }), // 2️⃣ 피드 작성 http.post('http://api.example.com/v2/feeds', async ({ request }) => { - const { content, images, scope } = (await request.json()) as IWriteFeedReqDTO; + const { content, images, scope } = (await request.json()) as TWriteFeedReqDTO; if (!content) { return createHttpErrorResponse('피드 등록을 위해 컨텐츠를 작성해야 합니다.'); @@ -60,7 +65,7 @@ export const feedHandlers = [ http.put('http://api.example.com/v2/feeds/:feedId', async ({ request, params }) => { const { feedId } = params; - const { content, images, scope } = (await request.json()) as IWriteFeedReqDTO; + const { content, images, scope } = (await request.json()) as TModifyFeedReqDTO; if (!content) { return createHttpErrorResponse('피드 수정을 위해 컨텐츠를 작성해야 합니다.'); diff --git a/src/entities/.gitkeep b/src/entities/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/src/entities/search/index.ts b/src/entities/search/index.ts new file mode 100644 index 0000000..9f8ccad --- /dev/null +++ b/src/entities/search/index.ts @@ -0,0 +1 @@ +export * from './model'; diff --git a/src/entities/search/model/index.ts b/src/entities/search/model/index.ts new file mode 100644 index 0000000..fcb073f --- /dev/null +++ b/src/entities/search/model/index.ts @@ -0,0 +1 @@ +export * from './types'; diff --git a/src/entities/search/model/types.ts b/src/entities/search/model/types.ts new file mode 100644 index 0000000..a029b44 --- /dev/null +++ b/src/entities/search/model/types.ts @@ -0,0 +1,19 @@ +import { IFeed } from '@/entities/feed'; +import { IUser } from '@/entities/user'; + +//피드 검색 +export interface ISearchFeedResDTO extends ISearchCommonResDTO { + contents: IFeed; +} + +//유저 검색 +export interface ISearchUserResDTO extends ISearchCommonResDTO { + contents: IUser; +} + +export interface ISearchCommonResDTO { + currentPageNumber: number; + pageSize: number; + numberOfElements: number; + hasNextPage: boolean; +} diff --git a/src/entities/user/model/index.ts b/src/entities/user/model/index.ts index b38ebc9..fcb073f 100644 --- a/src/entities/user/model/index.ts +++ b/src/entities/user/model/index.ts @@ -1 +1 @@ -export * from './type'; +export * from './types'; diff --git a/src/entities/user/model/types.ts b/src/entities/user/model/types.ts new file mode 100644 index 0000000..0eea308 --- /dev/null +++ b/src/entities/user/model/types.ts @@ -0,0 +1,5 @@ +export interface IUser { + id: number; + profileImage: string; + username: string; +} From f85b60f0e41c088c08a56df6b011437749ad1a42 Mon Sep 17 00:00:00 2001 From: suhwan2004 Date: Sun, 17 Nov 2024 14:28:35 +0900 Subject: [PATCH 03/12] =?UTF-8?q?feat:=20=ED=94=BC=EB=93=9C=20=EC=88=A8?= =?UTF-8?q?=EA=B8=B0=EA=B8=B0,=20=EC=88=A8=EA=B8=B0=EA=B8=B0=20=EC=B7=A8?= =?UTF-8?q?=EC=86=8C=20mock=20handler=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/mocks/handlers/hide.ts | 42 ++++++++++++++++++++++++++++++++ src/entities/hide/index.ts | 1 + src/entities/hide/model/index.ts | 1 + src/entities/hide/model/types.ts | 9 +++++++ 4 files changed, 53 insertions(+) create mode 100644 src/app/mocks/handlers/hide.ts create mode 100644 src/entities/hide/index.ts create mode 100644 src/entities/hide/model/index.ts create mode 100644 src/entities/hide/model/types.ts diff --git a/src/app/mocks/handlers/hide.ts b/src/app/mocks/handlers/hide.ts new file mode 100644 index 0000000..3b93cd5 --- /dev/null +++ b/src/app/mocks/handlers/hide.ts @@ -0,0 +1,42 @@ +import { http } from 'msw'; + +import { ICancleHideResDTO, IHideFeedResDTO } from '@/entities/hide'; + +import { feedMockData } from '../data'; +import { createHttpErrorResponse, createHttpSuccessResponse } from '../lib'; + +export const feedHandlers = [ + // 1️⃣ 피드 숨기기 + http.post('http://api.example.com/v2/feeds/:feedId/hides', async ({ params }) => { + const { feedId } = params; + + if (!feedId) { + return createHttpErrorResponse('피드 ID가 입력되어야 합니다.'); + } + + feedMockData.forEach((cur) => { + if (cur.id === +feedId) cur.isBlinded = true; + }); + + return createHttpSuccessResponse({ + isHidden: true, + }); + }), + + // 2️⃣ 피드 숨기기 취소 + http.post('http://api.example.com/v2/feeds/:feedId/hides', async ({ params }) => { + const { feedId } = params; + + if (!feedId) { + return createHttpErrorResponse('피드 ID가 입력되어야 합니다.'); + } + + feedMockData.forEach((cur) => { + if (cur.id === +feedId) cur.isBlinded = false; + }); + + return createHttpSuccessResponse({ + isHidden: false, + }); + }), +]; diff --git a/src/entities/hide/index.ts b/src/entities/hide/index.ts new file mode 100644 index 0000000..9f8ccad --- /dev/null +++ b/src/entities/hide/index.ts @@ -0,0 +1 @@ +export * from './model'; diff --git a/src/entities/hide/model/index.ts b/src/entities/hide/model/index.ts new file mode 100644 index 0000000..fcb073f --- /dev/null +++ b/src/entities/hide/model/index.ts @@ -0,0 +1 @@ +export * from './types'; diff --git a/src/entities/hide/model/types.ts b/src/entities/hide/model/types.ts new file mode 100644 index 0000000..1cd42e8 --- /dev/null +++ b/src/entities/hide/model/types.ts @@ -0,0 +1,9 @@ +// 피드 숨기기 +export interface IHideFeedResDTO { + isHidden: boolean; +} + +// 피드 숨기기 취소 +export interface ICancleHideResDTO { + isHidden: boolean; +} From 073edcd2546f0493e0d1c700f38e942228220ef7 Mon Sep 17 00:00:00 2001 From: suhwan2004 Date: Sun, 17 Nov 2024 14:28:57 +0900 Subject: [PATCH 04/12] =?UTF-8?q?feat:=20=ED=94=BC=EB=93=9C=20=ED=83=80?= =?UTF-8?q?=EC=9E=85=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entities/feed/model/types.ts | 45 ++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/src/entities/feed/model/types.ts b/src/entities/feed/model/types.ts index 800c871..e54ef71 100644 --- a/src/entities/feed/model/types.ts +++ b/src/entities/feed/model/types.ts @@ -1,13 +1,54 @@ +// 피드 신고 +export interface IReportFeedParamsDTO { + feedId: string; +} export interface IReportFeedReqDTO { category: string; content: string; isBlind: boolean; } -export interface IWriteFeedReqDTO { +export interface IReportFeedResDTO { + isReported: boolean; +} + +// 피드 작성 +export type TWriteFeedReqDTO = IFeedEditCommonDTO; + +// 피드 수정 +export type TModifyFeedReqDTO = IFeedEditCommonDTO; + +// common types... +export type TFeedScope = 'public' | 'friends' | 'private'; +export interface IFeedEditCommonDTO { content: string; images: string[]; scope: TFeedScope; } +export interface IFeed { + id: number; -export type TFeedScope = 'public' | 'friends' | 'private'; + user: { + id: number; + profileImage: string; + username: string; + }; + + content: string; + images: IImage[]; + + likeCount: number; + commentCount: number; + + isLiked: boolean; + isBookmarked: boolean; + isBlinded: boolean; + + createdAt: string; + updatedAt: string; +} + +export interface IImage { + id: number; + imageUrl: string; +} From a1ac725b0ceac1ecac76a0c7e7f79cdd89417bb5 Mon Sep 17 00:00:00 2001 From: suhwan2004 Date: Sun, 17 Nov 2024 14:38:50 +0900 Subject: [PATCH 05/12] =?UTF-8?q?fix:=20main=20branch=20rebase=20=ED=9B=84?= =?UTF-8?q?=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/mocks/data/feed.ts | 3 +- src/entities/feed/model/report.type.ts | 7 +++ src/entities/feed/model/types.ts | 54 ------------------- src/entities/feed/model/write.type.ts | 8 ++- .../hide/model/{types.ts => hide.type.ts} | 0 src/entities/hide/model/index.ts | 2 +- src/entities/search/model/index.ts | 2 +- .../search/model/{types.ts => search.type.ts} | 0 8 files changed, 18 insertions(+), 58 deletions(-) delete mode 100644 src/entities/feed/model/types.ts rename src/entities/hide/model/{types.ts => hide.type.ts} (100%) rename src/entities/search/model/{types.ts => search.type.ts} (100%) diff --git a/src/app/mocks/data/feed.ts b/src/app/mocks/data/feed.ts index 6780bbe..84b2f75 100644 --- a/src/app/mocks/data/feed.ts +++ b/src/app/mocks/data/feed.ts @@ -1,4 +1,5 @@ -import { IFeed, IImage } from '@/entities/feed'; +import { IFeed } from '@/entities/feed'; +import { IImage } from '@/shared/types/image'; import { userMockData } from './user'; diff --git a/src/entities/feed/model/report.type.ts b/src/entities/feed/model/report.type.ts index 4b80a80..689ddf5 100644 --- a/src/entities/feed/model/report.type.ts +++ b/src/entities/feed/model/report.type.ts @@ -1,5 +1,12 @@ +export interface IReportFeedParamsDTO { + feedId: string; +} export interface IReportFeedReqDTO { category: string; content: string; isBlind: boolean; } + +export interface IReportFeedResDTO { + isReported: boolean; +} diff --git a/src/entities/feed/model/types.ts b/src/entities/feed/model/types.ts deleted file mode 100644 index e54ef71..0000000 --- a/src/entities/feed/model/types.ts +++ /dev/null @@ -1,54 +0,0 @@ -// 피드 신고 -export interface IReportFeedParamsDTO { - feedId: string; -} -export interface IReportFeedReqDTO { - category: string; - content: string; - isBlind: boolean; -} - -export interface IReportFeedResDTO { - isReported: boolean; -} - -// 피드 작성 -export type TWriteFeedReqDTO = IFeedEditCommonDTO; - -// 피드 수정 -export type TModifyFeedReqDTO = IFeedEditCommonDTO; - -// common types... -export type TFeedScope = 'public' | 'friends' | 'private'; -export interface IFeedEditCommonDTO { - content: string; - images: string[]; - scope: TFeedScope; -} -export interface IFeed { - id: number; - - user: { - id: number; - profileImage: string; - username: string; - }; - - content: string; - images: IImage[]; - - likeCount: number; - commentCount: number; - - isLiked: boolean; - isBookmarked: boolean; - isBlinded: boolean; - - createdAt: string; - updatedAt: string; -} - -export interface IImage { - id: number; - imageUrl: string; -} diff --git a/src/entities/feed/model/write.type.ts b/src/entities/feed/model/write.type.ts index 9ca7903..f46f3b0 100644 --- a/src/entities/feed/model/write.type.ts +++ b/src/entities/feed/model/write.type.ts @@ -1,6 +1,12 @@ import { TFeedScope } from './common.type'; -export interface IWriteFeedReqDTO { +// 피드 작성 +export type TWriteFeedReqDTO = IFeedEditCommonDTO; + +// 피드 수정 +export type TModifyFeedReqDTO = IFeedEditCommonDTO; + +export interface IFeedEditCommonDTO { content: string; images: string[]; scope: TFeedScope; diff --git a/src/entities/hide/model/types.ts b/src/entities/hide/model/hide.type.ts similarity index 100% rename from src/entities/hide/model/types.ts rename to src/entities/hide/model/hide.type.ts diff --git a/src/entities/hide/model/index.ts b/src/entities/hide/model/index.ts index fcb073f..80135bb 100644 --- a/src/entities/hide/model/index.ts +++ b/src/entities/hide/model/index.ts @@ -1 +1 @@ -export * from './types'; +export * from './hide.type'; diff --git a/src/entities/search/model/index.ts b/src/entities/search/model/index.ts index fcb073f..0b3519c 100644 --- a/src/entities/search/model/index.ts +++ b/src/entities/search/model/index.ts @@ -1 +1 @@ -export * from './types'; +export * from './search.type'; diff --git a/src/entities/search/model/types.ts b/src/entities/search/model/search.type.ts similarity index 100% rename from src/entities/search/model/types.ts rename to src/entities/search/model/search.type.ts From 9fc03a50a48e886d821ff88c442f1b5451f9219c Mon Sep 17 00:00:00 2001 From: suhwan2004 Date: Sun, 17 Nov 2024 14:44:14 +0900 Subject: [PATCH 06/12] =?UTF-8?q?feat:=20=EA=B2=80=EC=83=89=20mock=20handl?= =?UTF-8?q?er=20=EB=82=B4=20response=20dto=20=ED=83=80=EC=9E=85=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/mocks/data/feed.ts | 2 +- src/app/mocks/handlers/search.ts | 6 ++++-- src/entities/search/model/search.type.ts | 11 ++++++----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/app/mocks/data/feed.ts b/src/app/mocks/data/feed.ts index 84b2f75..83a48f5 100644 --- a/src/app/mocks/data/feed.ts +++ b/src/app/mocks/data/feed.ts @@ -1,5 +1,5 @@ import { IFeed } from '@/entities/feed'; -import { IImage } from '@/shared/types/image'; +import { IImage } from '@/shared/types'; import { userMockData } from './user'; diff --git a/src/app/mocks/handlers/search.ts b/src/app/mocks/handlers/search.ts index 04a2b65..057fddf 100644 --- a/src/app/mocks/handlers/search.ts +++ b/src/app/mocks/handlers/search.ts @@ -1,6 +1,8 @@ import Fuse from 'fuse.js'; import { http } from 'msw'; +import { ISearchFeedResDTO, ISearchUserResDTO } from '@/entities/search'; + import { feedMockData, userMockData } from '../data'; import { createHttpErrorResponse, createHttpSuccessResponse } from '../lib'; @@ -28,7 +30,7 @@ export const searchHandlers = [ const totalFeeds = contents.length; const hasNextPage = totalFeeds > page * size; - return createHttpSuccessResponse({ + return createHttpSuccessResponse({ feed: { contents, currentPageNumber: page, @@ -62,7 +64,7 @@ export const searchHandlers = [ const totalFeeds = contents.length; const hasNextPage = totalFeeds > page * size; - return createHttpSuccessResponse({ + return createHttpSuccessResponse({ user: { contents, currentPageNumber: page, diff --git a/src/entities/search/model/search.type.ts b/src/entities/search/model/search.type.ts index a029b44..071b4c9 100644 --- a/src/entities/search/model/search.type.ts +++ b/src/entities/search/model/search.type.ts @@ -2,16 +2,17 @@ import { IFeed } from '@/entities/feed'; import { IUser } from '@/entities/user'; //피드 검색 -export interface ISearchFeedResDTO extends ISearchCommonResDTO { - contents: IFeed; +export interface ISearchFeedResDTO { + feed: ICommonSearchData; } //유저 검색 -export interface ISearchUserResDTO extends ISearchCommonResDTO { - contents: IUser; +export interface ISearchUserResDTO { + user: ICommonSearchData; } -export interface ISearchCommonResDTO { +export interface ICommonSearchData { + contents: T; currentPageNumber: number; pageSize: number; numberOfElements: number; From 2b03e2e7703df3d5697f4a5217dcfb148b660be5 Mon Sep 17 00:00:00 2001 From: suhwan2004 Date: Sun, 17 Nov 2024 14:59:22 +0900 Subject: [PATCH 07/12] =?UTF-8?q?chore:=20=EC=98=A4=ED=83=88=EC=9E=90=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/mocks/handlers/hide.ts | 4 ++-- src/entities/hide/model/hide.type.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/mocks/handlers/hide.ts b/src/app/mocks/handlers/hide.ts index 3b93cd5..9a73fc9 100644 --- a/src/app/mocks/handlers/hide.ts +++ b/src/app/mocks/handlers/hide.ts @@ -1,6 +1,6 @@ import { http } from 'msw'; -import { ICancleHideResDTO, IHideFeedResDTO } from '@/entities/hide'; +import { ICancelHideResDTO, IHideFeedResDTO } from '@/entities/hide'; import { feedMockData } from '../data'; import { createHttpErrorResponse, createHttpSuccessResponse } from '../lib'; @@ -35,7 +35,7 @@ export const feedHandlers = [ if (cur.id === +feedId) cur.isBlinded = false; }); - return createHttpSuccessResponse({ + return createHttpSuccessResponse({ isHidden: false, }); }), diff --git a/src/entities/hide/model/hide.type.ts b/src/entities/hide/model/hide.type.ts index 1cd42e8..cb3519d 100644 --- a/src/entities/hide/model/hide.type.ts +++ b/src/entities/hide/model/hide.type.ts @@ -4,6 +4,6 @@ export interface IHideFeedResDTO { } // 피드 숨기기 취소 -export interface ICancleHideResDTO { +export interface ICancelHideResDTO { isHidden: boolean; } From f14e66fd3b0a4fb0c56712cce973c4bc17dc433b Mon Sep 17 00:00:00 2001 From: suhwan2004 Date: Sun, 17 Nov 2024 23:25:56 +0900 Subject: [PATCH 08/12] =?UTF-8?q?feat:=20params=20type=EC=9D=84=20feed,=20?= =?UTF-8?q?hide=20mock=20handlers=EC=97=90=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/mocks/handlers/feed.ts | 84 +++++++++++++++------------ src/app/mocks/handlers/hide.ts | 67 ++++++++++++--------- src/entities/feed/model/write.type.ts | 6 ++ src/entities/hide/model/hide.type.ts | 6 ++ 4 files changed, 97 insertions(+), 66 deletions(-) diff --git a/src/app/mocks/handlers/feed.ts b/src/app/mocks/handlers/feed.ts index b87d038..968bf94 100644 --- a/src/app/mocks/handlers/feed.ts +++ b/src/app/mocks/handlers/feed.ts @@ -1,6 +1,8 @@ import { http } from 'msw'; import { + IModifyFeedParamsDTO, + IReportFeedParamsDTO, IReportFeedReqDTO, IReportFeedResDTO, TModifyFeedReqDTO, @@ -12,27 +14,30 @@ import { createHttpErrorResponse, createHttpSuccessResponse } from '../lib'; export const feedHandlers = [ // 1️⃣ 피드 신고 - http.post('http://api.example.com/v2/feeds/:feedId/reports', async ({ request, params }) => { - const { feedId } = params; + http.post( + 'http://api.example.com/v2/feeds/:feedId/reports', + async ({ request, params }) => { + const { feedId } = params; - const { category, isBlind } = (await request.json()) as IReportFeedReqDTO; + const { category, isBlind } = (await request.json()) as IReportFeedReqDTO; - if (!feedId || !category) { - return createHttpErrorResponse('피드 ID, 신고 카테고리가 필수로 입력되어야 합니다.'); - } + if (!feedId || !category) { + return createHttpErrorResponse('피드 ID, 신고 카테고리가 필수로 입력되어야 합니다.'); + } - if (isBlind) { - feedMockData.forEach((cur) => { - if (cur.id === +feedId) { - cur.isBlinded = true; - } - }); - } + if (isBlind) { + feedMockData.forEach((cur) => { + if (cur.id === +feedId) { + cur.isBlinded = true; + } + }); + } - return createHttpSuccessResponse({ - isReported: true, - }); - }), + return createHttpSuccessResponse({ + isReported: true, + }); + }, + ), // 2️⃣ 피드 작성 http.post('http://api.example.com/v2/feeds', async ({ request }) => { @@ -62,29 +67,32 @@ export const feedHandlers = [ }), // 3️⃣ 피드 수정 - http.put('http://api.example.com/v2/feeds/:feedId', async ({ request, params }) => { - const { feedId } = params; + http.put( + 'http://api.example.com/v2/feeds/:feedId', + async ({ request, params }) => { + const { feedId } = params; - const { content, images, scope } = (await request.json()) as TModifyFeedReqDTO; + const { content, images, scope } = (await request.json()) as TModifyFeedReqDTO; - if (!content) { - return createHttpErrorResponse('피드 수정을 위해 컨텐츠를 작성해야 합니다.'); - } else if (!scope) { - return createHttpErrorResponse('피드 수정을 위해 공개 범위를 설정해야 합니다.'); - } - - feedMockData.forEach((feed) => { - const numFeedId = +feedId; - if (feed.id === numFeedId) { - feedMockData[numFeedId] = { - ...feedMockData[numFeedId], - content, - images: images.map((url, index) => ({ id: index + 1, imageUrl: url })), - updatedAt: new Date().toISOString(), - }; + if (!content) { + return createHttpErrorResponse('피드 수정을 위해 컨텐츠를 작성해야 합니다.'); + } else if (!scope) { + return createHttpErrorResponse('피드 수정을 위해 공개 범위를 설정해야 합니다.'); } - }); - return createHttpSuccessResponse({}); - }), + feedMockData.forEach((feed) => { + const numFeedId = +feedId; + if (feed.id === numFeedId) { + feedMockData[numFeedId] = { + ...feedMockData[numFeedId], + content, + images: images.map((url, index) => ({ id: index + 1, imageUrl: url })), + updatedAt: new Date().toISOString(), + }; + } + }); + + return createHttpSuccessResponse({}); + }, + ), ]; diff --git a/src/app/mocks/handlers/hide.ts b/src/app/mocks/handlers/hide.ts index 9a73fc9..b2a1fb3 100644 --- a/src/app/mocks/handlers/hide.ts +++ b/src/app/mocks/handlers/hide.ts @@ -1,42 +1,53 @@ import { http } from 'msw'; -import { ICancelHideResDTO, IHideFeedResDTO } from '@/entities/hide'; +import { + ICancelHideFeedParamsDTO, + ICancelHideResDTO, + IHideFeedParamsDTO, + IHideFeedResDTO, +} from '@/entities/hide'; import { feedMockData } from '../data'; import { createHttpErrorResponse, createHttpSuccessResponse } from '../lib'; export const feedHandlers = [ // 1️⃣ 피드 숨기기 - http.post('http://api.example.com/v2/feeds/:feedId/hides', async ({ params }) => { - const { feedId } = params; + http.put( + 'http://api.example.com/v2/feeds/:feedId/hides', + async ({ params }) => { + const { feedId } = params; - if (!feedId) { - return createHttpErrorResponse('피드 ID가 입력되어야 합니다.'); - } + if (!feedId) { + return createHttpErrorResponse('피드 ID가 입력되어야 합니다.'); + } - feedMockData.forEach((cur) => { - if (cur.id === +feedId) cur.isBlinded = true; - }); + feedMockData.forEach((cur) => { + if (cur.id === +feedId) cur.isBlinded = true; + }); - return createHttpSuccessResponse({ - isHidden: true, - }); - }), + return createHttpSuccessResponse({ + isHidden: true, + }); + }, + ), // 2️⃣ 피드 숨기기 취소 - http.post('http://api.example.com/v2/feeds/:feedId/hides', async ({ params }) => { - const { feedId } = params; - - if (!feedId) { - return createHttpErrorResponse('피드 ID가 입력되어야 합니다.'); - } - - feedMockData.forEach((cur) => { - if (cur.id === +feedId) cur.isBlinded = false; - }); - - return createHttpSuccessResponse({ - isHidden: false, - }); - }), + http.delete( + 'http://api.example.com/v2/feeds/:feedId/hides', + async ({ params }) => { + const { feedId } = params; + + if (!feedId) { + return createHttpErrorResponse('피드 ID가 입력되어야 합니다.'); + } + + feedMockData.forEach((cur) => { + if (cur.id === +feedId) cur.isBlinded = false; + }); + + return createHttpSuccessResponse({ + isHidden: false, + }); + }, + ), ]; diff --git a/src/entities/feed/model/write.type.ts b/src/entities/feed/model/write.type.ts index f46f3b0..0ffb4e1 100644 --- a/src/entities/feed/model/write.type.ts +++ b/src/entities/feed/model/write.type.ts @@ -1,9 +1,15 @@ import { TFeedScope } from './common.type'; // 피드 작성 +export interface IWriteFeedParamsDTO { + feedId: string; +} export type TWriteFeedReqDTO = IFeedEditCommonDTO; // 피드 수정 +export interface IModifyFeedParamsDTO { + feedId: string; +} export type TModifyFeedReqDTO = IFeedEditCommonDTO; export interface IFeedEditCommonDTO { diff --git a/src/entities/hide/model/hide.type.ts b/src/entities/hide/model/hide.type.ts index cb3519d..f108fbc 100644 --- a/src/entities/hide/model/hide.type.ts +++ b/src/entities/hide/model/hide.type.ts @@ -1,9 +1,15 @@ // 피드 숨기기 +export interface IHideFeedParamsDTO { + feedId: string; +} export interface IHideFeedResDTO { isHidden: boolean; } // 피드 숨기기 취소 +export interface ICancelHideFeedParamsDTO { + feedId: string; +} export interface ICancelHideResDTO { isHidden: boolean; } From b70b38b30095ccccd24ba22601d20714c9994aab Mon Sep 17 00:00:00 2001 From: suhwan2004 Date: Sun, 17 Nov 2024 23:26:56 +0900 Subject: [PATCH 09/12] =?UTF-8?q?feat:=20ICommonSearchData=20=ED=83=80?= =?UTF-8?q?=EC=9E=85=EC=9D=84=20shared=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entities/search/model/search.type.ts | 9 +-------- src/shared/types/index.ts | 1 + src/shared/types/search.ts | 7 +++++++ 3 files changed, 9 insertions(+), 8 deletions(-) create mode 100644 src/shared/types/search.ts diff --git a/src/entities/search/model/search.type.ts b/src/entities/search/model/search.type.ts index 071b4c9..489452e 100644 --- a/src/entities/search/model/search.type.ts +++ b/src/entities/search/model/search.type.ts @@ -1,5 +1,6 @@ import { IFeed } from '@/entities/feed'; import { IUser } from '@/entities/user'; +import { ICommonSearchData } from '@/shared/types'; //피드 검색 export interface ISearchFeedResDTO { @@ -10,11 +11,3 @@ export interface ISearchFeedResDTO { export interface ISearchUserResDTO { user: ICommonSearchData; } - -export interface ICommonSearchData { - contents: T; - currentPageNumber: number; - pageSize: number; - numberOfElements: number; - hasNextPage: boolean; -} diff --git a/src/shared/types/index.ts b/src/shared/types/index.ts index cf09068..eead6ae 100644 --- a/src/shared/types/index.ts +++ b/src/shared/types/index.ts @@ -1 +1,2 @@ export * from './image'; +export * from './search'; diff --git a/src/shared/types/search.ts b/src/shared/types/search.ts new file mode 100644 index 0000000..12dfa4a --- /dev/null +++ b/src/shared/types/search.ts @@ -0,0 +1,7 @@ +export interface ICommonSearchData { + contents: T; + currentPageNumber: number; + pageSize: number; + numberOfElements: number; + hasNextPage: boolean; +} From 9301b50ae164168058cb8d9e54bf4e5329838b4e Mon Sep 17 00:00:00 2001 From: suhwan2004 Date: Sun, 17 Nov 2024 23:39:34 +0900 Subject: [PATCH 10/12] =?UTF-8?q?feat:=20hide=EB=A5=BC=20feature=EB=A1=9C?= =?UTF-8?q?=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/mocks/handlers/hide.ts | 2 +- src/{entities/hide => features/hideFeed}/index.ts | 0 src/{entities/hide => features/hideFeed}/model/hide.type.ts | 0 src/{entities/hide => features/hideFeed}/model/index.ts | 0 4 files changed, 1 insertion(+), 1 deletion(-) rename src/{entities/hide => features/hideFeed}/index.ts (100%) rename src/{entities/hide => features/hideFeed}/model/hide.type.ts (100%) rename src/{entities/hide => features/hideFeed}/model/index.ts (100%) diff --git a/src/app/mocks/handlers/hide.ts b/src/app/mocks/handlers/hide.ts index b2a1fb3..20a7cb3 100644 --- a/src/app/mocks/handlers/hide.ts +++ b/src/app/mocks/handlers/hide.ts @@ -5,7 +5,7 @@ import { ICancelHideResDTO, IHideFeedParamsDTO, IHideFeedResDTO, -} from '@/entities/hide'; +} from '@/features/hideFeed'; import { feedMockData } from '../data'; import { createHttpErrorResponse, createHttpSuccessResponse } from '../lib'; diff --git a/src/entities/hide/index.ts b/src/features/hideFeed/index.ts similarity index 100% rename from src/entities/hide/index.ts rename to src/features/hideFeed/index.ts diff --git a/src/entities/hide/model/hide.type.ts b/src/features/hideFeed/model/hide.type.ts similarity index 100% rename from src/entities/hide/model/hide.type.ts rename to src/features/hideFeed/model/hide.type.ts diff --git a/src/entities/hide/model/index.ts b/src/features/hideFeed/model/index.ts similarity index 100% rename from src/entities/hide/model/index.ts rename to src/features/hideFeed/model/index.ts From 6669f212de96b847e83c9ee8f7a18aa8e210dce2 Mon Sep 17 00:00:00 2001 From: suhwan2004 Date: Sun, 17 Nov 2024 23:40:30 +0900 Subject: [PATCH 11/12] =?UTF-8?q?feat:=20=EA=B8=B0=EC=A1=B4=20entities?= =?UTF-8?q?=EC=9D=98=20search=EB=A5=BC=20features=EC=9D=98=20searchFeed,?= =?UTF-8?q?=20searchUser=EB=A1=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/mocks/handlers/search.ts | 3 ++- src/entities/feed/model/common.type.ts | 4 ++-- src/entities/search/model/index.ts | 1 - src/entities/user/model/{type.ts => common.type.ts} | 0 src/entities/user/model/index.ts | 2 +- src/entities/user/model/types.ts | 5 ----- src/features/.gitkeep | 0 src/{entities/search => features/searchFeed}/index.ts | 0 src/features/searchFeed/model/index.ts | 1 + src/features/searchFeed/model/types.ts | 6 ++++++ src/features/searchUser/index.ts | 1 + src/features/searchUser/model/index.ts | 1 + .../search.type.ts => features/searchUser/model/types.ts} | 6 ------ src/shared/types/{image.ts => image.type.ts} | 0 src/shared/types/index.ts | 4 ++-- src/shared/types/{search.ts => search.type.ts} | 0 16 files changed, 16 insertions(+), 18 deletions(-) delete mode 100644 src/entities/search/model/index.ts rename src/entities/user/model/{type.ts => common.type.ts} (100%) delete mode 100644 src/entities/user/model/types.ts delete mode 100644 src/features/.gitkeep rename src/{entities/search => features/searchFeed}/index.ts (100%) create mode 100644 src/features/searchFeed/model/index.ts create mode 100644 src/features/searchFeed/model/types.ts create mode 100644 src/features/searchUser/index.ts create mode 100644 src/features/searchUser/model/index.ts rename src/{entities/search/model/search.type.ts => features/searchUser/model/types.ts} (58%) rename src/shared/types/{image.ts => image.type.ts} (100%) rename src/shared/types/{search.ts => search.type.ts} (100%) diff --git a/src/app/mocks/handlers/search.ts b/src/app/mocks/handlers/search.ts index 057fddf..0384192 100644 --- a/src/app/mocks/handlers/search.ts +++ b/src/app/mocks/handlers/search.ts @@ -1,7 +1,8 @@ import Fuse from 'fuse.js'; import { http } from 'msw'; -import { ISearchFeedResDTO, ISearchUserResDTO } from '@/entities/search'; +import { ISearchFeedResDTO } from '@/features/searchFeed'; +import { ISearchUserResDTO } from '@/features/searchUser'; import { feedMockData, userMockData } from '../data'; import { createHttpErrorResponse, createHttpSuccessResponse } from '../lib'; diff --git a/src/entities/feed/model/common.type.ts b/src/entities/feed/model/common.type.ts index bad4eab..1fc3163 100644 --- a/src/entities/feed/model/common.type.ts +++ b/src/entities/feed/model/common.type.ts @@ -1,5 +1,5 @@ -import { IUser } from '@/entities/user/model/type'; -import { IImage } from '@/shared/types/image'; +import { IUser } from '@/entities/user'; +import { IImage } from '@/shared/types'; export interface IFeed { id: number; diff --git a/src/entities/search/model/index.ts b/src/entities/search/model/index.ts deleted file mode 100644 index 0b3519c..0000000 --- a/src/entities/search/model/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './search.type'; diff --git a/src/entities/user/model/type.ts b/src/entities/user/model/common.type.ts similarity index 100% rename from src/entities/user/model/type.ts rename to src/entities/user/model/common.type.ts diff --git a/src/entities/user/model/index.ts b/src/entities/user/model/index.ts index fcb073f..7fb28e9 100644 --- a/src/entities/user/model/index.ts +++ b/src/entities/user/model/index.ts @@ -1 +1 @@ -export * from './types'; +export * from './common.type'; diff --git a/src/entities/user/model/types.ts b/src/entities/user/model/types.ts deleted file mode 100644 index 0eea308..0000000 --- a/src/entities/user/model/types.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface IUser { - id: number; - profileImage: string; - username: string; -} diff --git a/src/features/.gitkeep b/src/features/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/src/entities/search/index.ts b/src/features/searchFeed/index.ts similarity index 100% rename from src/entities/search/index.ts rename to src/features/searchFeed/index.ts diff --git a/src/features/searchFeed/model/index.ts b/src/features/searchFeed/model/index.ts new file mode 100644 index 0000000..fcb073f --- /dev/null +++ b/src/features/searchFeed/model/index.ts @@ -0,0 +1 @@ +export * from './types'; diff --git a/src/features/searchFeed/model/types.ts b/src/features/searchFeed/model/types.ts new file mode 100644 index 0000000..d46fe03 --- /dev/null +++ b/src/features/searchFeed/model/types.ts @@ -0,0 +1,6 @@ +import { IFeed } from '@/entities/feed'; +import { ICommonSearchData } from '@/shared/types'; +//피드 검색 +export interface ISearchFeedResDTO { + feed: ICommonSearchData; +} diff --git a/src/features/searchUser/index.ts b/src/features/searchUser/index.ts new file mode 100644 index 0000000..9f8ccad --- /dev/null +++ b/src/features/searchUser/index.ts @@ -0,0 +1 @@ +export * from './model'; diff --git a/src/features/searchUser/model/index.ts b/src/features/searchUser/model/index.ts new file mode 100644 index 0000000..fcb073f --- /dev/null +++ b/src/features/searchUser/model/index.ts @@ -0,0 +1 @@ +export * from './types'; diff --git a/src/entities/search/model/search.type.ts b/src/features/searchUser/model/types.ts similarity index 58% rename from src/entities/search/model/search.type.ts rename to src/features/searchUser/model/types.ts index 489452e..48861f3 100644 --- a/src/entities/search/model/search.type.ts +++ b/src/features/searchUser/model/types.ts @@ -1,12 +1,6 @@ -import { IFeed } from '@/entities/feed'; import { IUser } from '@/entities/user'; import { ICommonSearchData } from '@/shared/types'; -//피드 검색 -export interface ISearchFeedResDTO { - feed: ICommonSearchData; -} - //유저 검색 export interface ISearchUserResDTO { user: ICommonSearchData; diff --git a/src/shared/types/image.ts b/src/shared/types/image.type.ts similarity index 100% rename from src/shared/types/image.ts rename to src/shared/types/image.type.ts diff --git a/src/shared/types/index.ts b/src/shared/types/index.ts index eead6ae..41f775f 100644 --- a/src/shared/types/index.ts +++ b/src/shared/types/index.ts @@ -1,2 +1,2 @@ -export * from './image'; -export * from './search'; +export * from './image.type'; +export * from './search.type'; diff --git a/src/shared/types/search.ts b/src/shared/types/search.type.ts similarity index 100% rename from src/shared/types/search.ts rename to src/shared/types/search.type.ts From 86ff9bd2aca306555790b58729f750e8bbe1031f Mon Sep 17 00:00:00 2001 From: suhwan2004 Date: Mon, 18 Nov 2024 00:21:03 +0900 Subject: [PATCH 12/12] =?UTF-8?q?feat:IScrollablePage=EB=A5=BC=20common.ty?= =?UTF-8?q?pe=EC=9C=BC=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/features/searchFeed/model/types.ts | 5 +++-- src/features/searchUser/model/types.ts | 4 ++-- src/shared/types/{search.type.ts => common.type.ts} | 2 +- src/shared/types/index.ts | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) rename src/shared/types/{search.type.ts => common.type.ts} (74%) diff --git a/src/features/searchFeed/model/types.ts b/src/features/searchFeed/model/types.ts index d46fe03..ff46f18 100644 --- a/src/features/searchFeed/model/types.ts +++ b/src/features/searchFeed/model/types.ts @@ -1,6 +1,7 @@ import { IFeed } from '@/entities/feed'; -import { ICommonSearchData } from '@/shared/types'; +import { IScrollablePage } from '@/shared/types'; + //피드 검색 export interface ISearchFeedResDTO { - feed: ICommonSearchData; + feed: IScrollablePage; } diff --git a/src/features/searchUser/model/types.ts b/src/features/searchUser/model/types.ts index 48861f3..e17bc6f 100644 --- a/src/features/searchUser/model/types.ts +++ b/src/features/searchUser/model/types.ts @@ -1,7 +1,7 @@ import { IUser } from '@/entities/user'; -import { ICommonSearchData } from '@/shared/types'; +import { IScrollablePage } from '@/shared/types'; //유저 검색 export interface ISearchUserResDTO { - user: ICommonSearchData; + user: IScrollablePage; } diff --git a/src/shared/types/search.type.ts b/src/shared/types/common.type.ts similarity index 74% rename from src/shared/types/search.type.ts rename to src/shared/types/common.type.ts index 12dfa4a..5ad8aff 100644 --- a/src/shared/types/search.type.ts +++ b/src/shared/types/common.type.ts @@ -1,4 +1,4 @@ -export interface ICommonSearchData { +export interface IScrollablePage { contents: T; currentPageNumber: number; pageSize: number; diff --git a/src/shared/types/index.ts b/src/shared/types/index.ts index 41f775f..79bb4c5 100644 --- a/src/shared/types/index.ts +++ b/src/shared/types/index.ts @@ -1,2 +1,2 @@ export * from './image.type'; -export * from './search.type'; +export * from './common.type';