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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.somemore.domains.volunteer.service;

import com.somemore.domains.volunteer.domain.Volunteer;
import com.somemore.domains.volunteer.domain.VolunteerDetail;
import com.somemore.domains.volunteer.dto.response.VolunteerProfileResponseDto;
import com.somemore.domains.volunteer.dto.response.VolunteerRankingResponseDto;
import com.somemore.domains.volunteer.repository.VolunteerDetailRepository;
import com.somemore.domains.volunteer.repository.VolunteerRepository;
Expand Down Expand Up @@ -31,34 +29,6 @@ public class VolunteerQueryService implements VolunteerQueryUseCase {
private final VolunteerDetailRepository volunteerDetailRepository;
private final VolunteerDetailAccessValidator volunteerDetailAccessValidator;

@Override
public VolunteerProfileResponseDto getMyProfile(UUID volunteerId) {

return VolunteerProfileResponseDto.from(
findVolunteer(volunteerId),
findVolunteerDetail(volunteerId)
);
}

@Override
public VolunteerProfileResponseDto getVolunteerProfile(UUID volunteerId) {

return VolunteerProfileResponseDto.from(
findVolunteer(volunteerId)
);
}

@Override
public VolunteerProfileResponseDto getVolunteerDetailedProfile(UUID volunteerId,
UUID centerId) {
volunteerDetailAccessValidator.validateByCenterId(centerId, volunteerId);

return VolunteerProfileResponseDto.from(
findVolunteer(volunteerId),
findVolunteerDetail(volunteerId)
);
}

@Override
public UUID getVolunteerIdByOAuthId(String oAuthId) {
return volunteerRepository.findByOauthId(oAuthId)
Expand Down Expand Up @@ -99,15 +69,4 @@ public void validateVolunteerExists(UUID volunteerId) {
throw new BadRequestException(NOT_EXISTS_VOLUNTEER.getMessage());
}
}

private Volunteer findVolunteer(UUID volunteerId) {
return volunteerRepository.findById(volunteerId)
.orElseThrow(() -> new BadRequestException(NOT_EXISTS_VOLUNTEER));
}

private VolunteerDetail findVolunteerDetail(UUID volunteerId) {
return volunteerDetailRepository.findByVolunteerId(volunteerId)
.orElseThrow(() -> new BadRequestException(NOT_EXISTS_VOLUNTEER));
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.somemore.domains.volunteer.usecase;

import com.somemore.domains.volunteer.domain.Volunteer;
import com.somemore.domains.volunteer.dto.response.VolunteerProfileResponseDto;
import com.somemore.domains.volunteer.dto.response.VolunteerRankingResponseDto;
import com.somemore.domains.volunteer.repository.mapper.VolunteerSimpleInfo;

Expand All @@ -10,12 +9,6 @@

public interface VolunteerQueryUseCase {

VolunteerProfileResponseDto getMyProfile(UUID volunteerId);

VolunteerProfileResponseDto getVolunteerProfile(UUID volunteerId);

VolunteerProfileResponseDto getVolunteerDetailedProfile(UUID volunteerId, UUID centerId);

UUID getVolunteerIdByOAuthId(String oAuthId);

String getNicknameById(UUID id);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.somemore.domains.volunteer.controller;
package com.somemore.volunteer.controller;

import com.somemore.domains.volunteer.dto.response.VolunteerProfileResponseDto;
import com.somemore.domains.volunteer.usecase.VolunteerQueryUseCase;
import com.somemore.global.auth.annotation.CurrentUser;
import com.somemore.global.auth.annotation.UserId;
import com.somemore.global.common.response.ApiResponse;
import com.somemore.volunteer.dto.VolunteerProfileResponseDto;
import com.somemore.volunteer.usecase.GetVolunteerProfileUseCase;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
Expand All @@ -23,43 +23,38 @@
@Tag(name = "GET Volunteer Profile", description = "봉사자 조회")
public class VolunteerProfileQueryController {

private final VolunteerQueryUseCase volunteerQueryUseCase;
private final GetVolunteerProfileUseCase getVolunteerProfileUseCase;

@Operation(summary = "본인 상세 프로필 조회", description = "현재 로그인된 사용자의 상세 프로필을 조회합니다.")
@Secured("ROLE_VOLUNTEER")
@GetMapping("/me")
public ApiResponse<VolunteerProfileResponseDto> getMyProfile(
@CurrentUser UUID volunteerId) {

@UserId UUID userId) {
return ApiResponse.ok(
200,
volunteerQueryUseCase.getMyProfile(volunteerId),
"본인 상세 프로필 조회 성공");
getVolunteerProfileUseCase.getProfileByUserId(userId),
"본인 프로필 조회 성공");
}

@GetMapping("/{volunteerId}")
@Operation(summary = "타인 프로필 조회", description = "특정 봉사자의 프로필을 조회합니다. 상세 정보는 포함되지 않습니다.")
public ApiResponse<VolunteerProfileResponseDto> getVolunteerProfile(
@PathVariable UUID volunteerId) {

@GetMapping("/user-id/{userId}")
@Operation(summary = "타인 프로필 조회 (유저 아이디)", description = "유저 아이디로 특정 봉사자의 상세 프로필을 조회합니다.")
public ApiResponse<VolunteerProfileResponseDto> getVolunteerProfileByUserId(
@PathVariable UUID userId) {
return ApiResponse.ok(
200,
volunteerQueryUseCase.getVolunteerProfile(volunteerId),
getVolunteerProfileUseCase.getProfileByUserId(userId),
"타인 프로필 조회 성공"
);
}

@GetMapping("/{volunteerId}/detailed")
@Secured("ROLE_CENTER")
@Operation(summary = "지원자 상세 프로필 조회", description = "기관이 작성한 모집 글에 지원한 봉사자의 상세 프로필을 조회합니다.")
public ApiResponse<VolunteerProfileResponseDto> getVolunteerDetailedProfile(
@PathVariable UUID volunteerId,
@CurrentUser UUID centerId) {

@GetMapping("/volunteer-id/{volunteerId}")
@Operation(summary = "타인 프로필 조회 (봉사자 아아디)", description = "봉사자 아이디특정 봉사자의 상세 프로필을 조회합니다.")
public ApiResponse<VolunteerProfileResponseDto> getVolunteerProfileByVolunteerId(
@PathVariable UUID volunteerId) {
return ApiResponse.ok(
200,
volunteerQueryUseCase.getVolunteerDetailedProfile(volunteerId, centerId),
"지원자 상세 프로필 조회 성공"
getVolunteerProfileUseCase.getProfileByVolunteerId(volunteerId),
"타인 프로필 조회 성공"
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package com.somemore.volunteer.dto;

import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import com.somemore.user.domain.UserCommonAttribute;
import com.somemore.volunteer.domain.NEWVolunteer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;

@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
@Schema(description = "봉사자 프로필 응답 DTO")
@Builder
public record VolunteerProfileResponseDto(

@Schema(description = "봉사자 닉네임", example = "길동이")
String nickname,

@Schema(description = "봉사자 등급", example = "RED")
String tier,

@Schema(description = "봉사자 이미지 URL", example = "http://example.com/image.jpg")
String imgUrl,

@Schema(description = "봉사자 소개", example = "안녕하세요! 봉사 활동을 좋아합니다.")
String introduce,

@Schema(description = "총 봉사 시간", example = "120")
Integer totalVolunteerHours,

@Schema(description = "총 봉사 횟수", example = "20")
Integer totalVolunteerCount,

@Schema(description = "봉사자 상세 정보", implementation = Detail.class)
Detail detail
) {

public static VolunteerProfileResponseDto of(
NEWVolunteer volunteer,
UserCommonAttribute commonAttribute
) {
return VolunteerProfileResponseDto.builder()
.nickname(volunteer.getNickname())
.tier(volunteer.getTier().name())
.imgUrl(commonAttribute.getImgUrl())
.introduce(commonAttribute.getIntroduce())
.totalVolunteerHours(volunteer.getTotalVolunteerHours())
.totalVolunteerCount(volunteer.getTotalVolunteerCount())
.detail(Detail.of(volunteer, commonAttribute))
.build();
}

@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
@Schema(description = "봉사자 상세 프로필")
@Builder
public record Detail(
@Schema(description = "이름", example = "홍길동")
String name,

@Schema(description = "성별", example = "MALE")
String gender,

@Schema(description = "연락처", example = "010-1234-5678")
String contactNumber
) {
public static Detail of(
NEWVolunteer volunteer,
UserCommonAttribute commonAttribute
) {
return Detail.builder()
.name(commonAttribute.getName())
.gender(volunteer.getGender().name())
.contactNumber(commonAttribute.getContactNumber())
.build();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.somemore.volunteer.service;

import com.somemore.user.domain.UserCommonAttribute;
import com.somemore.user.usecase.UserQueryUseCase;
import com.somemore.volunteer.domain.NEWVolunteer;
import com.somemore.volunteer.dto.VolunteerProfileResponseDto;
import com.somemore.volunteer.usecase.GetVolunteerProfileUseCase;
import com.somemore.volunteer.usecase.NEWVolunteerQueryUseCase;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.UUID;

@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class GetVolunteerProfileService implements GetVolunteerProfileUseCase {

private final NEWVolunteerQueryUseCase volunteerQueryUseCase;
private final UserQueryUseCase userQueryUseCase;

@Override
public VolunteerProfileResponseDto getProfileByUserId(UUID userId) {
NEWVolunteer volunteer = volunteerQueryUseCase.getByUserId(userId);
UserCommonAttribute commonAttribute = userQueryUseCase.getCommonAttributeByUserId(userId);

return VolunteerProfileResponseDto.of(volunteer, commonAttribute);
}

@Override
public VolunteerProfileResponseDto getProfileByVolunteerId(UUID volunteerId) {
UUID userId = volunteerQueryUseCase.getUserIdById(volunteerId);
return getProfileByUserId(userId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,23 @@ public class NEWVolunteerQueryService implements NEWVolunteerQueryUseCase {

private final NEWVolunteerRepository volunteerRepository;

@Override
public NEWVolunteer getById(UUID id) {
return volunteerRepository.findById(id)
.orElseThrow(() -> new NoSuchElementException(ExceptionMessage.NOT_EXISTS_VOLUNTEER));
}

@Override
public NEWVolunteer getByUserId(UUID userId) {
return volunteerRepository.findByUserId(userId)
.orElseThrow(() -> new NoSuchElementException(ExceptionMessage.NOT_EXISTS_VOLUNTEER));
}

@Override
public UUID getUserIdById(UUID id) {
return getById(id).getUserId();
}

@Override
public UUID getIdByUserId(UUID userId) {
return getByUserId(userId).getId();
Expand Down
Loading
Loading