Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion src/common/swagger/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,41 @@
"userId":{"type":"string", "example":"7"},
"nickname":{"type":"string", "example":"탱"},
"profileImage":{"type": ["string", null], "example":null},
"description":{"type":"string", "example":"."}
"description":{"type":"string", "example":"."},
"badges":{
"type":"array",
"items":{
"properties":{
"id":{"type":"string", "example":"1"},
"earnedAt":{"type":"string", "example":"2025-08-10T05:16:02.000Z"},
"badge":{
"type":"array",
"items":{
"properties":{
"id":{"type":"string", "example":"1"},
"type":{"type":"string", "example":"follow"},
"threshold":{"type":"integer", "example":5},
"name":{"type":"string", "example":"팔로워 5명 달성"},
"badgeImage":{"type":"string", "example":"null"}
}
}
},
"reviews":{
"type":"array",
"items":{
"properties":{
"id":{"type":"integer", "example":101},
"requestId":{"type":"integer", "example":77},
"rate":{"type":"integer", "example":5},
"content":{"type":"string", "example":"좋았습니다"},
"createdAt":{"type":"string", "example":"2025-08-09T12:30:00.000Z"},
"updatedAt":{"type":"string", "example":"2025-08-09T12:30:00.000Z"}
}
}
}
}
}
}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/user/controller/user.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ export const getUserProfile = async(req, res, next) => {
const accountId = req.user.accountId;
console.log("controller accountId -> ", accountId);

const userId = req.user.userId;

const role = req.user.role;
console.log(role);

const result = await UserService.getUserProfile(accountId, role);
const result = await UserService.getUserProfile(accountId, userId, role);

res.status(StatusCodes.OK).success(result);
} catch(err){
Expand Down
15 changes: 15 additions & 0 deletions src/user/repository/user.repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,21 @@ export const UserRepository = {
}
});
},
// 사용자가 작성한 리뷰 조회
async UserReviewList(userId) {
return await prisma.review.findMany({
wehre : {useraId: userId},
select:{
id:true,
requestId:true,
rate: true,
content:true,
createddAt: true,
updatedAt: true,
},
orderBy: {createdAt:"desc"},
});
}

};

17 changes: 10 additions & 7 deletions src/user/service/user.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const UserService = {
}
},
// 사용자 프로필 조회
async getUserProfile(accountId, role) {
async getUserProfile(accountId, userId, role) {

let result;

Expand All @@ -128,6 +128,9 @@ export const UserService = {
earnedAt: userBadge.earnedAt,
badge: userBadge.badge
}));

const reviews = (await UserRepository.UserReviewList(userId)) ?? [];



return {
Expand All @@ -137,7 +140,8 @@ export const UserService = {
nickname: user.nickname,
profileImage:user.profileImage,
description: user.description,
badges
badges,
reviews
}
}
}
Expand All @@ -149,11 +153,10 @@ export const UserService = {

console.log("userBadges 확인:", result.userBadges);


const badges = result.userBadges.map(userBadge => ({
id: userBadge.id,
earnedAt: userBadge.earnedAt,
badge: userBadge.badge
const badges = result.userBadges.map((userBadge) => ({
id: userBadge.id,
earnedAt: userBadge.earnedAt,
badge: userBadge.badge? [userBadge.badge] : []
}));

return {
Expand Down