From 1c6e89b06fde7ce0ae92198613ad380e78a1a7db Mon Sep 17 00:00:00 2001 From: taeyoung0524 Date: Fri, 8 Aug 2025 22:00:28 +0900 Subject: [PATCH 1/2] =?UTF-8?q?FIX=20:=20=EC=9E=91=EA=B0=80=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=ED=95=84=20=EC=A1=B0=ED=9A=8C=EC=97=90=20image=20?= =?UTF-8?q?=ED=85=8C=EC=9D=B4=EB=B8=94=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/user/controller/user.controller.js | 2 +- src/user/service/user.service.js | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/user/controller/user.controller.js b/src/user/controller/user.controller.js index 3c68842..11a1b96 100644 --- a/src/user/controller/user.controller.js +++ b/src/user/controller/user.controller.js @@ -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) { diff --git a/src/user/service/user.service.js b/src/user/service/user.service.js index 186d2b5..e1ff35f 100644 --- a/src/user/service/user.service.js +++ b/src/user/service/user.service.js @@ -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"; @@ -372,16 +373,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); From 6246910704f650aa7a10713cdef60a4cb21fa5ce Mon Sep 17 00:00:00 2001 From: taeyoung0524 Date: Sat, 9 Aug 2025 01:04:29 +0900 Subject: [PATCH 2/2] =?UTF-8?q?FEAT=20:=20=EC=9E=91=EA=B0=80=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=ED=95=84=20=EC=A1=B0=ED=9A=8C=20swagger=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80,=20=EC=9E=91=EA=B0=80=20=ED=94=84=EB=A1=9C=ED=95=84?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C=EC=97=90=20commission=5Fimage=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/swagger/user.json | 131 +++++++++++++++++++++++++++++++ src/user/service/user.service.js | 4 + 2 files changed, 135 insertions(+) diff --git a/src/common/swagger/user.json b/src/common/swagger/user.json index ec2abed..5d32a60 100644 --- a/src/common/swagger/user.json +++ b/src/common/swagger/user.json @@ -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 } + } + } + } + } + } + } + } } } } diff --git a/src/user/service/user.service.js b/src/user/service/user.service.js index e1ff35f..c30c93d 100644 --- a/src/user/service/user.service.js +++ b/src/user/service/user.service.js @@ -346,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) => {