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
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,24 @@ public ResponseEntity<RsData<List<ArtistListResponse>>> getArtistList() {
@GetMapping("/profile/{artistId}")
@Operation(
summary = "작가 공개 프로필 상세 조회",
description = "작가의 공개 프로필 상세 정보를 조회합니다."
description = "작가의 공개 프로필 상세 정보를 조회합니다. 로그인한 경우 팔로우 여부가 포함됩니다."
)
public ResponseEntity<RsData<ArtistPublicProfileResponse>> getArtistPublicProfile(
@Parameter(description = "작가 ID", example = "42", required = true)
@PathVariable Long artistId) {

log.info("작가 공개 프로필 조회 - artistId: {}", artistId);
@PathVariable Long artistId,
@AuthenticationPrincipal CustomUserDetails userDetails) {

ArtistPublicProfileResponse response = artistPublicService.getPublicProfile(artistId);
ArtistPublicProfileResponse response;

if (userDetails != null) {
// 로그인한 사용자 - 팔로우 상태 포함
log.info("작가 공개 프로필 조회 (로그인) - artistId: {}, userId: {}", artistId, userDetails.getUserId());
response = artistPublicService.getPublicProfile(artistId, userDetails.getUserId());
} else {
// 비로그인 사용자 - 팔로우 상태 미포함
log.info("작가 공개 프로필 조회 (비로그인) - artistId: {}", artistId);
response = artistPublicService.getPublicProfile(artistId);
}

return ResponseEntity.ok(
RsData.of("200", "작가 프로필 조회 성공", response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public record ArtistPublicProfileResponse(
@Schema(description = "등록 상품 수", example = "15")
Integer productCount,

@Schema(description = "팔로우 여부", example = "true")
Boolean isFollowing,

@Schema(description = "작가 등록일", example = "2024-01-15T10:30:00")
LocalDateTime createdAt
) {
Expand All @@ -50,6 +53,23 @@ public static ArtistPublicProfileResponse from(ArtistProfile artistProfile) {
artistProfile.getFollowerCount(),
artistProfile.getTotalSales(),
artistProfile.getProductCount(),
false, // 기본값, Service에서 설정 필요
artistProfile.getCreateDate()
);
}

public static ArtistPublicProfileResponse from(ArtistProfile artistProfile, boolean isFollowing) {
return new ArtistPublicProfileResponse(
artistProfile.getId(),
artistProfile.getArtistName(),
artistProfile.getProfileImageUrl(),
artistProfile.getDescription(),
artistProfile.getMainProducts(),
artistProfile.getSnsAccount(),
artistProfile.getFollowerCount(),
artistProfile.getTotalSales(),
artistProfile.getProductCount(),
isFollowing,
artistProfile.getCreateDate()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.back.domain.artist.dto.response.ArtistPublicProfileResponse;
import com.back.domain.artist.entity.ArtistProfile;
import com.back.domain.artist.repository.ArtistProfileRepository;
import com.back.domain.follow.repository.FollowRepository;
import com.back.domain.product.product.entity.Product;
import com.back.domain.product.product.entity.ProductImage;
import com.back.domain.product.product.repository.ProductRepository;
Expand All @@ -29,6 +30,7 @@ public class ArtistPublicService {

private final ArtistProfileRepository artistProfileRepository;
private final ProductRepository productRepository;
private final FollowRepository followRepository;

/**
* 작가 목록 조회
Expand All @@ -46,10 +48,10 @@ public List<ArtistListResponse> getArtistList() {
}

/**
* 작가 공개 프로필 상세 조회
* 작가 공개 프로필 상세 조회 (비로그인 사용자)
*/
public ArtistPublicProfileResponse getPublicProfile(Long artistId) {
log.info("작가 공개 프로필 조회 시작 - artistId: {}", artistId);
log.info("작가 공개 프로필 조회 시작 (비로그인) - artistId: {}", artistId);

// 작가 프로필 조회
ArtistProfile artistProfile = artistProfileRepository.findById(artistId)
Expand All @@ -61,6 +63,25 @@ public ArtistPublicProfileResponse getPublicProfile(Long artistId) {
return ArtistPublicProfileResponse.from(artistProfile);
}

/**
* 작가 공개 프로필 상세 조회 (로그인 사용자)
*/
public ArtistPublicProfileResponse getPublicProfile(Long artistId, Long currentUserId) {
log.info("작가 공개 프로필 조회 시작 (로그인) - artistId: {}, currentUserId: {}", artistId, currentUserId);

// 작가 프로필 조회
ArtistProfile artistProfile = artistProfileRepository.findById(artistId)
.orElseThrow(() -> new ServiceException("404", "존재하지 않는 작가입니다."));

// 팔로우 여부 확인
boolean isFollowing = followRepository.existsByFollowerIdAndFollowingArtistId(currentUserId, artistId);

log.info("작가 공개 프로필 조회 완료 - artistId: {}, artistName: {}, isFollowing: {}",
artistId, artistProfile.getArtistName(), isFollowing);

return ArtistPublicProfileResponse.from(artistProfile, isFollowing);
}

/**
* 작가 상품 목록 조회
*/
Expand Down