Skip to content

Commit c2a2957

Browse files
authored
Merge pull request #182 from umc-commit/refactor/follower
[REFACTOR] Followercount 추가
2 parents bde6c74 + 33dc39e commit c2a2957

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/common/swagger/user.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,7 @@
755755
"description":{"type":"string", "example":"테스트용 작가입니다."},
756756
"profileImage":{"type": "string", "example":"https://example.com/artist1.png"},
757757
"slot":{"type": "integer", "example":3},
758+
"followerCount":{"type":"integer", "example":3},
758759
"reviews":{
759760
"type":"array",
760761
"items":{

src/user/repository/user.repository.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,11 @@ export const UserRepository = {
326326
orderBy: {createdAt:"desc"},
327327
});
328328
},
329-
329+
// artistId로 팔로워 조회하기
330+
async CountArtistFollower(artistId){
331+
return await prisma.follow.count({
332+
where:{artistId:artistId},
333+
})
334+
}
330335
};
331336

src/user/service/user.service.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,8 @@ export const UserService = {
371371
async AccessArtistProfile(artistId, accountId, userId) {
372372
const profile = await UserRepository.AccessArtistProfile(artistId);
373373

374+
const followercount = await UserRepository.CountArtistFollower(artistId);
375+
374376
if(!profile)
375377
throw new ArtistNotFound();
376378

@@ -441,6 +443,7 @@ export const UserService = {
441443

442444
return {
443445
...profile,
446+
followerCount: followercount,
444447
reviews,
445448
commissions:commissionList,
446449
badges

0 commit comments

Comments
 (0)