diff --git a/src/common/swagger/user.json b/src/common/swagger/user.json index 4e9b817..9501bd9 100644 --- a/src/common/swagger/user.json +++ b/src/common/swagger/user.json @@ -755,6 +755,7 @@ "description":{"type":"string", "example":"테스트용 작가입니다."}, "profileImage":{"type": "string", "example":"https://example.com/artist1.png"}, "slot":{"type": "integer", "example":3}, + "followerCount":{"type":"integer", "example":3}, "reviews":{ "type":"array", "items":{ diff --git a/src/user/repository/user.repository.js b/src/user/repository/user.repository.js index 1c57d68..6360bcc 100644 --- a/src/user/repository/user.repository.js +++ b/src/user/repository/user.repository.js @@ -326,6 +326,11 @@ export const UserRepository = { orderBy: {createdAt:"desc"}, }); }, - + // artistId로 팔로워 조회하기 + async CountArtistFollower(artistId){ + return await prisma.follow.count({ + where:{artistId:artistId}, + }) + } }; diff --git a/src/user/service/user.service.js b/src/user/service/user.service.js index 258b652..9dcebf6 100644 --- a/src/user/service/user.service.js +++ b/src/user/service/user.service.js @@ -371,6 +371,8 @@ export const UserService = { async AccessArtistProfile(artistId, accountId, userId) { const profile = await UserRepository.AccessArtistProfile(artistId); + const followercount = await UserRepository.CountArtistFollower(artistId); + if(!profile) throw new ArtistNotFound(); @@ -441,6 +443,7 @@ export const UserService = { return { ...profile, + followerCount: followercount, reviews, commissions:commissionList, badges