From e89039c3e6fc0b5498083d736bdcb07d0660a516 Mon Sep 17 00:00:00 2001 From: hseong3243 <48748265+hseong3243@users.noreply.github.com> Date: Wed, 8 Nov 2023 23:36:15 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=EC=95=A1=EC=84=B8=EC=8A=A4=20?= =?UTF-8?q?=ED=86=A0=ED=81=B0=20=EC=A0=84=EC=86=A1=EC=8B=9C=20perfix=20Bea?= =?UTF-8?q?rer=EB=A5=BC=20=EC=B6=94=EA=B0=80=ED=95=9C=EB=8B=A4.=20=20(#160?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: 인증 패키지 구조를 개선한다. * feat: JWT 인증 필터에서 Bearer 를 명시한 토큰만을 받도록 변경한다. * docs: 인증 도메인 api 문서화를 추가한다. --- src/docs/asciidoc/index.adoc | 24 +++++++++++++++++++ .../animal/controller/AnimalController.java | 2 +- .../controller/ApplicantController.java | 2 +- .../domain/auth/{resolver => }/LoginUser.java | 2 +- .../JwtAuthenticationProvider.java | 2 +- .../auth/controller/AuthController.java | 6 ++--- .../request/LoginRequest.java | 2 +- .../{jwt => dto}/response/CustomClaims.java | 2 +- .../response/LoginResponse.java | 3 +-- .../{jwt => dto}/response/TokenResponse.java | 2 +- .../auth/exception/InvalidJwtException.java | 4 ++++ .../domain/auth/jwt/JwtProvider.java | 4 ++-- .../domain/auth/service/AuthService.java | 2 +- .../controller/RecruitmentController.java | 2 +- .../review/controller/ReviewController.java | 2 +- .../shelter/controller/ShelterController.java | 2 +- .../controller/VolunteerController.java | 2 +- .../global/config/SecurityConfig.java | 2 +- .../global/config/WebMvcConfig.java | 2 +- .../auth => global}/jwt/JJwtProvider.java | 15 ++++++------ .../LoginUserArgumentResolver.java | 3 ++- .../web}/filter/JwtAuthenticationFilter.java | 20 +++++++++++++--- .../JwtAuthenticationProviderTest.java | 2 +- .../auth/controller/AuthControllerTest.java | 6 ++--- .../filter/JwtAuthenticationFilterTest.java | 24 +++++++++++++++---- .../domain/auth/jwt/JJwtProviderTest.java | 5 ++-- .../resolver/LoginUserTestController.java | 1 + .../domain/auth/service/AuthServiceTest.java | 2 +- .../domain/auth/support/AuthFixture.java | 9 +++---- 29 files changed, 109 insertions(+), 47 deletions(-) rename src/main/java/com/clova/anifriends/domain/auth/{resolver => }/LoginUser.java (83%) rename src/main/java/com/clova/anifriends/domain/auth/{controller => dto}/request/LoginRequest.java (81%) rename src/main/java/com/clova/anifriends/domain/auth/{jwt => dto}/response/CustomClaims.java (81%) rename src/main/java/com/clova/anifriends/domain/auth/{controller => dto}/response/LoginResponse.java (73%) rename src/main/java/com/clova/anifriends/domain/auth/{jwt => dto}/response/TokenResponse.java (87%) rename src/main/java/com/clova/anifriends/{domain/auth => global}/jwt/JJwtProvider.java (91%) rename src/main/java/com/clova/anifriends/{domain/auth/resolver => global/web/argumentresolver}/LoginUserArgumentResolver.java (94%) rename src/main/java/com/clova/anifriends/{domain/auth => global/web}/filter/JwtAuthenticationFilter.java (60%) diff --git a/src/docs/asciidoc/index.adoc b/src/docs/asciidoc/index.adoc index 84030ff68..ea5ad864d 100644 --- a/src/docs/asciidoc/index.adoc +++ b/src/docs/asciidoc/index.adoc @@ -9,6 +9,30 @@ == 0. 인증 +=== 보호소 로그인 + +==== Request +operation::auth-controller-test/shelter-login[snippets='http-request,request-fields'] + +==== Response +operation::auth-controller-test/shelter-login[snippets='http-response,response-fields,response-cookies'] + +=== 봉사자 로그인 + +==== Request +operation::auth-controller-test/volunteer-login[snippets='http-request,request-fields'] + +==== Response +operation::auth-controller-test/volunteer-login[snippets='http-response,response-fields,response-cookies'] + +=== 액세스 토큰 갱신 + +==== Request +operation::auth-controller-test/refresh-access-token[snippets='http-request,request-cookies'] + +==== Response +operation::auth-controller-test/refresh-access-token[snippets='http-response,response-fields,response-cookies'] + == 1. 봉사자 === 봉사자가 완료한 봉사 모집글 리스트 조회 diff --git a/src/main/java/com/clova/anifriends/domain/animal/controller/AnimalController.java b/src/main/java/com/clova/anifriends/domain/animal/controller/AnimalController.java index 66d5cc258..92fecaf6d 100644 --- a/src/main/java/com/clova/anifriends/domain/animal/controller/AnimalController.java +++ b/src/main/java/com/clova/anifriends/domain/animal/controller/AnimalController.java @@ -8,7 +8,7 @@ import com.clova.anifriends.domain.animal.dto.response.FindAnimalsByVolunteerResponse; import com.clova.anifriends.domain.animal.dto.response.RegisterAnimalResponse; import com.clova.anifriends.domain.animal.service.AnimalService; -import com.clova.anifriends.domain.auth.resolver.LoginUser; +import com.clova.anifriends.domain.auth.LoginUser; import jakarta.validation.Valid; import java.net.URI; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/clova/anifriends/domain/applicant/controller/ApplicantController.java b/src/main/java/com/clova/anifriends/domain/applicant/controller/ApplicantController.java index d23923b86..3cf2fd02e 100644 --- a/src/main/java/com/clova/anifriends/domain/applicant/controller/ApplicantController.java +++ b/src/main/java/com/clova/anifriends/domain/applicant/controller/ApplicantController.java @@ -3,7 +3,7 @@ import com.clova.anifriends.domain.applicant.dto.FindApplicantsApprovedResponse; import com.clova.anifriends.domain.applicant.dto.FindApplyingVolunteersResponse; import com.clova.anifriends.domain.applicant.service.ApplicantService; -import com.clova.anifriends.domain.auth.resolver.LoginUser; +import com.clova.anifriends.domain.auth.LoginUser; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; diff --git a/src/main/java/com/clova/anifriends/domain/auth/resolver/LoginUser.java b/src/main/java/com/clova/anifriends/domain/auth/LoginUser.java similarity index 83% rename from src/main/java/com/clova/anifriends/domain/auth/resolver/LoginUser.java rename to src/main/java/com/clova/anifriends/domain/auth/LoginUser.java index 47e52d3ba..50ffe2997 100644 --- a/src/main/java/com/clova/anifriends/domain/auth/resolver/LoginUser.java +++ b/src/main/java/com/clova/anifriends/domain/auth/LoginUser.java @@ -1,4 +1,4 @@ -package com.clova.anifriends.domain.auth.resolver; +package com.clova.anifriends.domain.auth; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/src/main/java/com/clova/anifriends/domain/auth/authentication/JwtAuthenticationProvider.java b/src/main/java/com/clova/anifriends/domain/auth/authentication/JwtAuthenticationProvider.java index 79bd876c7..7b9b4e148 100644 --- a/src/main/java/com/clova/anifriends/domain/auth/authentication/JwtAuthenticationProvider.java +++ b/src/main/java/com/clova/anifriends/domain/auth/authentication/JwtAuthenticationProvider.java @@ -1,7 +1,7 @@ package com.clova.anifriends.domain.auth.authentication; import com.clova.anifriends.domain.auth.jwt.JwtProvider; -import com.clova.anifriends.domain.auth.jwt.response.CustomClaims; +import com.clova.anifriends.domain.auth.dto.response.CustomClaims; import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; diff --git a/src/main/java/com/clova/anifriends/domain/auth/controller/AuthController.java b/src/main/java/com/clova/anifriends/domain/auth/controller/AuthController.java index 9b249accc..31512a295 100644 --- a/src/main/java/com/clova/anifriends/domain/auth/controller/AuthController.java +++ b/src/main/java/com/clova/anifriends/domain/auth/controller/AuthController.java @@ -1,8 +1,8 @@ package com.clova.anifriends.domain.auth.controller; -import com.clova.anifriends.domain.auth.controller.request.LoginRequest; -import com.clova.anifriends.domain.auth.controller.response.LoginResponse; -import com.clova.anifriends.domain.auth.jwt.response.TokenResponse; +import com.clova.anifriends.domain.auth.dto.request.LoginRequest; +import com.clova.anifriends.domain.auth.dto.response.LoginResponse; +import com.clova.anifriends.domain.auth.dto.response.TokenResponse; import com.clova.anifriends.domain.auth.service.AuthService; import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; diff --git a/src/main/java/com/clova/anifriends/domain/auth/controller/request/LoginRequest.java b/src/main/java/com/clova/anifriends/domain/auth/dto/request/LoginRequest.java similarity index 81% rename from src/main/java/com/clova/anifriends/domain/auth/controller/request/LoginRequest.java rename to src/main/java/com/clova/anifriends/domain/auth/dto/request/LoginRequest.java index c3d4a5557..b6df03425 100644 --- a/src/main/java/com/clova/anifriends/domain/auth/controller/request/LoginRequest.java +++ b/src/main/java/com/clova/anifriends/domain/auth/dto/request/LoginRequest.java @@ -1,4 +1,4 @@ -package com.clova.anifriends.domain.auth.controller.request; +package com.clova.anifriends.domain.auth.dto.request; import jakarta.validation.constraints.NotBlank; diff --git a/src/main/java/com/clova/anifriends/domain/auth/jwt/response/CustomClaims.java b/src/main/java/com/clova/anifriends/domain/auth/dto/response/CustomClaims.java similarity index 81% rename from src/main/java/com/clova/anifriends/domain/auth/jwt/response/CustomClaims.java rename to src/main/java/com/clova/anifriends/domain/auth/dto/response/CustomClaims.java index 93b2de397..171dae715 100644 --- a/src/main/java/com/clova/anifriends/domain/auth/jwt/response/CustomClaims.java +++ b/src/main/java/com/clova/anifriends/domain/auth/dto/response/CustomClaims.java @@ -1,4 +1,4 @@ -package com.clova.anifriends.domain.auth.jwt.response; +package com.clova.anifriends.domain.auth.dto.response; import java.util.List; diff --git a/src/main/java/com/clova/anifriends/domain/auth/controller/response/LoginResponse.java b/src/main/java/com/clova/anifriends/domain/auth/dto/response/LoginResponse.java similarity index 73% rename from src/main/java/com/clova/anifriends/domain/auth/controller/response/LoginResponse.java rename to src/main/java/com/clova/anifriends/domain/auth/dto/response/LoginResponse.java index 9c2cc1781..6b717b038 100644 --- a/src/main/java/com/clova/anifriends/domain/auth/controller/response/LoginResponse.java +++ b/src/main/java/com/clova/anifriends/domain/auth/dto/response/LoginResponse.java @@ -1,7 +1,6 @@ -package com.clova.anifriends.domain.auth.controller.response; +package com.clova.anifriends.domain.auth.dto.response; import com.clova.anifriends.domain.auth.jwt.UserRole; -import com.clova.anifriends.domain.auth.jwt.response.TokenResponse; public record LoginResponse(Long userId, UserRole role, String accessToken) { diff --git a/src/main/java/com/clova/anifriends/domain/auth/jwt/response/TokenResponse.java b/src/main/java/com/clova/anifriends/domain/auth/dto/response/TokenResponse.java similarity index 87% rename from src/main/java/com/clova/anifriends/domain/auth/jwt/response/TokenResponse.java rename to src/main/java/com/clova/anifriends/domain/auth/dto/response/TokenResponse.java index 495244369..a227263b3 100644 --- a/src/main/java/com/clova/anifriends/domain/auth/jwt/response/TokenResponse.java +++ b/src/main/java/com/clova/anifriends/domain/auth/dto/response/TokenResponse.java @@ -1,4 +1,4 @@ -package com.clova.anifriends.domain.auth.jwt.response; +package com.clova.anifriends.domain.auth.dto.response; import com.clova.anifriends.domain.auth.jwt.UserRole; diff --git a/src/main/java/com/clova/anifriends/domain/auth/exception/InvalidJwtException.java b/src/main/java/com/clova/anifriends/domain/auth/exception/InvalidJwtException.java index 06028448c..fd7373adf 100644 --- a/src/main/java/com/clova/anifriends/domain/auth/exception/InvalidJwtException.java +++ b/src/main/java/com/clova/anifriends/domain/auth/exception/InvalidJwtException.java @@ -5,6 +5,10 @@ public class InvalidJwtException extends AuthenticationException { + public InvalidJwtException(String message) { + super(ErrorCode.UN_AUTHENTICATION, message); + } + public InvalidJwtException(ErrorCode errorCode, String message) { super(errorCode, message); } diff --git a/src/main/java/com/clova/anifriends/domain/auth/jwt/JwtProvider.java b/src/main/java/com/clova/anifriends/domain/auth/jwt/JwtProvider.java index ec1511121..f1f07e738 100644 --- a/src/main/java/com/clova/anifriends/domain/auth/jwt/JwtProvider.java +++ b/src/main/java/com/clova/anifriends/domain/auth/jwt/JwtProvider.java @@ -1,8 +1,8 @@ package com.clova.anifriends.domain.auth.jwt; -import com.clova.anifriends.domain.auth.jwt.response.CustomClaims; -import com.clova.anifriends.domain.auth.jwt.response.TokenResponse; +import com.clova.anifriends.domain.auth.dto.response.CustomClaims; +import com.clova.anifriends.domain.auth.dto.response.TokenResponse; public interface JwtProvider { diff --git a/src/main/java/com/clova/anifriends/domain/auth/service/AuthService.java b/src/main/java/com/clova/anifriends/domain/auth/service/AuthService.java index 5bc7673d4..603400dfc 100644 --- a/src/main/java/com/clova/anifriends/domain/auth/service/AuthService.java +++ b/src/main/java/com/clova/anifriends/domain/auth/service/AuthService.java @@ -7,7 +7,7 @@ import com.clova.anifriends.domain.auth.exception.AuthNotFoundException; import com.clova.anifriends.domain.auth.jwt.JwtProvider; import com.clova.anifriends.domain.auth.jwt.UserRole; -import com.clova.anifriends.domain.auth.jwt.response.TokenResponse; +import com.clova.anifriends.domain.auth.dto.response.TokenResponse; import com.clova.anifriends.domain.auth.repository.RefreshTokenRepository; import com.clova.anifriends.domain.shelter.Shelter; import com.clova.anifriends.domain.shelter.repository.ShelterRepository; diff --git a/src/main/java/com/clova/anifriends/domain/recruitment/controller/RecruitmentController.java b/src/main/java/com/clova/anifriends/domain/recruitment/controller/RecruitmentController.java index 8f637ed83..4e4a0a8ff 100644 --- a/src/main/java/com/clova/anifriends/domain/recruitment/controller/RecruitmentController.java +++ b/src/main/java/com/clova/anifriends/domain/recruitment/controller/RecruitmentController.java @@ -1,6 +1,6 @@ package com.clova.anifriends.domain.recruitment.controller; -import com.clova.anifriends.domain.auth.resolver.LoginUser; +import com.clova.anifriends.domain.auth.LoginUser; import com.clova.anifriends.domain.recruitment.dto.request.FindRecruitmentsByShelterRequest; import com.clova.anifriends.domain.recruitment.dto.request.FindRecruitmentsByVolunteerRequest; import com.clova.anifriends.domain.recruitment.dto.request.RegisterRecruitmentRequest; diff --git a/src/main/java/com/clova/anifriends/domain/review/controller/ReviewController.java b/src/main/java/com/clova/anifriends/domain/review/controller/ReviewController.java index fe8a4e258..50eb30af4 100644 --- a/src/main/java/com/clova/anifriends/domain/review/controller/ReviewController.java +++ b/src/main/java/com/clova/anifriends/domain/review/controller/ReviewController.java @@ -1,6 +1,6 @@ package com.clova.anifriends.domain.review.controller; -import com.clova.anifriends.domain.auth.resolver.LoginUser; +import com.clova.anifriends.domain.auth.LoginUser; import com.clova.anifriends.domain.review.dto.request.RegisterReviewRequest; import com.clova.anifriends.domain.review.dto.response.FindReviewResponse; import com.clova.anifriends.domain.review.dto.response.FindShelterReviewsByVolunteerResponse; diff --git a/src/main/java/com/clova/anifriends/domain/shelter/controller/ShelterController.java b/src/main/java/com/clova/anifriends/domain/shelter/controller/ShelterController.java index 8a7755663..2a8dd699b 100644 --- a/src/main/java/com/clova/anifriends/domain/shelter/controller/ShelterController.java +++ b/src/main/java/com/clova/anifriends/domain/shelter/controller/ShelterController.java @@ -1,6 +1,6 @@ package com.clova.anifriends.domain.shelter.controller; -import com.clova.anifriends.domain.auth.resolver.LoginUser; +import com.clova.anifriends.domain.auth.LoginUser; import com.clova.anifriends.domain.shelter.dto.CheckDuplicateShelterEmailRequest; import com.clova.anifriends.domain.shelter.dto.CheckDuplicateShelterResponse; import com.clova.anifriends.domain.shelter.dto.FindShelterDetailResponse; diff --git a/src/main/java/com/clova/anifriends/domain/volunteer/controller/VolunteerController.java b/src/main/java/com/clova/anifriends/domain/volunteer/controller/VolunteerController.java index d81b8e3ad..5b6ad8547 100644 --- a/src/main/java/com/clova/anifriends/domain/volunteer/controller/VolunteerController.java +++ b/src/main/java/com/clova/anifriends/domain/volunteer/controller/VolunteerController.java @@ -1,6 +1,6 @@ package com.clova.anifriends.domain.volunteer.controller; -import com.clova.anifriends.domain.auth.resolver.LoginUser; +import com.clova.anifriends.domain.auth.LoginUser; import com.clova.anifriends.domain.volunteer.dto.request.CheckDuplicateVolunteerEmailRequest; import com.clova.anifriends.domain.volunteer.dto.request.RegisterVolunteerRequest; import com.clova.anifriends.domain.volunteer.dto.response.CheckDuplicateVolunteerEmailResponse; diff --git a/src/main/java/com/clova/anifriends/global/config/SecurityConfig.java b/src/main/java/com/clova/anifriends/global/config/SecurityConfig.java index 2e5f8689d..61674a3ad 100644 --- a/src/main/java/com/clova/anifriends/global/config/SecurityConfig.java +++ b/src/main/java/com/clova/anifriends/global/config/SecurityConfig.java @@ -1,7 +1,7 @@ package com.clova.anifriends.global.config; import com.clova.anifriends.domain.auth.authentication.JwtAuthenticationProvider; -import com.clova.anifriends.domain.auth.filter.JwtAuthenticationFilter; +import com.clova.anifriends.global.web.filter.JwtAuthenticationFilter; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpMethod; diff --git a/src/main/java/com/clova/anifriends/global/config/WebMvcConfig.java b/src/main/java/com/clova/anifriends/global/config/WebMvcConfig.java index 761bf7ed9..d6cbc8862 100644 --- a/src/main/java/com/clova/anifriends/global/config/WebMvcConfig.java +++ b/src/main/java/com/clova/anifriends/global/config/WebMvcConfig.java @@ -1,6 +1,6 @@ package com.clova.anifriends.global.config; -import com.clova.anifriends.domain.auth.resolver.LoginUserArgumentResolver; +import com.clova.anifriends.global.web.argumentresolver.LoginUserArgumentResolver; import java.util.List; import org.springframework.context.annotation.Configuration; import org.springframework.web.method.support.HandlerMethodArgumentResolver; diff --git a/src/main/java/com/clova/anifriends/domain/auth/jwt/JJwtProvider.java b/src/main/java/com/clova/anifriends/global/jwt/JJwtProvider.java similarity index 91% rename from src/main/java/com/clova/anifriends/domain/auth/jwt/JJwtProvider.java rename to src/main/java/com/clova/anifriends/global/jwt/JJwtProvider.java index 30654734d..9a4e918d5 100644 --- a/src/main/java/com/clova/anifriends/domain/auth/jwt/JJwtProvider.java +++ b/src/main/java/com/clova/anifriends/global/jwt/JJwtProvider.java @@ -1,11 +1,12 @@ -package com.clova.anifriends.domain.auth.jwt; +package com.clova.anifriends.global.jwt; +import com.clova.anifriends.domain.auth.dto.response.CustomClaims; +import com.clova.anifriends.domain.auth.dto.response.TokenResponse; import com.clova.anifriends.domain.auth.exception.ExpiredAccessTokenException; -import com.clova.anifriends.domain.auth.exception.InvalidJwtException; import com.clova.anifriends.domain.auth.exception.ExpiredRefreshTokenException; -import com.clova.anifriends.domain.auth.jwt.response.CustomClaims; -import com.clova.anifriends.domain.auth.jwt.response.TokenResponse; -import com.clova.anifriends.global.exception.ErrorCode; +import com.clova.anifriends.domain.auth.exception.InvalidJwtException; +import com.clova.anifriends.domain.auth.jwt.JwtProvider; +import com.clova.anifriends.domain.auth.jwt.UserRole; import io.jsonwebtoken.Claims; import io.jsonwebtoken.ExpiredJwtException; import io.jsonwebtoken.JwtException; @@ -101,7 +102,7 @@ public CustomClaims parseAccessToken(String token) { } catch (JwtException ex) { log.info("[EX] {}: 잘못된 JWT입니다.", ex.getClass().getSimpleName()); } - throw new InvalidJwtException(ErrorCode.UN_AUTHENTICATION, "유효하지 않은 JWT입니다."); + throw new InvalidJwtException("유효하지 않은 JWT입니다."); } @Override @@ -117,6 +118,6 @@ public TokenResponse refreshAccessToken(String refreshToken) { } catch (JwtException ex) { log.info("[EX] {}: 잘못된 리프레시 토큰입니다.", ex.getClass().getSimpleName()); } - throw new InvalidJwtException(ErrorCode.UN_AUTHENTICATION, "유효하지 않은 리프레시 토큰입니다."); + throw new InvalidJwtException("유효하지 않은 리프레시 토큰입니다."); } } diff --git a/src/main/java/com/clova/anifriends/domain/auth/resolver/LoginUserArgumentResolver.java b/src/main/java/com/clova/anifriends/global/web/argumentresolver/LoginUserArgumentResolver.java similarity index 94% rename from src/main/java/com/clova/anifriends/domain/auth/resolver/LoginUserArgumentResolver.java rename to src/main/java/com/clova/anifriends/global/web/argumentresolver/LoginUserArgumentResolver.java index 61489dab3..bc29b6147 100644 --- a/src/main/java/com/clova/anifriends/domain/auth/resolver/LoginUserArgumentResolver.java +++ b/src/main/java/com/clova/anifriends/global/web/argumentresolver/LoginUserArgumentResolver.java @@ -1,9 +1,10 @@ -package com.clova.anifriends.domain.auth.resolver; +package com.clova.anifriends.global.web.argumentresolver; import static com.clova.anifriends.global.exception.ErrorCode.UN_AUTHENTICATION; import com.clova.anifriends.domain.auth.authentication.JwtAuthentication; import com.clova.anifriends.domain.auth.exception.AuthAuthenticationException; +import com.clova.anifriends.domain.auth.LoginUser; import java.util.Objects; import org.springframework.core.MethodParameter; import org.springframework.security.core.Authentication; diff --git a/src/main/java/com/clova/anifriends/domain/auth/filter/JwtAuthenticationFilter.java b/src/main/java/com/clova/anifriends/global/web/filter/JwtAuthenticationFilter.java similarity index 60% rename from src/main/java/com/clova/anifriends/domain/auth/filter/JwtAuthenticationFilter.java rename to src/main/java/com/clova/anifriends/global/web/filter/JwtAuthenticationFilter.java index 43d7a3f25..72c609f27 100644 --- a/src/main/java/com/clova/anifriends/domain/auth/filter/JwtAuthenticationFilter.java +++ b/src/main/java/com/clova/anifriends/global/web/filter/JwtAuthenticationFilter.java @@ -1,6 +1,7 @@ -package com.clova.anifriends.domain.auth.filter; +package com.clova.anifriends.global.web.filter; import com.clova.anifriends.domain.auth.authentication.JwtAuthenticationProvider; +import com.clova.anifriends.domain.auth.exception.InvalidJwtException; import jakarta.servlet.FilterChain; import jakarta.servlet.GenericFilter; import jakarta.servlet.ServletException; @@ -17,17 +18,30 @@ public class JwtAuthenticationFilter extends GenericFilter { private static final String HEADER = "Authorization"; + private static final String BEARER = "Bearer "; private final JwtAuthenticationProvider authenticationProvider; @Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; - String accessToken = request.getHeader(HEADER); - if (Objects.nonNull(accessToken)) { + String bearerAccessToken = request.getHeader(HEADER); + if (Objects.nonNull(bearerAccessToken)) { + String accessToken = removeBearer(bearerAccessToken); Authentication authentication = authenticationProvider.authenticate(accessToken); SecurityContextHolder.getContext().setAuthentication(authentication); } chain.doFilter(req, res); } + + private String removeBearer(String bearerAccessToken) { + checkTokenContainsBearer(bearerAccessToken); + return bearerAccessToken.replace(BEARER, ""); + } + + private static void checkTokenContainsBearer(String bearerAccessToken) { + if(!bearerAccessToken.contains(BEARER)) { + throw new InvalidJwtException("올바르지 않는 액세스 토큰 형식입니다."); + } + } } diff --git a/src/test/java/com/clova/anifriends/domain/auth/authentication/JwtAuthenticationProviderTest.java b/src/test/java/com/clova/anifriends/domain/auth/authentication/JwtAuthenticationProviderTest.java index 6b64abf8a..31494952f 100644 --- a/src/test/java/com/clova/anifriends/domain/auth/authentication/JwtAuthenticationProviderTest.java +++ b/src/test/java/com/clova/anifriends/domain/auth/authentication/JwtAuthenticationProviderTest.java @@ -4,7 +4,7 @@ import com.clova.anifriends.domain.auth.jwt.JwtProvider; import com.clova.anifriends.domain.auth.jwt.UserRole; -import com.clova.anifriends.domain.auth.jwt.response.TokenResponse; +import com.clova.anifriends.domain.auth.dto.response.TokenResponse; import com.clova.anifriends.domain.auth.support.AuthFixture; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; diff --git a/src/test/java/com/clova/anifriends/domain/auth/controller/AuthControllerTest.java b/src/test/java/com/clova/anifriends/domain/auth/controller/AuthControllerTest.java index 548c5fcff..96a1c5366 100644 --- a/src/test/java/com/clova/anifriends/domain/auth/controller/AuthControllerTest.java +++ b/src/test/java/com/clova/anifriends/domain/auth/controller/AuthControllerTest.java @@ -15,9 +15,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import com.clova.anifriends.base.BaseControllerTest; -import com.clova.anifriends.domain.auth.controller.request.LoginRequest; +import com.clova.anifriends.domain.auth.dto.request.LoginRequest; import com.clova.anifriends.domain.auth.jwt.UserRole; -import com.clova.anifriends.domain.auth.jwt.response.TokenResponse; +import com.clova.anifriends.domain.auth.dto.response.TokenResponse; import com.clova.anifriends.domain.auth.support.AuthFixture; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -65,7 +65,7 @@ void volunteerLogin() throws Exception { void shelterLogin() throws Exception { //given LoginRequest request = new LoginRequest("email@email.com", "password123!"); - TokenResponse response = new TokenResponse(1L, UserRole.ROLE_VOLUNTEER, "accessToken", + TokenResponse response = new TokenResponse(1L, UserRole.ROLE_SHELTER, "accessToken", "refreshToken"); given(authService.shelterLogin(any(), any())).willReturn(response); diff --git a/src/test/java/com/clova/anifriends/domain/auth/filter/JwtAuthenticationFilterTest.java b/src/test/java/com/clova/anifriends/domain/auth/filter/JwtAuthenticationFilterTest.java index a0a8d0ce2..4d2c15380 100644 --- a/src/test/java/com/clova/anifriends/domain/auth/filter/JwtAuthenticationFilterTest.java +++ b/src/test/java/com/clova/anifriends/domain/auth/filter/JwtAuthenticationFilterTest.java @@ -1,14 +1,15 @@ package com.clova.anifriends.domain.auth.filter; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.catchException; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.then; import com.clova.anifriends.domain.auth.authentication.JwtAuthenticationProvider; +import com.clova.anifriends.domain.auth.exception.InvalidJwtException; import com.clova.anifriends.domain.auth.jwt.JwtProvider; -import com.clova.anifriends.domain.auth.jwt.UserRole; -import com.clova.anifriends.domain.auth.jwt.response.TokenResponse; import com.clova.anifriends.domain.auth.support.AuthFixture; +import com.clova.anifriends.global.web.filter.JwtAuthenticationFilter; import jakarta.servlet.FilterChain; import jakarta.servlet.ServletException; import java.io.IOException; @@ -57,8 +58,7 @@ void doFilter() throws ServletException, IOException { @DisplayName("성공: 액세스 토큰이 요청에 포함된 경우") void doFilterWhenContainsToken() throws ServletException, IOException { //given - TokenResponse tokenResponse = jwtProvider.createToken(1L, UserRole.ROLE_VOLUNTEER); - String accessToken = tokenResponse.accessToken(); + String accessToken = AuthFixture.shelterAccessToken(); mockRequest.addHeader("Authorization", accessToken); //when @@ -80,5 +80,21 @@ void doFilterWhenNotContainsToken() throws ServletException, IOException { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); assertThat(authentication).isNull(); } + + @Test + @DisplayName("예외: 액세스 토큰이 Bearer 형식이 아닌 경우") + void exceptionWhenTokenIsNotBearer() { + //given + String bearerAccessToken = AuthFixture.volunteerAccessToken(); + String accessToken = bearerAccessToken.replace("Bearer ", ""); + mockRequest.addHeader("Authorization", accessToken); + + //when + Exception exception = catchException( + () -> jwtAuthenticationFilter.doFilter(mockRequest, mockResponse, filterChain)); + + //then + assertThat(exception).isInstanceOf(InvalidJwtException.class); + } } } diff --git a/src/test/java/com/clova/anifriends/domain/auth/jwt/JJwtProviderTest.java b/src/test/java/com/clova/anifriends/domain/auth/jwt/JJwtProviderTest.java index 2486bbaf6..e12150df1 100644 --- a/src/test/java/com/clova/anifriends/domain/auth/jwt/JJwtProviderTest.java +++ b/src/test/java/com/clova/anifriends/domain/auth/jwt/JJwtProviderTest.java @@ -7,9 +7,10 @@ import com.clova.anifriends.domain.auth.exception.ExpiredAccessTokenException; import com.clova.anifriends.domain.auth.exception.ExpiredRefreshTokenException; import com.clova.anifriends.domain.auth.exception.InvalidJwtException; -import com.clova.anifriends.domain.auth.jwt.response.CustomClaims; -import com.clova.anifriends.domain.auth.jwt.response.TokenResponse; +import com.clova.anifriends.domain.auth.dto.response.CustomClaims; +import com.clova.anifriends.domain.auth.dto.response.TokenResponse; import com.clova.anifriends.domain.auth.support.AuthFixture; +import com.clova.anifriends.global.jwt.JJwtProvider; import java.util.List; import java.util.concurrent.TimeUnit; import org.awaitility.core.ThrowingRunnable; diff --git a/src/test/java/com/clova/anifriends/domain/auth/resolver/LoginUserTestController.java b/src/test/java/com/clova/anifriends/domain/auth/resolver/LoginUserTestController.java index 78d270b4d..b127775a3 100644 --- a/src/test/java/com/clova/anifriends/domain/auth/resolver/LoginUserTestController.java +++ b/src/test/java/com/clova/anifriends/domain/auth/resolver/LoginUserTestController.java @@ -1,5 +1,6 @@ package com.clova.anifriends.domain.auth.resolver; +import com.clova.anifriends.domain.auth.LoginUser; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/src/test/java/com/clova/anifriends/domain/auth/service/AuthServiceTest.java b/src/test/java/com/clova/anifriends/domain/auth/service/AuthServiceTest.java index ca25c1a56..2d1daf313 100644 --- a/src/test/java/com/clova/anifriends/domain/auth/service/AuthServiceTest.java +++ b/src/test/java/com/clova/anifriends/domain/auth/service/AuthServiceTest.java @@ -12,7 +12,7 @@ import com.clova.anifriends.domain.auth.exception.AuthNotFoundException; import com.clova.anifriends.domain.auth.jwt.JwtProvider; import com.clova.anifriends.domain.auth.jwt.UserRole; -import com.clova.anifriends.domain.auth.jwt.response.TokenResponse; +import com.clova.anifriends.domain.auth.dto.response.TokenResponse; import com.clova.anifriends.domain.auth.repository.RefreshTokenRepository; import com.clova.anifriends.domain.auth.support.AuthFixture; import com.clova.anifriends.domain.auth.support.MockPasswordEncode; diff --git a/src/test/java/com/clova/anifriends/domain/auth/support/AuthFixture.java b/src/test/java/com/clova/anifriends/domain/auth/support/AuthFixture.java index 7e15e0dfb..73075ec44 100644 --- a/src/test/java/com/clova/anifriends/domain/auth/support/AuthFixture.java +++ b/src/test/java/com/clova/anifriends/domain/auth/support/AuthFixture.java @@ -1,9 +1,9 @@ package com.clova.anifriends.domain.auth.support; -import com.clova.anifriends.domain.auth.jwt.JJwtProvider; +import com.clova.anifriends.global.jwt.JJwtProvider; import com.clova.anifriends.domain.auth.jwt.JwtProvider; import com.clova.anifriends.domain.auth.jwt.UserRole; -import com.clova.anifriends.domain.auth.jwt.response.TokenResponse; +import com.clova.anifriends.domain.auth.dto.response.TokenResponse; public final class AuthFixture { @@ -14,6 +14,7 @@ public final class AuthFixture { private static final String TEST_REFRESH_SECRET = "~GWW.|?:\"#Rqmm^-nk#>#4Ngc}]3xz!hOQCXNF:8z-Mdn\"U!Vt Date: Wed, 8 Nov 2023 23:38:09 +0900 Subject: [PATCH 2/2] =?UTF-8?q?refactor:=20=EB=B3=B4=ED=98=B8=EC=86=8C?= =?UTF-8?q?=EC=97=90=20=EB=8B=AC=EB=A6=B0=20=ED=9B=84=EA=B8=B0=20=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=A1=B0=ED=9A=8C(=EB=B3=B4=ED=98=B8?= =?UTF-8?q?=EC=86=8C)=EB=A5=BC=20=EB=AA=85=EC=84=B8=EC=97=90=20=EB=A7=9E?= =?UTF-8?q?=EA=B2=8C=20=EC=88=98=EC=A0=95=ED=95=9C=EB=8B=A4.=20(#163)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: 보호소의 후기 리스트 조회(보호소) api 응답을 명세에 맞게 수정한다. * docs: 보호소의 후기 리스트 조회(보호소) api를 문서화한다. --- src/docs/asciidoc/index.adoc | 8 + .../review/controller/ReviewController.java | 7 +- ... FindShelterReviewsByShelterResponse.java} | 15 +- .../domain/review/service/ReviewService.java | 11 +- src/main/resources/static/docs/index.html | 3119 +++++++++-------- .../controller/ReviewControllerTest.java | 14 +- .../review/service/ReviewServiceTest.java | 14 +- 7 files changed, 1792 insertions(+), 1396 deletions(-) rename src/main/java/com/clova/anifriends/domain/review/dto/response/{FindShelterReviewsResponse.java => FindShelterReviewsByShelterResponse.java} (77%) diff --git a/src/docs/asciidoc/index.adoc b/src/docs/asciidoc/index.adoc index ea5ad864d..328d3f39f 100644 --- a/src/docs/asciidoc/index.adoc +++ b/src/docs/asciidoc/index.adoc @@ -99,6 +99,14 @@ operation::recruitment-controller-test/register-recruitment[snippets='http-respo == 5. 봉사 후기 +=== 보호소의 후기 리스트 조회 + +==== Request +operation::review-controller-test/find-shelter-reviews-by-shelter[snippets='http-request,request-headers,path-parameters,query-parameters'] + +==== Response +operation::review-controller-test/find-shelter-reviews-by-shelter[snippets='http-response,response-fields'] + == 6. 보호 동물 = 봉사자 diff --git a/src/main/java/com/clova/anifriends/domain/review/controller/ReviewController.java b/src/main/java/com/clova/anifriends/domain/review/controller/ReviewController.java index 50eb30af4..5bd91f4da 100644 --- a/src/main/java/com/clova/anifriends/domain/review/controller/ReviewController.java +++ b/src/main/java/com/clova/anifriends/domain/review/controller/ReviewController.java @@ -4,7 +4,7 @@ import com.clova.anifriends.domain.review.dto.request.RegisterReviewRequest; import com.clova.anifriends.domain.review.dto.response.FindReviewResponse; import com.clova.anifriends.domain.review.dto.response.FindShelterReviewsByVolunteerResponse; -import com.clova.anifriends.domain.review.dto.response.FindShelterReviewsResponse; +import com.clova.anifriends.domain.review.dto.response.FindShelterReviewsByShelterResponse; import com.clova.anifriends.domain.review.dto.response.FindVolunteerReviewsResponse; import com.clova.anifriends.domain.review.service.ReviewService; import java.net.URI; @@ -44,10 +44,11 @@ public ResponseEntity registerReview( } @GetMapping("/shelters/{shelterId}/reviews") - public ResponseEntity findShelterReviews( + public ResponseEntity findShelterReviewsByShelter( @PathVariable("shelterId") Long shelterId, Pageable pageable) { - FindShelterReviewsResponse response = reviewService.findShelterReviews(shelterId, pageable); + FindShelterReviewsByShelterResponse response + = reviewService.findShelterReviewsByShelter(shelterId, pageable); return ResponseEntity.ok(response); } diff --git a/src/main/java/com/clova/anifriends/domain/review/dto/response/FindShelterReviewsResponse.java b/src/main/java/com/clova/anifriends/domain/review/dto/response/FindShelterReviewsByShelterResponse.java similarity index 77% rename from src/main/java/com/clova/anifriends/domain/review/dto/response/FindShelterReviewsResponse.java rename to src/main/java/com/clova/anifriends/domain/review/dto/response/FindShelterReviewsByShelterResponse.java index 8b228da96..d018acdd6 100644 --- a/src/main/java/com/clova/anifriends/domain/review/dto/response/FindShelterReviewsResponse.java +++ b/src/main/java/com/clova/anifriends/domain/review/dto/response/FindShelterReviewsByShelterResponse.java @@ -7,17 +7,18 @@ import java.util.List; import org.springframework.data.domain.Page; -public record FindShelterReviewsResponse(List reviews, - PageInfo pageInfo) { +public record FindShelterReviewsByShelterResponse( + List reviews, + PageInfo pageInfo) { public record FindShelterReviewResponse( Long reviewId, - LocalDateTime createdAt, - String content, + LocalDateTime reviewCreatedAt, + String reviewContent, List reviewImageUrls, String volunteerName, - int temperature, + int volunteerTemperature, String volunteerImageUrl, long VolunteerReviewCount) { @@ -36,11 +37,11 @@ public static FindShelterReviewResponse from(Review review) { } } - public static FindShelterReviewsResponse from(Page reviewPage) { + public static FindShelterReviewsByShelterResponse from(Page reviewPage) { PageInfo pageInfo = PageInfo.of(reviewPage.getTotalElements(), reviewPage.hasNext()); List reviews = reviewPage .map(FindShelterReviewResponse::from) .stream().toList(); - return new FindShelterReviewsResponse(reviews, pageInfo); + return new FindShelterReviewsByShelterResponse(reviews, pageInfo); } } diff --git a/src/main/java/com/clova/anifriends/domain/review/service/ReviewService.java b/src/main/java/com/clova/anifriends/domain/review/service/ReviewService.java index 54ba68368..f6cd83793 100644 --- a/src/main/java/com/clova/anifriends/domain/review/service/ReviewService.java +++ b/src/main/java/com/clova/anifriends/domain/review/service/ReviewService.java @@ -6,7 +6,7 @@ import com.clova.anifriends.domain.review.Review; import com.clova.anifriends.domain.review.dto.response.FindReviewResponse; import com.clova.anifriends.domain.review.dto.response.FindShelterReviewsByVolunteerResponse; -import com.clova.anifriends.domain.review.dto.response.FindShelterReviewsResponse; +import com.clova.anifriends.domain.review.dto.response.FindShelterReviewsByShelterResponse; import com.clova.anifriends.domain.review.dto.response.FindVolunteerReviewsResponse; import com.clova.anifriends.domain.review.exception.ApplicantNotFoundException; import com.clova.anifriends.domain.review.exception.ReviewBadRequestException; @@ -37,10 +37,11 @@ private Review getReview(Long userId, Long reviewId) { } @Transactional(readOnly = true) - public FindShelterReviewsResponse findShelterReviews(Long shelterId, Pageable pageable) { - Page reviewPage - = reviewRepository.findAllByShelterId(shelterId, pageable); - return FindShelterReviewsResponse.from(reviewPage); + public FindShelterReviewsByShelterResponse findShelterReviewsByShelter( + Long shelterId, + Pageable pageable) { + Page reviewPage = reviewRepository.findAllByShelterId(shelterId, pageable); + return FindShelterReviewsByShelterResponse.from(reviewPage); } @Transactional diff --git a/src/main/resources/static/docs/index.html b/src/main/resources/static/docs/index.html index 6397022b7..0c5feafae 100644 --- a/src/main/resources/static/docs/index.html +++ b/src/main/resources/static/docs/index.html @@ -1,593 +1,598 @@ - - - - - API 문서 - - - + + + + +API 문서 + + +
-

공통 권한

-
-

0. 인증

-
+

공통 권한

+
+

0. 인증

+
-
-
-
-

1. 봉사자

-
-
-

봉사자가 완료한 봉사 모집글 리스트 조회

-
-

Request

-
-
HTTP request
-
-
+
+
+
+

1. 봉사자

+
+
+

봉사자가 완료한 봉사 모집글 리스트 조회

+
+

Request

+
+
HTTP request
+
+
GET /api/volunteers/1/recruitments/completed?pageNumber=0&pageSize=10 HTTP/1.1
-X-CSRF-TOKEN: SiYfXSGFaZOJPEgcpof4iiM5-8WM1fmKtCyfjOHW56AO1mD8fkN-aULkDKOkBHp6wqrMvBIP1qe84Minhhym74KygcY_4gPI
+X-CSRF-TOKEN: tw9kn4U5vGCJCaHv8M-VQqN4OywKgBECX6D_746S3SeGYHhqgjpQ-bcP2FikO5nWkeKhJ5FKFhVo4Sgvb5ScibzzuUSzUk4M
 Host: localhost:8080
-
-
-
-
-
Path parameters
- - - - - - - - - - - - - - - - - - -
Table 1. /api/volunteers/{volunteerId}/recruitments/completed
ParameterDescription

volunteerId

봉사자 ID

-
-
-
Query parameters
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
필드명필수값제약설명

pageNumber

true

페이지 번호

pageSize

true

페이지 사이즈

-
-
-
-

Response

-
-
HTTP response
-
-
+
+
+
+
+
Path parameters
+ + ++++ + + + + + + + + + + + + +
Table 1. /api/volunteers/{volunteerId}/recruitments/completed
ParameterDescription

volunteerId

봉사자 ID

+
+
+
Query parameters
+ ++++++ + + + + + + + + + + + + + + + + + + + + + + +
필드명필수값제약설명

pageNumber

true

페이지 번호

pageSize

true

페이지 사이즈

+
+
+
+

Response

+
+
HTTP response
+
+
HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
 X-Content-Type-Options: nosniff
@@ -601,7 +606,7 @@ 
-
-
-
-
-
Response fields
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PathTypeDescription

recruitments

Array

봉사 모집글 리스트

recruitments[].recruitmentId

Number

봉사 모집글 ID

recruitments[].recruitmentTitle

String

봉사 모집글 제목

recruitments[].recruitmentStartTime

String

봉사 날짜

recruitments[].shelterName

String

보호소 이름

pageInfo

Object

페이지 정보

pageInfo.totalElements

Number

총 요소 개수

pageInfo.hasNext

Boolean

다음 페이지 여부

-
-
-
-
-
-
-

보호 동물

-
-
-

보호 동물 상세 조회

-
-

Request

-
-
HTTP request
-
-
+
+
+
+
+
Response fields
+ +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PathTypeDescription

recruitments

Array

봉사 모집글 리스트

recruitments[].recruitmentId

Number

봉사 모집글 ID

recruitments[].recruitmentTitle

String

봉사 모집글 제목

recruitments[].recruitmentStartTime

String

봉사 날짜

recruitments[].shelterName

String

보호소 이름

pageInfo

Object

페이지 정보

pageInfo.totalElements

Number

총 요소 개수

pageInfo.hasNext

Boolean

다음 페이지 여부

+
+
+
+
+
+
+

보호 동물

+
+
+

보호 동물 상세 조회

+
+

Request

+
+
HTTP request
+
+
GET /api/animals/1 HTTP/1.1
 Content-Type: application/json;charset=UTF-8
-Authorization: eyJhbGciOiJIUzM4NCJ9.eyJpc3MiOiJpc3N1ZXIiLCJpYXQiOjE2OTk0MzAyOTAsInN1YiI6IjEiLCJleHAiOjE2OTk0MzEyOTAsInJvbGUiOiJST0xFX1ZPTFVOVEVFUiJ9.uwCVMszrCNj-7VmcVsTx49DLvLsoKzdsjgfR8kKtdpZlmhV2M4TvoJSWY5yoxic6
-X-CSRF-TOKEN: 5h8uAxGXg_djONGejPe8yBbq2MYs8tzQkFFk8cvPQSrzLUwb0ScaNymm5pVOW-muv9qIrHLf9f8bx7j9pjJWk_j6dRiQHil_
+Authorization: eyJhbGciOiJIUzM4NCJ9.eyJpc3MiOiJpc3N1ZXIiLCJpYXQiOjE2OTk0MzYyNDIsInN1YiI6IjEiLCJleHAiOjE2OTk0MzcyNDIsInJvbGUiOiJST0xFX1ZPTFVOVEVFUiJ9.BgdJ7CFunj47tDrEBrZJwcObNvosB5NlIiSfGmgEU3QbIkLAG6gNWDa1JWJWs1Oo
+X-CSRF-TOKEN: CfwHkJDvQdj5l8MzItsDejNqSv-HtjW-CjIfTxyq_rOCVN6DMcpmofXWdLnU8vYGQ_Y3TwRaZ57jjgSTawIsfS-cnIO2Nrq3
 Host: localhost:8080
-
-
-
-
-
Path parameters
- - - - - - - - - - - - - - - - - - -
Table 1. /api/animals/{animalId}
ParameterDescription

animalId

보호 동물 ID

-
-
-
-

Response

-
-
HTTP response
-
-
+
+
+
+
+
Path parameters
+ + ++++ + + + + + + + + + + + + +
Table 1. /api/animals/{animalId}
ParameterDescription

animalId

보호 동물 ID

+
+
+
+

Response

+
+
HTTP response
+
+
HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
 X-Content-Type-Options: nosniff
@@ -746,214 +751,214 @@ 
-
-
-
-
-
Response fields
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PathTypeDescription

animalId

Number

보호 동물 ID

animalName

String

보호 동물 이름

animalBirthDate

String

보호 동물 출생 날짜

animalType

String

보호 동물 종류

animalBreed

String

보호 동물 품종

animalGender

String

보호 동물 성별

animalIsNeutered

Boolean

보호 동물 중성화 유무

animalActive

String

보호 동물 활동성

animalWeight

Number

보호 동물 몸무게

animalInformation

String

보호 동물 기타 정보

animalImageUrls[]

Array

보호 동물 이미지 url 리스트

animalIsAdopted

Boolean

보호 동물 입양 여부

-
-
-
-
-
-

보호소

-
-

1. 봉사자

-
-
-

1) 봉사 모집글 조회 & 검색

-
-

Request

-
-
HTTP request
-
-
+
+
+
+
+
Response fields
+ +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PathTypeDescription

animalId

Number

보호 동물 ID

animalName

String

보호 동물 이름

animalBirthDate

String

보호 동물 출생 날짜

animalType

String

보호 동물 종류

animalBreed

String

보호 동물 품종

animalGender

String

보호 동물 성별

animalIsNeutered

Boolean

보호 동물 중성화 유무

animalActive

String

보호 동물 활동성

animalWeight

Number

보호 동물 몸무게

animalInformation

String

보호 동물 기타 정보

animalImageUrls[]

Array

보호 동물 이미지 url 리스트

animalIsAdopted

Boolean

보호 동물 입양 여부

+
+
+
+
+
+

보호소

+
+

1. 봉사자

+
+
+

1) 봉사 모집글 조회 & 검색

+
+

Request

+
+
HTTP request
+
+
GET /api/volunteers/recruitments?keyword=%EA%B2%85%EC%83%89%EC%96%B4&startDate=2023-11-08&endDate=2023-11-08&isClosed=false&title=true&content=false&shelterName=false&pageNumber=0&pageSize=10 HTTP/1.1
-Authorization: eyJhbGciOiJIUzM4NCJ9.eyJpc3MiOiJpc3N1ZXIiLCJpYXQiOjE2OTk0MzAyOTQsInN1YiI6IjEiLCJleHAiOjE2OTk0MzEyOTQsInJvbGUiOiJST0xFX1ZPTFVOVEVFUiJ9.eGIhqzJd5gvxPOAPtRplNR6czR0QHCs0XC_KCSzefiP_5w5hJTmn6UgfkIjbXl2t
-X-CSRF-TOKEN: aNQE1Xiq-QllNnvDyOYwYlo70BHFQ98ew2EYG3qffJr7UqXGW7Fh4xnIyztIBU738MsEVT4L_SihJe4z-wB6KU6uTv7Dap3z
+Authorization: eyJhbGciOiJIUzM4NCJ9.eyJpc3MiOiJpc3N1ZXIiLCJpYXQiOjE2OTk0MzYyNDgsInN1YiI6IjEiLCJleHAiOjE2OTk0MzcyNDgsInJvbGUiOiJST0xFX1ZPTFVOVEVFUiJ9.Veqp0RIfytfETlrO71aWAspYC_JttgCl-ShLdpOXEyZ5xnQS3V4JpmOVGTeTkJ3o
+X-CSRF-TOKEN: HfuUojMBKwwKAbC0iKXSJPoeuW5vQnE9QK98zSgCVpzOEwuOfp-lmwMyGTonONKGsIjmHM0ulA9YJxUQI5gd-h41NKX2JGjv
 Host: localhost:8080
-
-
-
-
-
Request headers
- - - - - - - - - - - - - - - - - -
NameDescription

Authorization

봉사자 액세스 토큰

-
-
-
Query parameters
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
필드명필수값제약설명

keyword

검색어

startDate

yyyy-MM-dd

검색 시작일

endDate

yyyy-MM-dd

검색 종료일

isClosed

true, false

마감 여부

title

기본값 true

제목 포함 검색

content

기본값 true

본문 포함 검색

shelterName

기본값 true

보호소 이름 포함 검색

pageNumber

true

페이지 번호

pageSize

true

페이지 사이즈

-
-
-
-

Response

-
-
HTTP response
-
-
+
+
+
+
+
Request headers
+ ++++ + + + + + + + + + + + + +
NameDescription

Authorization

봉사자 액세스 토큰

+
+
+
Query parameters
+ ++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
필드명필수값제약설명

keyword

검색어

startDate

yyyy-MM-dd

검색 시작일

endDate

yyyy-MM-dd

검색 종료일

isClosed

true, false

마감 여부

title

기본값 true

제목 포함 검색

content

기본값 true

본문 포함 검색

shelterName

기본값 true

보호소 이름 포함 검색

pageNumber

true

페이지 번호

pageSize

true

페이지 사이즈

+
+
+
+

Response

+
+
HTTP response
+
+
HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
 X-Content-Type-Options: nosniff
@@ -967,8 +972,8 @@ 
-
-
-
-
-
Response fields
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PathTypeDescription

recruitments

Array

봉사 모집글 리스트

recruitments[].recruitmentId

Number

봉사 모집글 ID

recruitments[].recruitmentTitle

String

봉사 모집글 제목

recruitments[].recruitmentStartTime

String

봉사 시작 시간

recruitments[].recruitmentEndTime

String

봉사 종료 시간

recruitments[].recruitmentIsClosed

Boolean

봉사 모집 마감 여부

recruitments[].recruitmentApplicantCount

Number

봉사 신청 인원

recruitments[].recruitmentCapacity

Number

봉사 정원

recruitments[].shelterName

String

보호소 이름

recruitments[].shelterImageUrl

String

보호소 이미지 url

pageInfo

Object

페이지 정보

pageInfo.totalElements

Number

총 요소 개수

pageInfo.hasNext

Boolean

다음 페이지 여부

-
-
-
-
-
-
-

2. 보호소

-
+
+
+
+
+
Response fields
+ +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PathTypeDescription

recruitments

Array

봉사 모집글 리스트

recruitments[].recruitmentId

Number

봉사 모집글 ID

recruitments[].recruitmentTitle

String

봉사 모집글 제목

recruitments[].recruitmentStartTime

String

봉사 시작 시간

recruitments[].recruitmentEndTime

String

봉사 종료 시간

recruitments[].recruitmentIsClosed

Boolean

봉사 모집 마감 여부

recruitments[].recruitmentApplicantCount

Number

봉사 신청 인원

recruitments[].recruitmentCapacity

Number

봉사 정원

recruitments[].shelterName

String

보호소 이름

recruitments[].shelterImageUrl

String

보호소 이미지 url

pageInfo

Object

페이지 정보

pageInfo.totalElements

Number

총 요소 개수

pageInfo.hasNext

Boolean

다음 페이지 여부

+
+
+
+
+

보호소에 달린 후기 리스트 조회

+
+

Request

+
+
HTTP request
+
+
+
GET /api/volunteers/shelters/1/reviews?pageNumber=0&pageSize=10 HTTP/1.1
+Authorization: eyJhbGciOiJIUzM4NCJ9.eyJpc3MiOiJpc3N1ZXIiLCJpYXQiOjE2OTk0MzYyNDgsInN1YiI6IjEiLCJleHAiOjE2OTk0MzcyNDgsInJvbGUiOiJST0xFX1ZPTFVOVEVFUiJ9.Veqp0RIfytfETlrO71aWAspYC_JttgCl-ShLdpOXEyZ5xnQS3V4JpmOVGTeTkJ3o
+X-CSRF-TOKEN: gh5tXugFOxVB9c2KT7b8ygE8NLWS1Dt-PlSnwKqGs6Kq6tbAuy5cOt83D3BslKjvd5vIrjYLGYyitg1TDm2Wpp6-isGZ3LOh
+Host: localhost:8080
+
+
+
+
+
Path parameters
+ + ++++ + + + + + + + + + + + + +
Table 1. /api/volunteers/shelters/{shelterId}/reviews
ParameterDescription

shelterId

보호소 ID

+
+
+
Query parameters
+ ++++++ + + + + + + + + + + + + + + + + + + + + + + +
필드명필수값제약설명

pageNumber

true

페이지 번호

pageSize

true

페이지 사이즈

+
+
+
+

Response

+
+
HTTP response
+
+
+
HTTP/1.1 200 OK
+Content-Type: application/json;charset=UTF-8
+X-Content-Type-Options: nosniff
+X-XSS-Protection: 0
+Cache-Control: no-cache, no-store, max-age=0, must-revalidate
+Pragma: no-cache
+Expires: 0
+Content-Length: 336
+
+{
+  "reviews" : [ {
+    "reviewId" : 1,
+    "volunteerTemperature" : 36,
+    "reviewCreatedAt" : "2023-11-08T18:37:28.623979",
+    "reviewContent" : "reviewContent",
+    "volunteerEmail" : "asdf@gmail.com",
+    "reviewImageUrls" : [ "imageUrl1", "imageUrl2" ]
+  } ],
+  "pageInfo" : {
+    "totalElements" : 1,
+    "hasNext" : false
+  }
+}
+
+
+
+
+
Response fields
+ +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PathTypeDescription

reviews

Array

리뷰 리스트

reviews[].reviewId

Number

리뷰 ID

reviews[].reviewCreatedAt

String

리뷰 생성일

reviews[].reviewContent

String

리뷰 내용

reviews[].reviewImageUrls

Array

리뷰 이미지 url 리스트

reviews[].volunteerEmail

String

봉사자 이메일

reviews[].volunteerTemperature

Number

봉사자 온도

pageInfo

Object

페이지 정보

pageInfo.totalElements

Number

총 요소 개수

pageInfo.hasNext

Boolean

다음 페이지 여부

+
+
+
+
+
+
+

2. 보호소

+
-
-
-
-

3. 봉사 모집

-
-
-

1) 봉사 모집글 등록

-
-

Request

-
-
HTTP request
-
-
+
+
+
+

3. 봉사 모집

+
+
+

1) 봉사 모집글 등록

+
+

Request

+
+
HTTP request
+
+
POST /api/shelters/recruitments HTTP/1.1
 Content-Type: application/json;charset=UTF-8
-Authorization: eyJhbGciOiJIUzM4NCJ9.eyJpc3MiOiJpc3N1ZXIiLCJpYXQiOjE2OTk0MzAyOTQsInN1YiI6IjEiLCJleHAiOjE2OTk0MzEyOTQsInJvbGUiOiJST0xFX1NIRUxURVIifQ.Aq-IUCvgEieH-UP9pZs6TmpiKYyJRDKdOm9WSgF1UkAWjL1owUjmnd1gfAYz6dAX
+Authorization: eyJhbGciOiJIUzM4NCJ9.eyJpc3MiOiJpc3N1ZXIiLCJpYXQiOjE2OTk0MzYyNDgsInN1YiI6IjEiLCJleHAiOjE2OTk0MzcyNDgsInJvbGUiOiJST0xFX1NIRUxURVIifQ.XlN1zlgCSSxC95ms28vzyyau8b2ROv9iRPaVI-XuD4Q-PS54HMDERa5g7ifRyKNU
 Content-Length: 223
-X-CSRF-TOKEN: ZJzTdRvAsgaOs_6P84bKEV-rQlN3AA32_r2jGTLqbe8aj0_cAv_iEHr11zajhc_tw6v-cGqbbzISMWzbmIXFIFHYX9p_7C7p
+X-CSRF-TOKEN: _-B_5m8GE2tOEZDP3yfW7tN6JLbX9KzSrSbMQYtGuRkr9U6vmtJG110zdwljJaiquwri3-UbCdTmlZr_yB6tdbxzjXpOxCvM
 Host: localhost:8080
 
 {
   "title" : "title",
-  "startTime" : "2023-11-09T16:58:14.158667",
-  "endTime" : "2023-11-09T17:58:14.158667",
-  "deadline" : "2023-11-08T21:58:14.158667",
+  "startTime" : "2023-11-09T18:37:28.210436",
+  "endTime" : "2023-11-09T19:37:28.210436",
+  "deadline" : "2023-11-08T23:37:28.210436",
   "capacity" : 10,
   "content" : "content",
   "imageUrls" : [ ]
 }
-
-
-
-
-
Request headers
- - - - - - - - - - - - - - - - - -
NameDescription

Authorization

보호소 액세스 토큰

-
-
-
Request fields
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
필드명타입필수값제약설명

title

String

true

1자 이상, 50자 이하

봉사 모집글 제목

startTime

String

true

yyyy-MM-dd’T’HH:mm:ss

봉사 시작 시간

endTime

String

true

yyyy-MM-dd’T’HH:mm:ss

봉사 종료 시간

deadline

String

true

yyyy-MM-dd’T’HH:mm:ss

봉사 모집 마감 시간

capacity

Number

true

1명 이상, 99명 이하

봉사 모집 정원

content

String

true

1자 이상, 1000자 이하

봉사 모집글 본문

imageUrls

Array

0장 이상, 5장 이하

봉사 모집글 이미지

-
-
-
-

Response

-
-
HTTP response
-
-
+
+
+
+
+
Request headers
+ ++++ + + + + + + + + + + + + +
NameDescription

Authorization

보호소 액세스 토큰

+
+
+
Request fields
+ +++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
필드명타입필수값제약설명

title

String

true

1자 이상, 50자 이하

봉사 모집글 제목

startTime

String

true

yyyy-MM-dd’T’HH:mm:ss

봉사 시작 시간

endTime

String

true

yyyy-MM-dd’T’HH:mm:ss

봉사 종료 시간

deadline

String

true

yyyy-MM-dd’T’HH:mm:ss

봉사 모집 마감 시간

capacity

Number

true

1명 이상, 99명 이하

봉사 모집 정원

content

String

true

1자 이상, 1000자 이하

봉사 모집글 본문

imageUrls

Array

0장 이상, 5장 이하

봉사 모집글 이미지

+
+
+
+

Response

+
+
HTTP response
+
+
HTTP/1.1 201 Created
 Location: /api/recruitments/1
 X-Content-Type-Options: nosniff
@@ -1214,273 +1393,479 @@ 
-
Response headers
- - - - - - - - - - - - - - - - - -
NameDescription

Location

생성된 리소스에 대한 접근 api

-
-
-
-
-
- +
+
+
Response headers
+ ++++ + + + + + + + + + + + + +
NameDescription

Location

생성된 리소스에 대한 접근 api

+
+
+
+
+
+ - +
+

5. 봉사 후기

+
+
+

보호소의 후기 리스트 조회

+
+

Request

+
+
HTTP request
+
+
+
GET /api/shelters/1/reviews?pageNumber=0&pageSize=10 HTTP/1.1
+Authorization: eyJhbGciOiJIUzM4NCJ9.eyJpc3MiOiJpc3N1ZXIiLCJpYXQiOjE2OTk0MzYyNDgsInN1YiI6IjEiLCJleHAiOjE2OTk0MzcyNDgsInJvbGUiOiJST0xFX1NIRUxURVIifQ.XlN1zlgCSSxC95ms28vzyyau8b2ROv9iRPaVI-XuD4Q-PS54HMDERa5g7ifRyKNU
+X-CSRF-TOKEN: Gq8eMhL-m93cACMG-Zun9WHLrZhZjhG-XGdG_3mFCjWc4hNseZ8nBnfPr-nxMkFln7aTxFavgKFg7ymTPlEjy0ixOwWlhnUN
+Host: localhost:8080
+
+
+
+
+
Request headers
+ ++++ + + + + + + + + + + + + +
NameDescription

Authorization

보호소 액세스 토큰

+
+
+
Path parameters
+ + ++++ + + + + + + + + + + + + +
Table 1. /api/shelters/{shelterId}/reviews
ParameterDescription

shelterId

보호소 ID

+
+
+
Query parameters
+ ++++++ + + + + + + + + + + + + + + + + + + + + + + +
필드명필수값제약설명

pageNumber

true

페이지 번호

pageSize

true

페이지 사이즈

+
+
+
+

Response

+
+
HTTP response
+
+
+
HTTP/1.1 200 OK
+Content-Type: application/json;charset=UTF-8
+X-Content-Type-Options: nosniff
+X-XSS-Protection: 0
+Cache-Control: no-cache, no-store, max-age=0, must-revalidate
+Pragma: no-cache
+Expires: 0
+Content-Length: 401
 
-    
-
-
-

6. 보호 동물

-
+{ + "reviews" : [ { + "reviewId" : 1, + "reviewCreatedAt" : "2023-11-08T18:37:28.558638", + "reviewContent" : "reviewContent", + "reviewImageUrls" : [ "imageUrl1", "imageUrl2" ], + "volunteerName" : "김봉사", + "volunteerTemperature" : 36, + "volunteerImageUrl" : "image/url", + "VolunteerReviewCount" : 1 + } ], + "pageInfo" : { + "totalElements" : 1, + "hasNext" : false + } +} +
+
+
+
+
Response fields
+ +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PathTypeDescription

reviews

Array

리뷰 리스트

reviews[].reviewId

Number

리뷰 ID

reviews[].reviewCreatedAt

String

리뷰 생성일

reviews[].reviewContent

String

리뷰 내용

reviews[].reviewImageUrls

Array

리뷰 이미지 url 리스트

reviews[].volunteerName

String

봉사자 이름

reviews[].volunteerTemperature

Number

봉사자 온도

reviews[].volunteerImageUrl

String

봉사자 프로필 이미지 url

reviews[].VolunteerReviewCount

Number

봉사자 리뷰 수

pageInfo

Object

페이지 정보

pageInfo.totalElements

Number

총 요소 개수

pageInfo.hasNext

Boolean

다음 페이지 여부

+
+
+
+
+
+ -

봉사자

-
-

1. 봉사자

-
+
+
+

봉사자

+
+

1. 봉사자

+
-
-
-
-

2. 보호소

-
+
+
+
+

2. 보호소

+
-
-
- + - + - + - + -

Enum 문서화

-
-

1. 보호 동물 성격

-
-
-

|보호 동물 성격

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
코드코드명

QUIET

QUIET

NORMAL

NORMAL

ACTIVE

ACTIVE

VERY_ACTIVE

VERY_ACTIVE

-
-
-
-

2. 보호 동물 성별

-
-
-

|보호 동물 성별

-
- - - - - - - - - - - - - - - - - - - - - -
코드코드명

MALE

MALE

FEMALE

FEMALE

-
-
-
-

3. 보호 동물 종류

-
-
-

|보호 동물 종류

-
- - - - - - - - - - - - - - - - - - - - - - - - - -
코드코드명

DOG

DOG

CAT

CAT

ETC

ETC

-
-
-
-

4. 봉사 신청자 상태

-
-
-

|보호 동물 종류

-
- - - - - - - - - - - - - - - - - - - - - - - - - -
코드코드명

DOG

DOG

CAT

CAT

ETC

ETC

-
-
-
-

5. 봉사자 성별

-
-
-

|보호 동물 종류

-
- - - - - - - - - - - - - - - - - - - - - - - - - -
코드코드명

DOG

DOG

CAT

CAT

ETC

ETC

-
-
+
+
+

Enum 문서화

+
+

1. 보호 동물 성격

+
+
+

|보호 동물 성격

+
+ ++++ + + + + + + + + + + + + + + + + + + + + + + + + +
코드코드명

QUIET

QUIET

NORMAL

NORMAL

ACTIVE

ACTIVE

VERY_ACTIVE

VERY_ACTIVE

+
+
+
+

2. 보호 동물 성별

+
+
+

|보호 동물 성별

+
+ ++++ + + + + + + + + + + + + + + + + +
코드코드명

MALE

MALE

FEMALE

FEMALE

+
+
+
+

3. 보호 동물 종류

+
+
+

|보호 동물 종류

+
+ ++++ + + + + + + + + + + + + + + + + + + + + +
코드코드명

DOG

DOG

CAT

CAT

ETC

ETC

+
+
+
+

4. 봉사 신청자 상태

+
+
+

|보호 동물 종류

+
+ ++++ + + + + + + + + + + + + + + + + + + + + +
코드코드명

DOG

DOG

CAT

CAT

ETC

ETC

+
+
+
+

5. 봉사자 성별

+
+
+

|보호 동물 종류

+
+ ++++ + + + + + + + + + + + + + + + + + + + + +
코드코드명

DOG

DOG

CAT

CAT

ETC

ETC

+
+
\ No newline at end of file diff --git a/src/test/java/com/clova/anifriends/domain/review/controller/ReviewControllerTest.java b/src/test/java/com/clova/anifriends/domain/review/controller/ReviewControllerTest.java index 7a8a0df28..3060b6a34 100644 --- a/src/test/java/com/clova/anifriends/domain/review/controller/ReviewControllerTest.java +++ b/src/test/java/com/clova/anifriends/domain/review/controller/ReviewControllerTest.java @@ -42,7 +42,7 @@ import com.clova.anifriends.domain.review.dto.request.RegisterReviewRequest; import com.clova.anifriends.domain.review.dto.response.FindReviewResponse; import com.clova.anifriends.domain.review.dto.response.FindShelterReviewsByVolunteerResponse; -import com.clova.anifriends.domain.review.dto.response.FindShelterReviewsResponse; +import com.clova.anifriends.domain.review.dto.response.FindShelterReviewsByShelterResponse; import com.clova.anifriends.domain.review.dto.response.FindVolunteerReviewsResponse; import com.clova.anifriends.domain.shelter.Shelter; import com.clova.anifriends.domain.shelter.ShelterImage; @@ -104,7 +104,7 @@ void findReview() throws Exception { @Test @DisplayName("성공: 보호소가 받은 봉사자 리뷰 목록 조회 api 호출") - void findShelterReviews() throws Exception { + void findShelterReviewsByShelter() throws Exception { //given Long shelterId = 1L; Shelter shelter = shelter(); @@ -119,9 +119,9 @@ void findShelterReviews() throws Exception { ReflectionTestUtils.setField(review, "reviewId", 1L); ReflectionTestUtils.setField(review, "createdAt", LocalDateTime.now()); PageImpl reviewPage = new PageImpl<>(List.of(review)); - FindShelterReviewsResponse response = FindShelterReviewsResponse.from(reviewPage); + FindShelterReviewsByShelterResponse response = FindShelterReviewsByShelterResponse.from(reviewPage); - given(reviewService.findShelterReviews(anyLong(), any())).willReturn(response); + given(reviewService.findShelterReviewsByShelter(anyLong(), any())).willReturn(response); //when ResultActions resultActions @@ -146,12 +146,12 @@ void findShelterReviews() throws Exception { responseFields( fieldWithPath("reviews").type(ARRAY).description("리뷰 리스트"), fieldWithPath("reviews[].reviewId").type(NUMBER).description("리뷰 ID"), - fieldWithPath("reviews[].createdAt").type(STRING).description("리뷰 생성일"), - fieldWithPath("reviews[].content").type(STRING).description("리뷰 내용"), + fieldWithPath("reviews[].reviewCreatedAt").type(STRING).description("리뷰 생성일"), + fieldWithPath("reviews[].reviewContent").type(STRING).description("리뷰 내용"), fieldWithPath("reviews[].reviewImageUrls").type(ARRAY) .description("리뷰 이미지 url 리스트"), fieldWithPath("reviews[].volunteerName").type(STRING).description("봉사자 이름"), - fieldWithPath("reviews[].temperature").type(NUMBER).description("봉사자 온도"), + fieldWithPath("reviews[].volunteerTemperature").type(NUMBER).description("봉사자 온도"), fieldWithPath("reviews[].volunteerImageUrl").type(STRING) .description("봉사자 프로필 이미지 url"), fieldWithPath("reviews[].VolunteerReviewCount").type(NUMBER) diff --git a/src/test/java/com/clova/anifriends/domain/review/service/ReviewServiceTest.java b/src/test/java/com/clova/anifriends/domain/review/service/ReviewServiceTest.java index ecd3a889f..a328d42c5 100644 --- a/src/test/java/com/clova/anifriends/domain/review/service/ReviewServiceTest.java +++ b/src/test/java/com/clova/anifriends/domain/review/service/ReviewServiceTest.java @@ -24,7 +24,7 @@ import com.clova.anifriends.domain.review.Review; import com.clova.anifriends.domain.review.dto.response.FindReviewResponse; import com.clova.anifriends.domain.review.dto.response.FindShelterReviewsByVolunteerResponse; -import com.clova.anifriends.domain.review.dto.response.FindShelterReviewsResponse; +import com.clova.anifriends.domain.review.dto.response.FindShelterReviewsByShelterResponse; import com.clova.anifriends.domain.review.dto.response.FindVolunteerReviewsResponse; import com.clova.anifriends.domain.review.exception.ApplicantNotFoundException; import com.clova.anifriends.domain.review.exception.ReviewBadRequestException; @@ -155,12 +155,12 @@ void exceptionWhenAlreadyExistReview() { } @Nested - @DisplayName("findShelterReviews 메서드 실행 시") - class FindShelterReviewsTest { + @DisplayName("findShelterReviewsByShelter 메서드 실행 시") + class FindShelterReviewsByShelterTest { @Test @DisplayName("성공") - void findShelterReviews() { + void findShelterReviewsByShelter() { //given Long shelterId = 1L; PageRequest pageRequest = PageRequest.of(0, 10); @@ -170,14 +170,14 @@ void findShelterReviews() { Applicant applicant = applicant(recruitment, volunteer, ATTENDANCE); Review review = review(applicant); PageImpl reviewPage = new PageImpl<>(List.of(review)); - FindShelterReviewsResponse expected = FindShelterReviewsResponse.from(reviewPage); + FindShelterReviewsByShelterResponse expected = FindShelterReviewsByShelterResponse.from(reviewPage); given(reviewRepository.findAllByShelterId(anyLong(), any())) .willReturn(reviewPage); //then - FindShelterReviewsResponse response - = reviewService.findShelterReviews(shelterId, pageRequest); + FindShelterReviewsByShelterResponse response + = reviewService.findShelterReviewsByShelter(shelterId, pageRequest); //then assertThat(response).usingRecursiveComparison()