Skip to content

Commit 8ad88bd

Browse files
authored
Merge pull request #148 from umc-commit/fix/front-user-artist-google
2 parents adafeca + 6246910 commit 8ad88bd

3 files changed

Lines changed: 149 additions & 5 deletions

File tree

src/common/swagger/user.json

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,137 @@
678678
}
679679
}
680680
}
681+
},
682+
"/api/artists/{artistId}":{
683+
"get":{
684+
"tags":["User"],
685+
"summary": "작가 프로필 조회하기",
686+
"description": "작가 프로필을 조회하는 API입니다. ",
687+
"security" : [
688+
{
689+
"bearerAuth":[]
690+
}
691+
],
692+
"parameters": [
693+
{
694+
"name": "artistId",
695+
"in": "path",
696+
"required": true,
697+
"description": "팔로우할 작가의 ID",
698+
"schema": {
699+
"type": "string",
700+
"example": "1"
701+
}
702+
}
703+
],
704+
"responses":{
705+
"200":{
706+
"description":"해당 작가 프로필 조회 성공",
707+
"content":{
708+
"application/json": {
709+
"schema":{
710+
"type":"object",
711+
"properties":{
712+
"resultType":{"type":"object", "example":"SUCCESS"},
713+
"error":{"type":null, "example":null},
714+
"success":{
715+
"type":"object",
716+
"properties":{
717+
"nickname":{"type": "string", "example":"artist_one"},
718+
"description":{"type":"string", "example":"테스트용 작가입니다."},
719+
"profileImage":{"type": "string", "example":"https://example.com/artist1.png"},
720+
"slot":{"type": "integer", "example":3},
721+
"reviews":{
722+
"type":"array",
723+
"items":{
724+
"properties":{
725+
"id":{"type":"string", "example":"5"},
726+
"rate":{"type":"integer", "example":5},
727+
"content":{"type":"string", "example": "안녕~"},
728+
"createdAt" :{"type":"string", "example": "2025-08-04T02:31:36.000Z"},
729+
"commissionTitle":{"type":"string", "example":"테스트 커미션 글"},
730+
"workingTime":{"type":"string", "example":"33일"},
731+
"writer":{
732+
"type":"object",
733+
"properties":{
734+
"nickname":{"type":"string", "example":"신청자1"}
735+
}
736+
}
737+
}
738+
}
739+
},
740+
"commissions":{
741+
"type":"array",
742+
"items":{
743+
"properties":{
744+
"id":{"type":"string", "example":"1"},
745+
"title":{"type":"string", "example":"테스트 커미션 글"},
746+
"summary":{"type":"string", "example":"이것은 테스트용 커미션 글입니다."},
747+
"minPrice":{"type":"integer", "example":1000},
748+
"category":{"type":"string", "example":""},
749+
"tags":{
750+
"type":"array",
751+
"items":{"type":"string"},
752+
"example":["감성", "낙서"]
753+
},
754+
"commission_img":{"type":"string", "example":"http://example.com/image.jpg"}
755+
}
756+
}
757+
},
758+
"badges" :{
759+
"type":"array",
760+
"items":{
761+
"properties":{
762+
"id":{"type":"string", "example":"1"},
763+
"earnedAt":{"type":"string", "example":"2025-08-03T23:24:37.000Z"},
764+
"badge":{
765+
"type":"array",
766+
"items":{
767+
"properties":{
768+
"id":{"type":"string", "example":"1"},
769+
"type":{"type":"string", "example": "comm_finish"},
770+
"threshold":{"type":"integer", "example":1},
771+
"name":{"type":"string", "example":"커미션 1회 완료"},
772+
"badgeImage":{"type":"string", "example":"https://example.com/badge_comm1.png"}
773+
}
774+
}
775+
}
776+
}
777+
}
778+
}
779+
780+
}
781+
}
782+
}
783+
784+
}
785+
}
786+
}
787+
},
788+
"404":{
789+
"description": "해당 작가가 존재하지 않습니다.",
790+
"content": {
791+
"application/json": {
792+
"schema": {
793+
"type": "object",
794+
"properties": {
795+
"resultType": { "type": "string", "example": "FAIL" },
796+
"error": {
797+
"type": "object",
798+
"properties": {
799+
"errorCode": { "type": "string", "example": "U008" },
800+
"reason": { "type": "string", "example": "해당 작가가 존재하지 않습니다." },
801+
"data": { "type": ["object", "null"], "example": null }
802+
}
803+
},
804+
"success": { "type": "null", "example": null }
805+
}
806+
}
807+
}
808+
}
809+
}
810+
}
811+
}
681812
}
682813
}
683814
}

src/user/controller/user.controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export const AccessArtistProfile = async(req, res, next) => {
183183
const accountId = req.user.accountId;
184184
const userId = req.user.userId;
185185

186-
const result = await UserService.AccessArtistProfile(artistId, accountId);
186+
const result = await UserService.AccessArtistProfile(artistId, accountId, userId);
187187

188188
res.status(StatusCodes.OK).success(result);
189189
} catch(err) {

src/user/service/user.service.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { OauthIdAlreadyExistError, MissingCategoryError, MissingRequiredAgreemen
33
import axios from "axios";
44
import { signJwt } from "../../jwt.config.js";
55
import { BadgeRepository } from "../repository/badge.repository.js";
6+
import { CommissionRepository } from "../../commission/repository/commission.repository.js";
67

78

89

@@ -345,6 +346,10 @@ export const UserService = {
345346
// 작가 프로필 조회하기
346347
async AccessArtistProfile(artistId, accountId, userId) {
347348
const profile = await UserRepository.AccessArtistProfile(artistId);
349+
350+
if(!profile)
351+
throw new ArtistNotFound();
352+
348353
const rawReviews = await UserRepository.ArtistReviews(artistId);
349354

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

373378
// 작가가 등록한 커미션 목록
374379
const commissions = await UserRepository.FetchArtistCommissions(artistId, userId);
375-
const commissionList = commissions.map(c=> ({
380+
const commissionList = await Promise.all(
381+
commissions.map(async (c) => {
382+
const images = await CommissionRepository.findImagesByCommissionId(c.id); // c.id == targetId
383+
384+
return {
376385
id: c.id,
377386
title: c.title,
378387
summary: c.summary,
379388
minPrice: c.minPrice,
380389
category: c.category.name,
381390
tags: c.commissionTags.map(t => t.tag.name),
382-
thumbnail: c.thumbnailImage, // 컬럼 존재 시
383-
bookmark: c.bookmarks.length > 0
384-
}));
391+
thumbnail: c.thumbnailImage,
392+
bookmark: c.bookmarks.length > 0,
393+
commission_img: images.length > 0 ? images[0].url : null // 첫 번째 이미지를 대표로
394+
};
395+
})
396+
);
397+
385398

386399

387400
const result = await UserRepository.getMyProfile(accountId);

0 commit comments

Comments
 (0)