From dbee44e13b2ef4e8122e2dd4b6de238f7b93ac21 Mon Sep 17 00:00:00 2001 From: taeyoung0524 Date: Sat, 2 Aug 2025 02:17:02 +0900 Subject: [PATCH 01/16] =?UTF-8?q?BUG=20:=20=EA=B5=AC=EA=B8=80=20=EC=86=8C?= =?UTF-8?q?=EC=85=9C=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EB=B2=84=EA=B7=B8=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/auth.config.js | 4 +++- src/user/user.routes.js | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/auth.config.js b/src/auth.config.js index 4297840..3722734 100644 --- a/src/auth.config.js +++ b/src/auth.config.js @@ -24,12 +24,14 @@ export const googleStrategy = new GoogleStrategy( const googleVerify = async (profile) => { + console.log(profile); + const user = await prisma.account.findFirst({ where: {oauthId : profile.id, provider:profile.provider}, include:{users:true}, }); - if (user !== null) { + if (user && user.users.length>0) { return { id: user.users[0].id, nickname: user.users[0].nickname, account_id : user.id.toString() }; } diff --git a/src/user/user.routes.js b/src/user/user.routes.js index 46c36ce..5d8ef32 100644 --- a/src/user/user.routes.js +++ b/src/user/user.routes.js @@ -30,6 +30,7 @@ router.get( passport.authenticate("google", { failureRedirect: "/oauth2/login/google", failureMessage: true, + session:false, }), (req, res) => { console.log("req.user", req.user); // BigInt 의심 필드 확인 From c2261000017c7862e1610076fa23f60892fe06cf Mon Sep 17 00:00:00 2001 From: taeyoung0524 Date: Sat, 2 Aug 2025 16:00:28 +0900 Subject: [PATCH 02/16] =?UTF-8?q?FEAT=20:=20seed.js=EC=97=90=20category,?= =?UTF-8?q?=20agreement=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- prisma/seed.js | 73 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 70 insertions(+), 3 deletions(-) diff --git a/prisma/seed.js b/prisma/seed.js index d9c25d5..4961957 100644 --- a/prisma/seed.js +++ b/prisma/seed.js @@ -55,9 +55,76 @@ async function main() { }); // Category 생성 - const category = await prisma.category.create({ + const category1 = await prisma.category.create({ data: { - name: "캐릭터 일러스트", + name: "글", + }, + }); + // Category 생성 + const category2 = await prisma.category.create({ + data: { + name: "그림", + }, + }); + // Category 생성 + const category3 = await prisma.category.create({ + data: { + name: "영상", + }, + }); + // Category 생성 + const category4 = await prisma.category.create({ + data: { + name: "디자인", + }, + }); + // Category 생성 + const category5 = await prisma.category.create({ + data: { + name: "굿즈", + }, + }); + // Category 생성 + const category6 = await prisma.category.create({ + data: { + name: "점술", + }, + }); + // Category 생성 + const category7 = await prisma.category.create({ + data: { + name: "사운드", + }, + }); + // Category 생성 + const category8 = await prisma.category.create({ + data: { + name: "모션", + }, + }); + // Category 생성 + const category9 = await prisma.category.create({ + data: { + name: "외주", + }, + }); + + // Agreements 생성 + const agreement1 = await prisma.agreement.create({ + data: { + agreeType:"(필수) 서비스 이용약관" + }, + }); + // Agreements 생성 + const agreement2 = await prisma.agreement.create({ + data: { + agreeType:"(필수) 개인정보 수집/이용 동의" + }, + }); + // Agreements 생성 + const agreement3 = await prisma.agreement.create({ + data: { + agreeType:"(선택) 마케팅 수신 동의" }, }); @@ -65,7 +132,7 @@ async function main() { const commission = await prisma.commission.create({ data: { artistId: artist.id, - categoryId: category.id, + categoryId: 1, title: "테스트 커미션 글", summary: "이것은 테스트용 커미션 글입니다.", content: "테스트 커미션의 상세 설명입니다. 이 부분에는 커미션의 자세한 내용이 들어갑니다.", From 63f28d062ecb5a23db4e9464bb51e5d5775377e7 Mon Sep 17 00:00:00 2001 From: taeyoung0524 Date: Sat, 2 Aug 2025 17:25:51 +0900 Subject: [PATCH 03/16] =?UTF-8?q?BUG=20:=20=EC=B9=B4=EC=B9=B4=EC=98=A4=20?= =?UTF-8?q?=EC=86=8C=EC=85=9C=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/user/user.routes.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/user/user.routes.js b/src/user/user.routes.js index 5d8ef32..341bf9c 100644 --- a/src/user/user.routes.js +++ b/src/user/user.routes.js @@ -61,6 +61,7 @@ router.get( passport.authenticate("kakao", { failureRedirect: "/oauth2/login/kakao", failureMessage: true, + session:false, }), (req, res) => { console.log("req.user", req.user); // BigInt 의심 필드 확인 From 420d7fbc146556e151dd145207db70137c2b8ac3 Mon Sep 17 00:00:00 2001 From: taeyoung0524 Date: Sat, 2 Aug 2025 17:52:23 +0900 Subject: [PATCH 04/16] =?UTF-8?q?BUG=20:=20=EC=B9=B4=EC=B9=B4=EC=98=A4=20?= =?UTF-8?q?=EC=86=8C=EC=85=9C=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=20=EC=88=98=EC=A0=95:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/auth.config.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/auth.config.js b/src/auth.config.js index 3722734..5545bda 100644 --- a/src/auth.config.js +++ b/src/auth.config.js @@ -61,15 +61,23 @@ export const kakaoStrategy = new KakaoStrategy( const kakaoVerify = async (profile) => { + console.log(profile); + const user = await prisma.account.findFirst({ where: {oauthId : profile.id.toString(), provider:profile.provider}, - include:{users:true}, + include:{users:true, artists:true}, }); - if (user !== null) { + console.log(user); + + if (user && user.users.length>0) { return { id: user.users[0].id, nickname: user.users[0].nickname, account_id : user.id.toString() }; } + if(user && user.artists.length>0){ + return{id:user.artists[0].id, nickname:user.artists[0].nickname, account_id:user.id.toString()}; + } + // 사용자가 없으면 회원가입 페이지로 이동하도록 응답 // ex. 프론트에서 signupRequired : true를 응답받으면 회원가입 페이지로 이동 return { From 84435d05e64ad98da0b75804c6df0d64b1d0e01a Mon Sep 17 00:00:00 2001 From: taeyoung0524 Date: Sat, 2 Aug 2025 19:49:28 +0900 Subject: [PATCH 05/16] =?UTF-8?q?BUG=20:=20=EA=B5=AC=EA=B8=80=20=EC=86=8C?= =?UTF-8?q?=EC=85=9C=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EB=B2=84=EA=B7=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20250802104722_init/migration.sql | 38 +++++++++++++++++++ prisma/schema.prisma | 20 +++++----- prisma/seed.js | 1 + src/auth.config.js | 8 +++- src/user/repository/user.repository.js | 21 +++++----- 5 files changed, 65 insertions(+), 23 deletions(-) create mode 100644 prisma/migrations/20250802104722_init/migration.sql diff --git a/prisma/migrations/20250802104722_init/migration.sql b/prisma/migrations/20250802104722_init/migration.sql new file mode 100644 index 0000000..1eb4257 --- /dev/null +++ b/prisma/migrations/20250802104722_init/migration.sql @@ -0,0 +1,38 @@ +/* + Warnings: + + - You are about to drop the column `user_id` on the `user_agreement` table. All the data in the column will be lost. + - The primary key for the `user_categories` table will be changed. If it partially fails, the table could be left without primary key constraint. + - You are about to drop the column `user_id` on the `user_categories` table. All the data in the column will be lost. + - A unique constraint covering the columns `[account_id,agreement_id]` on the table `user_agreement` will be added. If there are existing duplicate values, this will fail. + - Added the required column `account_id` to the `user_agreement` table without a default value. This is not possible if the table is not empty. + - Added the required column `account_id` to the `user_categories` table without a default value. This is not possible if the table is not empty. + +*/ +-- DropForeignKey +ALTER TABLE `user_agreement` DROP FOREIGN KEY `user_agreement_user_id_fkey`; + +-- DropForeignKey +ALTER TABLE `user_categories` DROP FOREIGN KEY `user_categories_user_id_fkey`; + +-- DropIndex +DROP INDEX `user_agreement_user_id_agreement_id_key` ON `user_agreement`; + +-- AlterTable +ALTER TABLE `user_agreement` DROP COLUMN `user_id`, + ADD COLUMN `account_id` BIGINT NOT NULL; + +-- AlterTable +ALTER TABLE `user_categories` DROP PRIMARY KEY, + DROP COLUMN `user_id`, + ADD COLUMN `account_id` BIGINT NOT NULL, + ADD PRIMARY KEY (`account_id`, `category_id`); + +-- CreateIndex +CREATE UNIQUE INDEX `user_agreement_account_id_agreement_id_key` ON `user_agreement`(`account_id`, `agreement_id`); + +-- AddForeignKey +ALTER TABLE `user_categories` ADD CONSTRAINT `user_categories_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `user_agreement` ADD CONSTRAINT `user_agreement_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index e31adc1..ad82fb6 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -19,8 +19,10 @@ model Account { oauthId String @map("oauth_id") @db.VarChar(255) createdAt DateTime @default(now()) @map("created_at") - users User[] - artists Artist[] + users User[] + artists Artist[] + userAgreements UserAgreement[] + userCategories UserCategory[] @@unique([provider, oauthId]) @@map("accounts") @@ -46,8 +48,6 @@ model User { bookmarks Bookmark[] follows Follow[] notifications Notification[] - userAgreements UserAgreement[] - userCategories UserCategory[] searchHistories SearchHistory[] pushToken PushToken? @@ -83,13 +83,13 @@ model Category { } model UserCategory { - userId BigInt @map("user_id") + accountId BigInt @map("account_id") categoryId BigInt @map("category_id") - user User @relation(fields: [userId], references: [id]) + account Account @relation(fields: [accountId], references: [id]) category Category @relation(fields: [categoryId], references: [id]) - @@id([userId, categoryId]) + @@id([accountId, categoryId]) @@map("user_categories") } @@ -337,13 +337,13 @@ model Agreement { model UserAgreement { id BigInt @id @default(autoincrement()) - userId BigInt @map("user_id") + accountId BigInt @map("account_id") agreementId BigInt @map("agreement_id") - user User @relation(fields: [userId], references: [id]) + account Account @relation(fields: [accountId], references: [id]) agreement Agreement @relation(fields: [agreementId], references: [id]) - @@unique([userId, agreementId]) + @@unique([accountId, agreementId]) @@map("user_agreement") } diff --git a/prisma/seed.js b/prisma/seed.js index 4961957..8371dfa 100644 --- a/prisma/seed.js +++ b/prisma/seed.js @@ -137,6 +137,7 @@ async function main() { summary: "이것은 테스트용 커미션 글입니다.", content: "테스트 커미션의 상세 설명입니다. 이 부분에는 커미션의 자세한 내용이 들어갑니다.", minPrice: 1000, + formSchema: {}, }, }); diff --git a/src/auth.config.js b/src/auth.config.js index 5545bda..0fd8405 100644 --- a/src/auth.config.js +++ b/src/auth.config.js @@ -28,11 +28,15 @@ const googleVerify = async (profile) => { const user = await prisma.account.findFirst({ where: {oauthId : profile.id, provider:profile.provider}, - include:{users:true}, + include:{users:true, artists:true}, }); if (user && user.users.length>0) { - return { id: user.users[0].id, nickname: user.users[0].nickname, account_id : user.id.toString() }; + return { id: user.users[0].id, nickname: user.users[0].nickname, accountId : user.id.toString() }; + } + + if(user && user.artists.length>0){ + return{id:user.artists[0].id, nickname:user.artists[0].nickname, accountId:user.id.toString()}; } // 사용자가 없으면 회원가입 페이지로 이동하도록 응답 diff --git a/src/user/repository/user.repository.js b/src/user/repository/user.repository.js index 02395f0..bef1549 100644 --- a/src/user/repository/user.repository.js +++ b/src/user/repository/user.repository.js @@ -86,9 +86,9 @@ export const UserRepository = { /** * 사용자 카테고리 연결 생성 */ - async createUserCategories (userId, categoryIds) { + async createUserCategories (accountId, categoryIds) { const data = categoryIds.map(categoryId => ({ - userId, + accountId, categoryId, })); return await prisma.userCategory.createMany({ @@ -98,9 +98,9 @@ export const UserRepository = { /** * 사용자 약관 동의 생성 */ - async createUserAgreements (userId, agreementIds) { + async createUserAgreements (accountId, agreementIds) { const data = agreementIds.map(agreementId => ({ - userId, + accountId, agreementId, })); return await prisma.userAgreement.createMany({ @@ -110,17 +110,16 @@ export const UserRepository = { /** * 나의 프로필 조회 */ - async getMyProfile(userId) { - return await prisma.user.findUnique({ + async getMyProfile(accountId) { + return await prisma.account.findUnique({ where:{ - id:userId + id }, select:{ - nickname:true, - description:true, - profileImage: true, + users: { select: { id: true, nickname: true, description: true, profileImage: true } }, + artists:{ select: { id: true, nickname: true, description: true, profileImage: true } }, } - }) + }); }, /** From 8de198f0d8c07d3941d499b8008df785598773ab Mon Sep 17 00:00:00 2001 From: taeyoung0524 Date: Sat, 2 Aug 2025 21:45:00 +0900 Subject: [PATCH 06/16] =?UTF-8?q?FIX=20:=20=EC=82=AC=EC=9A=A9=EC=9E=90=20?= =?UTF-8?q?=ED=94=84=EB=A1=9C=ED=95=84=20=EC=A1=B0=ED=9A=8C=20role=20?= =?UTF-8?q?=EA=B5=AC=EB=B6=84=EC=9C=BC=EB=A1=9C=20=EC=BD=94=EB=93=9C=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/auth.config.js | 8 +++-- src/user/controller/user.controller.js | 9 ++++-- src/user/repository/user.repository.js | 22 +++++++------- src/user/service/user.service.js | 41 +++++++++++++++++++------- src/user/user.routes.js | 7 +++-- 5 files changed, 57 insertions(+), 30 deletions(-) diff --git a/src/auth.config.js b/src/auth.config.js index 0fd8405..83cf842 100644 --- a/src/auth.config.js +++ b/src/auth.config.js @@ -24,19 +24,21 @@ export const googleStrategy = new GoogleStrategy( const googleVerify = async (profile) => { - console.log(profile); + console.log("profile -> ",profile); const user = await prisma.account.findFirst({ where: {oauthId : profile.id, provider:profile.provider}, include:{users:true, artists:true}, }); + console.log("user -> ", user); + if (user && user.users.length>0) { - return { id: user.users[0].id, nickname: user.users[0].nickname, accountId : user.id.toString() }; + return { id: user.users[0].id, nickname: user.users[0].nickname, accountId : user.id.toString(), role:'client', provider: user.provider, oauthId:user.oauthId }; } if(user && user.artists.length>0){ - return{id:user.artists[0].id, nickname:user.artists[0].nickname, accountId:user.id.toString()}; + return{id:user.artists[0].id, nickname:user.artists[0].nickname, accountId:user.id.toString(), role:'artist', provider:user.provider, oauthId: user.oauthId}; } // 사용자가 없으면 회원가입 페이지로 이동하도록 응답 diff --git a/src/user/controller/user.controller.js b/src/user/controller/user.controller.js index 3d579e7..5416abd 100644 --- a/src/user/controller/user.controller.js +++ b/src/user/controller/user.controller.js @@ -45,10 +45,13 @@ export const getUserProfile = async(req, res, next) => { try{ console.log("Decoded JWT from req.user:", req.user); - const userId = req.user.userId.toString(); - console.log(userId); + const accountId = req.user.accountId.toString(); + console.log("controller accountId -> ", accountId); + + const role = req.user.role; + console.log(role); - const result = await UserService.getUserProfile(userId); + const result = await UserService.getUserProfile(accountId, role); res.status(StatusCodes.OK).success(result); } catch(err){ diff --git a/src/user/repository/user.repository.js b/src/user/repository/user.repository.js index bef1549..df75a92 100644 --- a/src/user/repository/user.repository.js +++ b/src/user/repository/user.repository.js @@ -4,13 +4,13 @@ export const UserRepository = { /** * 사용자 ID로 사용자 조회 */ - async findUserById(userId) { - return await prisma.user.findUnique({ + async findUserById(accountId) { + return await prisma.account.findUnique({ where: { - id: userId, + id: accountId }, - include : { - account:true, + select:{ + users: { select: { id: true, nickname: true, description: true, profileImage: true } } } }); }, @@ -18,13 +18,13 @@ export const UserRepository = { /** * 작가 ID로 작가 조회 */ - async findArtistById(artistId) { - return await prisma.artist.findUnique({ + async findArtistById(accountId) { + return await prisma.account.findUnique({ where: { - id: artistId, + id: accountId, }, - include : { - account:true, + select:{ + artists:{ select: { id: true, nickname: true, description: true, profileImage: true } } } }); }, @@ -113,7 +113,7 @@ export const UserRepository = { async getMyProfile(accountId) { return await prisma.account.findUnique({ where:{ - id + id:accountId }, select:{ users: { select: { id: true, nickname: true, description: true, profileImage: true } }, diff --git a/src/user/service/user.service.js b/src/user/service/user.service.js index b75f235..27e0bd8 100644 --- a/src/user/service/user.service.js +++ b/src/user/service/user.service.js @@ -105,16 +105,37 @@ export const UserService = { } }, // 사용자 프로필 조회 - async getUserProfile(userId) { - const user = await UserRepository.findUserById(userId); - if(!user) return null; - return { - message:"나의 프로필 조회에 성공하였습니다.", - user:{ - userId: user.id.toString(), - nickname: user.nickname, - profileImage:user.profileImage, - description: user.description + async getUserProfile(accountId, role) { + + let result; + + if(role === 'client') { + result = await UserRepository.findUserById(accountId); + console.log(result); + const user = result.users[0]; + return { + message:"나의 프로필 조회에 성공하였습니다.", + user:{ + userId: user.id, + nickname: user.nickname, + profileImage:user.profileImage, + description: user.description + } + } + } + + if(role === 'artist') { + result = await UserRepository.findArtistById(accountId); + console.log(result); + const artist = result.artists[0]; + return { + message:"나의 프로필 조회에 성공하였습니다.", + user:{ + artistId: artist.id, + nickname: artist.nickname, + profileImage:artist.profileImage, + description: artist.description + } } } }, diff --git a/src/user/user.routes.js b/src/user/user.routes.js index 341bf9c..100b15a 100644 --- a/src/user/user.routes.js +++ b/src/user/user.routes.js @@ -39,13 +39,14 @@ router.get( if(req.user.signupRequired){ token = signJwt({ - provider: req.user.provider.toString(), - oauth_id : req.user.oauth_id.toString(), + provider: req.user.provider, + oauth_id : req.user.oauth_id, }); return res.redirect(`/signup?token=${token}`); } token = signJwt({ - userId: req.user.id?.toString(), + accountId: req.user.accountId, + role:req.user.role, }); res.redirect(`/?token=${token}`) From 2865871da595d0fa53c85e092e90e67688b12a6e Mon Sep 17 00:00:00 2001 From: taeyoung0524 Date: Sat, 2 Aug 2025 22:51:43 +0900 Subject: [PATCH 07/16] =?UTF-8?q?FIX=20:=20=EC=82=AC=EC=9A=A9=EC=9E=90?= =?UTF-8?q?=EA=B0=80=20=EC=84=A0=ED=83=9D=ED=95=9C=20=EC=B9=B4=ED=85=8C?= =?UTF-8?q?=EA=B3=A0=EB=A6=AC=20=EC=A1=B0=ED=9A=8C=20=EB=B2=84=EA=B7=B8=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/user/controller/user.controller.js | 6 +++--- src/user/repository/user.repository.js | 16 +++++++++------- src/user/service/user.service.js | 15 ++++++++++----- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/user/controller/user.controller.js b/src/user/controller/user.controller.js index 5416abd..bafaa43 100644 --- a/src/user/controller/user.controller.js +++ b/src/user/controller/user.controller.js @@ -81,10 +81,10 @@ export const AccessUserCategories = async(req, res, next) => { try{ console.log("Decoded JWT from req.user:", req.user); - const userId = req.user.userId.toString(); - console.log("userId : ", userId); + const accountId = req.user.accountId.toString(); + console.log("사용자가 선택한 카테고리 조회 accountId -> ", accountId); - const result = await UserService.accessUserCategories(userId); + const result = await UserService.accessUserCategories(accountId); res.status(StatusCodes.OK).success(result); } catch(err) { next(err); diff --git a/src/user/repository/user.repository.js b/src/user/repository/user.repository.js index df75a92..cce7d4b 100644 --- a/src/user/repository/user.repository.js +++ b/src/user/repository/user.repository.js @@ -132,13 +132,15 @@ export const UserRepository = { }) }, // 사용자가 선택한 카테고리 조회 - async AccessUserCategories(userId){ - return await prisma.user.findUnique({ - where :{id:userId}, - include:{ - userCategories:{ - include:{ - category:true, + async AccessUserCategories(accountId){ + return await prisma.userCategory.findMany({ + where :{ + accountId + }, + select:{ + category:{ + select:{ + name:true } } } diff --git a/src/user/service/user.service.js b/src/user/service/user.service.js index 27e0bd8..a7b3cf8 100644 --- a/src/user/service/user.service.js +++ b/src/user/service/user.service.js @@ -36,6 +36,8 @@ export const UserService = { // 3. 사용자 프로필 생성 profile = await UserRepository.createUserProfile(account.id, nickname, "."); + console.log("user profile -> ", profile); + // 4. 사용자 약관 동의 처리 (agreements -> 사용자가 동의한 agreement id 배열) await UserRepository.createUserAgreements(profile.id, agreements); @@ -46,11 +48,13 @@ export const UserService = { // 3. 사용자 프로필 생성 profile = await UserRepository.createArtistProfile(account.id, nickname, "."); + console.log("artist profile -> ", profile); + // 4. 사용자 약관 동의 처리 (agreements -> 사용자가 동의한 agreement id 배열) - await UserRepository.createUserAgreements(profile.id, agreements); + await UserRepository.createUserAgreements(profile.accountId, agreements); // 5. 사용자가 선한 카테고리 처리 (categories -> 사용자가 선택한 category id 배열 ) - await UserRepository.createUserCategories(profile.id, categories); + await UserRepository.createUserCategories(profile.accountId, categories); } else { throw new UserRoleError(); @@ -176,11 +180,12 @@ export const UserService = { }, // 사용자가 선택한 카테고리 조회 - async accessUserCategories(userId) { - const user = await UserRepository.AccessUserCategories(userId); + async accessUserCategories(accountId) { + const user = await UserRepository.AccessUserCategories(accountId); + console.log(user); if(!user) return null; - const categoryName = user.userCategories.map(uc => uc.category.name); + const categoryName = user.map(item => item.category.name); return { message:"사용자가 선택한 카테고리 조회에 성공했습니다.", From d4dc839d1e4b3917f640cc04e0ebf69544d9d431 Mon Sep 17 00:00:00 2001 From: taeyoung0524 Date: Sat, 2 Aug 2025 23:29:29 +0900 Subject: [PATCH 08/16] =?UTF-8?q?FIX=20:=20addAccount=20profile=20?= =?UTF-8?q?=EB=B6=80=EB=B6=84=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/user/service/user.service.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/user/service/user.service.js b/src/user/service/user.service.js index a7b3cf8..b0afb3c 100644 --- a/src/user/service/user.service.js +++ b/src/user/service/user.service.js @@ -39,10 +39,10 @@ export const UserService = { console.log("user profile -> ", profile); // 4. 사용자 약관 동의 처리 (agreements -> 사용자가 동의한 agreement id 배열) - await UserRepository.createUserAgreements(profile.id, agreements); + await UserRepository.createUserAgreements(profile.accountId, agreements); // 5. 사용자가 선한 카테고리 처리 (categories -> 사용자가 선택한 category id 배열 ) - await UserRepository.createUserCategories(profile.id, categories); + await UserRepository.createUserCategories(profile.accountId, categories); } else if (role === "artist") { // 3. 사용자 프로필 생성 From 936b435971de46b57e07c95d620c5e18614051cd Mon Sep 17 00:00:00 2001 From: taeyoung0524 Date: Sun, 3 Aug 2025 00:05:21 +0900 Subject: [PATCH 09/16] =?UTF-8?q?FIX=20:=20user,=20artist=20=ED=85=8C?= =?UTF-8?q?=EC=9D=B4=EB=B8=94=EC=97=90=EC=84=9C=20accountId=20unique=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migration.sql | 12 ++++++ prisma/schema.prisma | 4 +- src/user/controller/user.controller.js | 9 +++-- src/user/repository/user.repository.js | 13 ++++++- src/user/service/user.service.js | 38 ++++++++++++++++--- 5 files changed, 63 insertions(+), 13 deletions(-) create mode 100644 prisma/migrations/20250802150431_account_id_unique/migration.sql diff --git a/prisma/migrations/20250802150431_account_id_unique/migration.sql b/prisma/migrations/20250802150431_account_id_unique/migration.sql new file mode 100644 index 0000000..bba1ce6 --- /dev/null +++ b/prisma/migrations/20250802150431_account_id_unique/migration.sql @@ -0,0 +1,12 @@ +/* + Warnings: + + - A unique constraint covering the columns `[account_id]` on the table `artists` will be added. If there are existing duplicate values, this will fail. + - A unique constraint covering the columns `[account_id]` on the table `users` will be added. If there are existing duplicate values, this will fail. + +*/ +-- CreateIndex +CREATE UNIQUE INDEX `artists_account_id_key` ON `artists`(`account_id`); + +-- CreateIndex +CREATE UNIQUE INDEX `users_account_id_key` ON `users`(`account_id`); diff --git a/prisma/schema.prisma b/prisma/schema.prisma index ad82fb6..5db48f5 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -31,7 +31,7 @@ model Account { model User { id BigInt @id @default(autoincrement()) nickname String @db.VarChar(50) - accountId BigInt @map("account_id") + accountId BigInt @map("account_id") @unique description String? @db.VarChar(1000) profileImage String? @map("profile_image") @db.VarChar(255) createdAt DateTime @default(now()) @map("created_at") @@ -56,7 +56,7 @@ model User { model Artist { id BigInt @id @default(autoincrement()) - accountId BigInt @map("account_id") + accountId BigInt @map("account_id") @unique nickname String @db.VarChar(50) profileImage String? @map("profile_image") @db.VarChar(255) description String? @db.VarChar(1000) diff --git a/src/user/controller/user.controller.js b/src/user/controller/user.controller.js index bafaa43..349b1c4 100644 --- a/src/user/controller/user.controller.js +++ b/src/user/controller/user.controller.js @@ -64,12 +64,15 @@ export const UpdateMyprofile = async(req, res, next) => { try{ console.log("Decoded JWT from req.user:", req.user); - const userId = req.user.userId.toString(); - console.log("userId : ", userId); + const accountId = req.user.accountId; + console.log("accountId -> : ", accountId); + + const role = req.user.role; const dto = new UpdateMyprofileDto(req.body); - const result = await UserService.updateMyprofile(userId, dto); + const result = await UserService.updateMyprofile(accountId, dto, role); + res.status(StatusCodes.OK).success(result); } catch(err){ next(err); diff --git a/src/user/repository/user.repository.js b/src/user/repository/user.repository.js index cce7d4b..5ff5681 100644 --- a/src/user/repository/user.repository.js +++ b/src/user/repository/user.repository.js @@ -125,9 +125,18 @@ export const UserRepository = { /** * 나의 프로필 수정 */ - async updateMyprofile(userId, updates) { + async updateMyprofile(accountId, updates) { return await prisma.user.update({ - where:{id: userId}, + where:{accountId}, + data:updates, + }) + }, + /** + * 작가 프로필 수정 + */ + async updateArtistProfile(accountId, updates) { + return await prisma.artist.update({ + where:{accountId}, data:updates, }) }, diff --git a/src/user/service/user.service.js b/src/user/service/user.service.js index b0afb3c..eaf7ecb 100644 --- a/src/user/service/user.service.js +++ b/src/user/service/user.service.js @@ -144,8 +144,16 @@ export const UserService = { } }, // 나의 프로필 수정 - async updateMyprofile(userId, dto) { - const user = await UserRepository.findUserById(userId); + async updateMyprofile(accountId, dto, role) { + let user; + if(role === "client") { + user = await UserRepository.findUserById(accountId); + } + + if(role === "artist") { + user = await UserRepository.findArtistById(accountId); + } + if(!user) return null; const updates = {}; @@ -166,17 +174,35 @@ export const UserService = { }; } - const updatedUser = await UserRepository.updateMyprofile(userId, updates); + let updatedUser; - return { + if(role === "client"){ + updatedUser = await UserRepository.updateMyprofile(accountId, updates); + + return { message:"프로필 수정이 완료되었습니다.", user:{ userId: updatedUser.id.toString(), nickname: updatedUser.nickname, profileImage: updatedUser.profileImage, description: updatedUser.description, - } - }; + } + }; + } + + if(role === "artist"){ + updatedUser = await UserRepository.updateArtistProfile(accountId, updates); + + return { + message:"프로필 수정이 완료되었습니다.", + user:{ + userId: updatedUser.id.toString(), + nickname: updatedUser.nickname, + profileImage: updatedUser.profileImage, + description: updatedUser.description, + } + }; + } }, // 사용자가 선택한 카테고리 조회 From d1493a24ac9c6f655aaabfdfe27ced2b0718f3d1 Mon Sep 17 00:00:00 2001 From: taeyoung0524 Date: Sun, 3 Aug 2025 00:34:56 +0900 Subject: [PATCH 10/16] =?UTF-8?q?BUG=20:=20=EC=B9=B4=EC=B9=B4=EC=98=A4=20?= =?UTF-8?q?=EC=86=8C=EC=85=9C=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/auth.config.js | 4 ++-- src/user/controller/user.controller.js | 4 ++-- src/user/user.routes.js | 7 ++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/auth.config.js b/src/auth.config.js index 83cf842..abcfee6 100644 --- a/src/auth.config.js +++ b/src/auth.config.js @@ -77,11 +77,11 @@ const kakaoVerify = async (profile) => { console.log(user); if (user && user.users.length>0) { - return { id: user.users[0].id, nickname: user.users[0].nickname, account_id : user.id.toString() }; + return { id: user.users[0].id, nickname: user.users[0].nickname, accountId : user.id.toString(), role:'client', provider: user.provider, oauthId:user.oauthId }; } if(user && user.artists.length>0){ - return{id:user.artists[0].id, nickname:user.artists[0].nickname, account_id:user.id.toString()}; + return{id:user.artists[0].id, nickname:user.artists[0].nickname, accountId:user.id.toString(), role:'artist', provider: user.provider, oauthId:user.oauthId}; } // 사용자가 없으면 회원가입 페이지로 이동하도록 응답 diff --git a/src/user/controller/user.controller.js b/src/user/controller/user.controller.js index 349b1c4..4e4e8fe 100644 --- a/src/user/controller/user.controller.js +++ b/src/user/controller/user.controller.js @@ -43,9 +43,9 @@ export const addUser = async(req, res, next) => { // 사용자 프로필 조회 export const getUserProfile = async(req, res, next) => { try{ - console.log("Decoded JWT from req.user:", req.user); + console.log("👊Decoded JWT from req.user:", req.user); - const accountId = req.user.accountId.toString(); + const accountId = req.user.accountId; console.log("controller accountId -> ", accountId); const role = req.user.role; diff --git a/src/user/user.routes.js b/src/user/user.routes.js index 100b15a..fe067ab 100644 --- a/src/user/user.routes.js +++ b/src/user/user.routes.js @@ -71,13 +71,14 @@ router.get( if(req.user.signupRequired){ token = signJwt({ - provider: req.user.provider.toString(), - oauth_id : req.user.oauth_id.toString(), + provider: req.user.provider, + oauth_id : req.user.oauth_id, }); return res.redirect(`/signup?token=${token}`); } token = signJwt({ - userId: req.user.id?.toString(), + accountId: req.user.accountId, + role:req.user.role, }); res.redirect(`/?token=${token}`) From 3a44629112699a0a3ae3b8831b0b790e7bcfd673 Mon Sep 17 00:00:00 2001 From: taeyoung0524 Date: Sun, 3 Aug 2025 01:58:12 +0900 Subject: [PATCH 11/16] =?UTF-8?q?BUG=20:=20=EB=84=A4=EC=9D=B4=EB=B2=84=20?= =?UTF-8?q?=EC=86=8C=EC=85=9C=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/auth.config.js | 14 ++++++++++---- src/user/user.routes.js | 4 +++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/auth.config.js b/src/auth.config.js index abcfee6..46053a2 100644 --- a/src/auth.config.js +++ b/src/auth.config.js @@ -110,14 +110,20 @@ export const naverStrategy = new NaverStrategy( ); const naverVerify = async (profile) => { - + const user = await prisma.account.findFirst({ where: {oauthId : profile.id.toString(), provider:profile.provider}, - include:{users:true}, + include:{users:true, artists:true}, }); - if (user !== null) { - return { id: user.users[0].id, nickname: user.users[0].nickname, account_id : user.id.toString() }; + console.log(user); + + if (user && user.users.length>0) { + return { id: user.users[0].id, nickname: user.users[0].nickname, accountId : user.id.toString(), role:'client', provider: user.provider, oauthId:user.oauthId }; + } + + if(user && user.artists.length>0){ + return{id:user.artists[0].id, nickname:user.artists[0].nickname, accountId:user.id.toString(), role:'artist', provider: user.provider, oauthId:user.oauthId}; } // 사용자가 없으면 회원가입 페이지로 이동하도록 응답 diff --git a/src/user/user.routes.js b/src/user/user.routes.js index fe067ab..1bbacb9 100644 --- a/src/user/user.routes.js +++ b/src/user/user.routes.js @@ -94,6 +94,7 @@ router.get( passport.authenticate("naver", { failureRedirect: "/oauth2/login/naver", failureMessage: true, + session:false, }), (req, res) => { console.log("req.user", req.user); // BigInt 의심 필드 확인 @@ -109,7 +110,8 @@ router.get( } token = signJwt({ - userId: req.user.id?.toString(), + accountId: req.user.accountId, + role:req.user.role, }); res.redirect(`/?token=${token}`) From b7465fc672735eac7f6b5d8c44985a6f8601a376 Mon Sep 17 00:00:00 2001 From: taeyoung0524 Date: Sun, 3 Aug 2025 02:15:09 +0900 Subject: [PATCH 12/16] =?UTF-8?q?FIX=20:=20Follow=20=ED=85=8C=EC=9D=B4?= =?UTF-8?q?=EB=B8=94=EC=97=90=20userId=20=EC=A0=9C=EA=B1=B0=20/=20accountI?= =?UTF-8?q?d=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migration.sql | 23 +++++++++++++++++++ prisma/schema.prisma | 10 ++++---- src/user/controller/user.controller.js | 8 +++---- src/user/repository/user.repository.js | 4 ++-- src/user/service/user.service.js | 4 ++-- 5 files changed, 36 insertions(+), 13 deletions(-) create mode 100644 prisma/migrations/20250802171420_follow_account_id_add/migration.sql diff --git a/prisma/migrations/20250802171420_follow_account_id_add/migration.sql b/prisma/migrations/20250802171420_follow_account_id_add/migration.sql new file mode 100644 index 0000000..e7883da --- /dev/null +++ b/prisma/migrations/20250802171420_follow_account_id_add/migration.sql @@ -0,0 +1,23 @@ +/* + Warnings: + + - You are about to drop the column `user_id` on the `follows` table. All the data in the column will be lost. + - A unique constraint covering the columns `[account_id,artist_id]` on the table `follows` will be added. If there are existing duplicate values, this will fail. + - Added the required column `account_id` to the `follows` table without a default value. This is not possible if the table is not empty. + +*/ +-- DropForeignKey +ALTER TABLE `follows` DROP FOREIGN KEY `follows_user_id_fkey`; + +-- DropIndex +DROP INDEX `follows_user_id_artist_id_key` ON `follows`; + +-- AlterTable +ALTER TABLE `follows` DROP COLUMN `user_id`, + ADD COLUMN `account_id` BIGINT NOT NULL; + +-- CreateIndex +CREATE UNIQUE INDEX `follows_account_id_artist_id_key` ON `follows`(`account_id`, `artist_id`); + +-- AddForeignKey +ALTER TABLE `follows` ADD CONSTRAINT `follows_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 5db48f5..099a519 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -23,6 +23,7 @@ model Account { artists Artist[] userAgreements UserAgreement[] userCategories UserCategory[] + follows Follow[] @@unique([provider, oauthId]) @@map("accounts") @@ -46,7 +47,6 @@ model User { chatMessages ChatMessage[] reviews Review[] bookmarks Bookmark[] - follows Follow[] notifications Notification[] searchHistories SearchHistory[] pushToken PushToken? @@ -241,13 +241,13 @@ model ChatMessage { model Follow { id BigInt @id @default(autoincrement()) artistId BigInt @map("artist_id") - userId BigInt @map("user_id") + accountId BigInt @map("account_id") createdAt DateTime @default(now()) @map("created_at") - artist Artist @relation(fields: [artistId], references: [id]) - user User @relation(fields: [userId], references: [id]) + artist Artist @relation(fields: [artistId], references: [id]) + account Account @relation(fields: [accountId], references: [id]) - @@unique([userId, artistId]) + @@unique([accountId, artistId]) @@map("follows") } diff --git a/src/user/controller/user.controller.js b/src/user/controller/user.controller.js index 4e4e8fe..dcca4b8 100644 --- a/src/user/controller/user.controller.js +++ b/src/user/controller/user.controller.js @@ -111,14 +111,14 @@ export const CheckUserNickname = async(req, res, next) => { // 작가 팔로우하기 export const FollowArtist = async(req, res, next) => { try{ - console.log("Decoded JWT from req.user:", req.user); + console.log("⭐Decoded JWT from req.user:", req.user); - const userId = req.user.userId.toString(); - console.log("userId : ", userId); + const accountId = req.user.accountId.toString(); + console.log("작가 팔로우하기 accountId : ", accountId); const artistId = req.params.artistId; - const result = await UserService.FollowArtist(userId, artistId); + const result = await UserService.FollowArtist(accountId, artistId); res.status(StatusCodes.CREATED).success(result); } catch(err) { diff --git a/src/user/repository/user.repository.js b/src/user/repository/user.repository.js index 5ff5681..ac5a1c6 100644 --- a/src/user/repository/user.repository.js +++ b/src/user/repository/user.repository.js @@ -173,9 +173,9 @@ export const UserRepository = { }, // 사용자가 팔로우중인지 확인 - async AlreadyFollow(userId, artistId) { + async AlreadyFollow(accountId, artistId) { return await prisma.follow.findFirst({ - where:{userId, artistId} + where:{accountId, artistId} }) }, diff --git a/src/user/service/user.service.js b/src/user/service/user.service.js index eaf7ecb..d0fa8c2 100644 --- a/src/user/service/user.service.js +++ b/src/user/service/user.service.js @@ -236,13 +236,13 @@ export const UserService = { }, // 작가 팔로우하기 - async FollowArtist(userId, artistId) { + async FollowArtist(accountId, artistId) { const artist = await UserRepository.findArtistById(artistId); if(!artist) throw new ArtistNotFound(); - const alreadyFollowing = await UserRepository.AlreadyFollow(userId, artistId); + const alreadyFollowing = await UserRepository.AlreadyFollow(accountId, artistId); if(alreadyFollowing) throw new UserAlreadyFollowArtist(); From 36499101f4e57662ad29a22e0afda03bb403bc59 Mon Sep 17 00:00:00 2001 From: taeyoung0524 Date: Sun, 3 Aug 2025 02:32:37 +0900 Subject: [PATCH 13/16] =?UTF-8?q?FIX=20:=20=EC=9E=91=EA=B0=80=20=ED=8C=94?= =?UTF-8?q?=EB=A1=9C=EC=9A=B0=ED=95=98=EA=B8=B0=20=EB=B2=84=EA=B7=B8=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/user/repository/user.repository.js | 4 ++-- src/user/service/user.service.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/user/repository/user.repository.js b/src/user/repository/user.repository.js index ac5a1c6..346b7c1 100644 --- a/src/user/repository/user.repository.js +++ b/src/user/repository/user.repository.js @@ -163,10 +163,10 @@ export const UserRepository = { }, // 작가 팔로우하기 - async FollowArtist(userId, artistId) { + async FollowArtist(accountId, artistId) { return await prisma.follow.create({ data:{ - userId, + accountId, artistId } }) diff --git a/src/user/service/user.service.js b/src/user/service/user.service.js index d0fa8c2..f3992be 100644 --- a/src/user/service/user.service.js +++ b/src/user/service/user.service.js @@ -247,7 +247,7 @@ export const UserService = { if(alreadyFollowing) throw new UserAlreadyFollowArtist(); - const result = await UserRepository.FollowArtist(userId, artistId); + const result = await UserRepository.FollowArtist(accountId, artistId); return { message:"해당 작가 팔로우를 성공했습니다.", From ae23570a48256cf8c7f187109644e4aad50339f7 Mon Sep 17 00:00:00 2001 From: taeyoung0524 Date: Sun, 3 Aug 2025 02:38:08 +0900 Subject: [PATCH 14/16] =?UTF-8?q?FIX=20:=20=ED=8C=94=EB=A1=9C=EC=9A=B0?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EC=9E=91=EA=B0=80=20=EB=AA=A9=EB=A1=9D=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/user/controller/user.controller.js | 16 ++++++++-------- src/user/repository/user.repository.js | 10 +++++----- src/user/service/user.service.js | 10 +++++----- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/user/controller/user.controller.js b/src/user/controller/user.controller.js index dcca4b8..c68639f 100644 --- a/src/user/controller/user.controller.js +++ b/src/user/controller/user.controller.js @@ -129,14 +129,14 @@ export const FollowArtist = async(req, res, next) => { // 작가 팔로우 취소하기 export const CancelArtistFollow = async(req, res, next) => { try{ - console.log("Decoded JWT from req.user:", req.user); + console.log("💟Decoded JWT from req.user:", req.user); - const userId = req.user.userId.toString(); - console.log("userId : ", userId); + const accountId = req.user.accountId.toString(); + console.log("작가 팔로우 취소하기 accountId : ", accountId); const artistId = req.params.artistId; - const result = await UserService.CancelArtistFollow(userId, artistId); + const result = await UserService.CancelArtistFollow(accountId, artistId); res.status(StatusCodes.OK).success(result); } catch(err) { @@ -147,12 +147,12 @@ export const CancelArtistFollow = async(req, res, next) => { // 사용자가 팔로우 한 작가 조회하기 export const LookUserFollow = async(req, res, next) => { try{ - console.log("Decoded JWT from req.user:", req.user); + console.log("🦁Decoded JWT from req.user:", req.user); - const userId = req.user.userId.toString(); - console.log("userId : ", userId); + const accountId = req.user.accountId.toString(); + console.log("팔로우하는 작가 목록 조회 accountId : ", accountId); - const result = await UserService.LookUserFollow(userId); + const result = await UserService.LookUserFollow(accountId); res.status(StatusCodes.OK).success(result); }catch(err) { diff --git a/src/user/repository/user.repository.js b/src/user/repository/user.repository.js index 346b7c1..e047899 100644 --- a/src/user/repository/user.repository.js +++ b/src/user/repository/user.repository.js @@ -180,11 +180,11 @@ export const UserRepository = { }, // 작가 팔로우 취소하기 - async CancelArtistFollow(userId, artistId) { + async CancelArtistFollow(accountId, artistId) { return await prisma.follow.delete({ where:{ - userId_artistId:{ - userId, + accountId_artistId:{ + accountId, artistId } } @@ -192,10 +192,10 @@ export const UserRepository = { }, // 사용자가 팔로우한 작가 조회하기 - async LookUserFollow(userId){ + async LookUserFollow(accountId){ return await prisma.follow.findMany({ where:{ - userId:userId + accountId:accountId }, select:{ artist:{ diff --git a/src/user/service/user.service.js b/src/user/service/user.service.js index f3992be..3c3ec6f 100644 --- a/src/user/service/user.service.js +++ b/src/user/service/user.service.js @@ -256,18 +256,18 @@ export const UserService = { }, // 작가 팔로우 취소하기 - async CancelArtistFollow(userId, artistId) { + async CancelArtistFollow(accountId, artistId) { const artist = await UserRepository.findArtistById(artistId); if(!artist) throw new ArtistNotFound(); - const FollowState = await UserRepository.AlreadyFollow(userId, artistId); + const FollowState = await UserRepository.AlreadyFollow(accountId, artistId); if(!FollowState) throw new NotFollowingArtist(); - const result = await UserRepository.CancelArtistFollow(userId, artistId); + const result = await UserRepository.CancelArtistFollow(accountId, artistId); return { message: "해당 작가 팔로우를 취소했습니다.", @@ -276,8 +276,8 @@ export const UserService = { }, // 사용자가 팔로우한 작가 조회하기 - async LookUserFollow(userId) { - const artistList = await UserRepository.LookUserFollow(userId); + async LookUserFollow(accountId) { + const artistList = await UserRepository.LookUserFollow(accountId); if(artistList.length === 0) return { message:"팔로우하는 작가가 없습니다.", From da612961a1402cbfc761ff7f23d63925979095c6 Mon Sep 17 00:00:00 2001 From: taeyoung0524 Date: Sun, 3 Aug 2025 21:11:47 +0900 Subject: [PATCH 15/16] =?UTF-8?q?BUG=20:=20=EC=B9=B4=EC=B9=B4=EC=98=A4=20?= =?UTF-8?q?=EC=86=8C=EC=85=9C=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B82=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/auth.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/auth.config.js b/src/auth.config.js index 46053a2..c11647c 100644 --- a/src/auth.config.js +++ b/src/auth.config.js @@ -89,7 +89,7 @@ const kakaoVerify = async (profile) => { return { signupRequired : true, provider : profile.provider, - oauth_id : profile.id, + oauth_id : profile.id.toString(), }; }; From b2af5a0aa303f0d024a5c2da40ed465ec297be24 Mon Sep 17 00:00:00 2001 From: taeyoung0524 Date: Sun, 3 Aug 2025 21:52:43 +0900 Subject: [PATCH 16/16] =?UTF-8?q?FIX=20:=20req.user=EC=97=90=20userId,=20a?= =?UTF-8?q?rtistId=20=EC=A0=84=EB=8B=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/auth.config.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/auth.config.js b/src/auth.config.js index c11647c..27e5cfe 100644 --- a/src/auth.config.js +++ b/src/auth.config.js @@ -34,11 +34,11 @@ const googleVerify = async (profile) => { console.log("user -> ", user); if (user && user.users.length>0) { - return { id: user.users[0].id, nickname: user.users[0].nickname, accountId : user.id.toString(), role:'client', provider: user.provider, oauthId:user.oauthId }; + return { id: user.users[0].id, nickname: user.users[0].nickname, accountId : user.id.toString(), userId: user.users[0].id.toString(), role:'client', provider: user.provider, oauthId:user.oauthId }; } if(user && user.artists.length>0){ - return{id:user.artists[0].id, nickname:user.artists[0].nickname, accountId:user.id.toString(), role:'artist', provider:user.provider, oauthId: user.oauthId}; + return{id:user.artists[0].id, nickname:user.artists[0].nickname, accountId:user.id.toString(), artistId: user.artists[0].id.toString(), role:'artist', provider:user.provider, oauthId: user.oauthId}; } // 사용자가 없으면 회원가입 페이지로 이동하도록 응답 @@ -77,11 +77,11 @@ const kakaoVerify = async (profile) => { console.log(user); if (user && user.users.length>0) { - return { id: user.users[0].id, nickname: user.users[0].nickname, accountId : user.id.toString(), role:'client', provider: user.provider, oauthId:user.oauthId }; + return { id: user.users[0].id, nickname: user.users[0].nickname, accountId : user.id.toString(), userId: user.users[0].id.toString(), role:'client', provider: user.provider, oauthId:user.oauthId }; } if(user && user.artists.length>0){ - return{id:user.artists[0].id, nickname:user.artists[0].nickname, accountId:user.id.toString(), role:'artist', provider: user.provider, oauthId:user.oauthId}; + return{id:user.artists[0].id, nickname:user.artists[0].nickname, accountId:user.id.toString(), artistId: user.artists[0].id.toString(), role:'artist', provider:user.provider, oauthId: user.oauthId}; } // 사용자가 없으면 회원가입 페이지로 이동하도록 응답 @@ -119,11 +119,11 @@ const naverVerify = async (profile) => { console.log(user); if (user && user.users.length>0) { - return { id: user.users[0].id, nickname: user.users[0].nickname, accountId : user.id.toString(), role:'client', provider: user.provider, oauthId:user.oauthId }; + return { id: user.users[0].id, nickname: user.users[0].nickname, accountId : user.id.toString(), userId: user.users[0].id.toString(), role:'client', provider: user.provider, oauthId:user.oauthId }; } if(user && user.artists.length>0){ - return{id:user.artists[0].id, nickname:user.artists[0].nickname, accountId:user.id.toString(), role:'artist', provider: user.provider, oauthId:user.oauthId}; + return{id:user.artists[0].id, nickname:user.artists[0].nickname, accountId:user.id.toString(), artistId: user.artists[0].id.toString(), role:'artist', provider:user.provider, oauthId: user.oauthId}; } // 사용자가 없으면 회원가입 페이지로 이동하도록 응답