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
131 changes: 131 additions & 0 deletions src/common/swagger/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,137 @@
}
}
}
},
"/api/artists/{artistId}":{
"get":{
"tags":["User"],
"summary": "작가 프로필 조회하기",
"description": "작가 프로필을 조회하는 API입니다. ",
"security" : [
{
"bearerAuth":[]
}
],
"parameters": [
{
"name": "artistId",
"in": "path",
"required": true,
"description": "팔로우할 작가의 ID",
"schema": {
"type": "string",
"example": "1"
}
}
],
"responses":{
"200":{
"description":"해당 작가 프로필 조회 성공",
"content":{
"application/json": {
"schema":{
"type":"object",
"properties":{
"resultType":{"type":"object", "example":"SUCCESS"},
"error":{"type":null, "example":null},
"success":{
"type":"object",
"properties":{
"nickname":{"type": "string", "example":"artist_one"},
"description":{"type":"string", "example":"테스트용 작가입니다."},
"profileImage":{"type": "string", "example":"https://example.com/artist1.png"},
"slot":{"type": "integer", "example":3},
"reviews":{
"type":"array",
"items":{
"properties":{
"id":{"type":"string", "example":"5"},
"rate":{"type":"integer", "example":5},
"content":{"type":"string", "example": "안녕~"},
"createdAt" :{"type":"string", "example": "2025-08-04T02:31:36.000Z"},
"commissionTitle":{"type":"string", "example":"테스트 커미션 글"},
"workingTime":{"type":"string", "example":"33일"},
"writer":{
"type":"object",
"properties":{
"nickname":{"type":"string", "example":"신청자1"}
}
}
}
}
},
"commissions":{
"type":"array",
"items":{
"properties":{
"id":{"type":"string", "example":"1"},
"title":{"type":"string", "example":"테스트 커미션 글"},
"summary":{"type":"string", "example":"이것은 테스트용 커미션 글입니다."},
"minPrice":{"type":"integer", "example":1000},
"category":{"type":"string", "example":"글"},
"tags":{
"type":"array",
"items":{"type":"string"},
"example":["감성", "낙서"]
},
"commission_img":{"type":"string", "example":"http://example.com/image.jpg"}
}
}
},
"badges" :{
"type":"array",
"items":{
"properties":{
"id":{"type":"string", "example":"1"},
"earnedAt":{"type":"string", "example":"2025-08-03T23:24:37.000Z"},
"badge":{
"type":"array",
"items":{
"properties":{
"id":{"type":"string", "example":"1"},
"type":{"type":"string", "example": "comm_finish"},
"threshold":{"type":"integer", "example":1},
"name":{"type":"string", "example":"커미션 1회 완료"},
"badgeImage":{"type":"string", "example":"https://example.com/badge_comm1.png"}
}
}
}
}
}
}

}
}
}

}
}
}
},
"404":{
"description": "해당 작가가 존재하지 않습니다.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"resultType": { "type": "string", "example": "FAIL" },
"error": {
"type": "object",
"properties": {
"errorCode": { "type": "string", "example": "U008" },
"reason": { "type": "string", "example": "해당 작가가 존재하지 않습니다." },
"data": { "type": ["object", "null"], "example": null }
}
},
"success": { "type": "null", "example": null }
}
}
}
}
}
}
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/user/controller/user.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export const AccessArtistProfile = async(req, res, next) => {
const accountId = req.user.accountId;
const userId = req.user.userId;

const result = await UserService.AccessArtistProfile(artistId, accountId);
const result = await UserService.AccessArtistProfile(artistId, accountId, userId);

res.status(StatusCodes.OK).success(result);
} catch(err) {
Expand Down
21 changes: 17 additions & 4 deletions src/user/service/user.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { OauthIdAlreadyExistError, MissingCategoryError, MissingRequiredAgreemen
import axios from "axios";
import { signJwt } from "../../jwt.config.js";
import { BadgeRepository } from "../repository/badge.repository.js";
import { CommissionRepository } from "../../commission/repository/commission.repository.js";



Expand Down Expand Up @@ -345,6 +346,10 @@ export const UserService = {
// 작가 프로필 조회하기
async AccessArtistProfile(artistId, accountId, userId) {
const profile = await UserRepository.AccessArtistProfile(artistId);

if(!profile)
throw new ArtistNotFound();

const rawReviews = await UserRepository.ArtistReviews(artistId);

const reviews = rawReviews.map((r) => {
Expand Down Expand Up @@ -372,16 +377,24 @@ export const UserService = {

// 작가가 등록한 커미션 목록
const commissions = await UserRepository.FetchArtistCommissions(artistId, userId);
const commissionList = commissions.map(c=> ({
const commissionList = await Promise.all(
commissions.map(async (c) => {
const images = await CommissionRepository.findImagesByCommissionId(c.id); // c.id == targetId

return {
id: c.id,
title: c.title,
summary: c.summary,
minPrice: c.minPrice,
category: c.category.name,
tags: c.commissionTags.map(t => t.tag.name),
thumbnail: c.thumbnailImage, // 컬럼 존재 시
bookmark: c.bookmarks.length > 0
}));
thumbnail: c.thumbnailImage,
bookmark: c.bookmarks.length > 0,
commission_img: images.length > 0 ? images[0].url : null // 첫 번째 이미지를 대표로
};
})
);



const result = await UserRepository.getMyProfile(accountId);
Expand Down