-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/86 봉사자의 관심기관 조회 기능 #96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f0efddd
feat: 기관 아이디 리스트를 통한 오버뷰 데이터 조회 구현
7zrv 8553f58
feat: 봉사자의 관심 기관 리스트 조회 기능 구현
7zrv 3459705
feat: 테스트용 인증 유저 어노테이션 구현
7zrv 046a08f
feat: 관심기관 조회 컨트롤러 구현
7zrv c417022
chore: 불필요한 import문 제거
7zrv 5fc83b4
chore: 테스트 커버리지 제외 클래스 추가
7zrv 43790f2
chore: 코드 리뷰 사항 반영
7zrv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/main/java/com/somemore/center/repository/mapper/CenterOverviewInfo.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.somemore.center.repository.mapper; | ||
|
|
||
|
|
||
| import java.util.UUID; | ||
|
|
||
| public record CenterOverviewInfo( | ||
| UUID centerId, | ||
| String centerName, | ||
| String imgUrl | ||
| ) { | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
src/main/java/com/somemore/center/usecase/query/CenterQueryUseCase.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,13 @@ | ||
| package com.somemore.center.usecase.query; | ||
|
|
||
| import com.somemore.center.repository.mapper.CenterOverviewInfo; | ||
| import com.somemore.center.dto.response.CenterProfileResponseDto; | ||
|
|
||
| import java.util.List; | ||
| import java.util.UUID; | ||
|
|
||
| public interface CenterQueryUseCase { | ||
|
|
||
| CenterProfileResponseDto getCenterProfileByCenterId(UUID centerId); | ||
| List<CenterOverviewInfo> getCenterOverviewsByIds(List<UUID> centerIds); | ||
| void validateCenterExists(UUID centerId); | ||
| } |
32 changes: 32 additions & 0 deletions
32
src/main/java/com/somemore/interestcenter/controller/InterestCenterQueryApiController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package com.somemore.interestcenter.controller; | ||
|
|
||
| import com.somemore.global.common.response.ApiResponse; | ||
| import com.somemore.interestcenter.dto.response.InterestCentersResponseDto; | ||
| import com.somemore.interestcenter.usecase.InterestCenterQueryUseCase; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| import java.util.List; | ||
| import java.util.UUID; | ||
|
|
||
| @RequiredArgsConstructor | ||
| @RestController | ||
| @Tag(name = "Interest Center Query API", description = "관심 기관의 조회 API를 제공합니다") | ||
| public class InterestCenterQueryApiController { | ||
|
|
||
| private final InterestCenterQueryUseCase interestCenterQueryUseCase; | ||
|
|
||
| @Operation(summary = "관심기관 목록 조회 API") | ||
| @GetMapping("/api/interest-centers") | ||
| public ApiResponse<List<InterestCentersResponseDto>> getInterestCenters(@AuthenticationPrincipal String volunteerId) { | ||
|
|
||
| List<InterestCentersResponseDto> responseDtos = interestCenterQueryUseCase.getInterestCenters(UUID.fromString(volunteerId)); | ||
|
|
||
| return ApiResponse.ok(200, responseDtos, "관심기관 조회 성공"); | ||
| } | ||
|
|
||
| } | ||
28 changes: 28 additions & 0 deletions
28
src/main/java/com/somemore/interestcenter/dto/response/InterestCentersResponseDto.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package com.somemore.interestcenter.dto.response; | ||
|
|
||
| import com.fasterxml.jackson.databind.PropertyNamingStrategies; | ||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
| import com.somemore.center.repository.mapper.CenterOverviewInfo; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import lombok.Builder; | ||
|
|
||
| import java.util.UUID; | ||
|
|
||
| @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) | ||
| @Builder | ||
| public record InterestCentersResponseDto( | ||
| @Schema(description = "관심기관의 ID", example = "123e4567-e89b-12d3-a456-426614174000") | ||
| UUID centerId, | ||
| @Schema(description = "관심기관의 이름", example = "서울 도서관") | ||
| String centerName, | ||
| @Schema(description = "관심기관의 프로필 이미지 링크", example = "~~/image.jpeg") | ||
| String imgUrl | ||
| ) { | ||
| public static InterestCentersResponseDto of(CenterOverviewInfo responseDto) { | ||
| return InterestCentersResponseDto.builder() | ||
| .centerId(responseDto.centerId()) | ||
| .centerName(responseDto.centerName()) | ||
| .imgUrl(responseDto.imgUrl()) | ||
| .build(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/com/somemore/interestcenter/service/InterestCenterQueryService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package com.somemore.interestcenter.service; | ||
|
|
||
| import com.somemore.center.repository.mapper.CenterOverviewInfo; | ||
| import com.somemore.center.usecase.query.CenterQueryUseCase; | ||
| import com.somemore.interestcenter.dto.response.InterestCentersResponseDto; | ||
| import com.somemore.interestcenter.repository.InterestCenterRepository; | ||
| import com.somemore.interestcenter.usecase.InterestCenterQueryUseCase; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| import java.util.List; | ||
| import java.util.UUID; | ||
|
|
||
| @RequiredArgsConstructor | ||
| @Service | ||
| public class InterestCenterQueryService implements InterestCenterQueryUseCase { | ||
|
|
||
| private final CenterQueryUseCase centerQueryUseCase; | ||
| private final InterestCenterRepository interestCenterRepository; | ||
|
|
||
| @Override | ||
| public List<InterestCentersResponseDto> getInterestCenters(UUID volunteerId) { | ||
|
|
||
| List<UUID> interestCenterIds = interestCenterRepository.findInterestCenterIdsByVolunteerId(volunteerId); | ||
| if (interestCenterIds.isEmpty()) { | ||
| return List.of(); | ||
| } | ||
|
|
||
| List<CenterOverviewInfo> centerOverviews = centerQueryUseCase.getCenterOverviewsByIds(interestCenterIds); | ||
| return centerOverviews.stream() | ||
| .map(InterestCentersResponseDto::of) | ||
| .toList(); | ||
| } | ||
| } |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/somemore/interestcenter/usecase/InterestCenterQueryUseCase.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.somemore.interestcenter.usecase; | ||
|
|
||
| import com.somemore.interestcenter.dto.response.InterestCentersResponseDto; | ||
|
|
||
| import java.util.List; | ||
| import java.util.UUID; | ||
|
|
||
| public interface InterestCenterQueryUseCase { | ||
| List<InterestCentersResponseDto> getInterestCenters(UUID volunteerId); | ||
| } |
26 changes: 26 additions & 0 deletions
26
src/test/java/com/somemore/CustomSecurityContextFactory.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package com.somemore; | ||
|
|
||
| import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; | ||
| import org.springframework.security.core.Authentication; | ||
| import org.springframework.security.core.authority.SimpleGrantedAuthority; | ||
| import org.springframework.security.core.context.SecurityContext; | ||
| import org.springframework.security.core.context.SecurityContextHolder; | ||
| import org.springframework.security.test.context.support.WithSecurityContextFactory; | ||
|
|
||
| import java.util.Collections; | ||
|
|
||
| public class CustomSecurityContextFactory implements WithSecurityContextFactory<WithMockCustomUser> { | ||
| @Override | ||
| public SecurityContext createSecurityContext(WithMockCustomUser annotation) { | ||
| SecurityContext context = SecurityContextHolder.createEmptyContext(); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아 저는 이게 문제였을까요... |
||
|
|
||
| Authentication auth = new UsernamePasswordAuthenticationToken( | ||
| annotation.username(), | ||
| "password", | ||
| Collections.singletonList(new SimpleGrantedAuthority("ROLE_USER")) | ||
| ); | ||
|
|
||
| context.setAuthentication(auth); | ||
| return context; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.somemore; | ||
|
|
||
| import org.springframework.security.test.context.support.WithSecurityContext; | ||
|
|
||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
|
|
||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @WithSecurityContext(factory = CustomSecurityContextFactory.class) | ||
| public @interface WithMockCustomUser { | ||
| String username() default "123e4567-e89b-12d3-a456-426614174000"; | ||
| } | ||
|
Comment on lines
+8
to
+12
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 어노테이션에 능숙하시네요. 저는 처음보는 문법이 많은 것 같습니다. |
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
명세상으로 페이징 처리 해야할 것 같아요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://www.notion.so/prgrms/getInterestCenters-977bdc0b0c164da3bf7261df7991097d?pvs=4