-
Notifications
You must be signed in to change notification settings - Fork 8
[9주차/박콩] 워크북 제출합니다 #46
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
Open
haewonee
wants to merge
7
commits into
UMC-Inha:parkkong/main
Choose a base branch
from
haewonee:Feat/Chapter9
base: parkkong/main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
34470f8
feat: 워크북 특정 가게의 리뷰목록 보기 API 구현
haewonee 267d666
feat: 페이지 커스텀 어노테이션 구현
haewonee ffea899
feat: 내가 작성한 리뷰 목록 API 구현
haewonee 29ffa81
feat: 특정 가게의 미션 목록 조회 API 구현
haewonee 44d71a0
feat: 내가 진행중인 미션 목록 API 구현
haewonee 3d05061
feat: 진행중인 미션 진행 완료로 바꾸기 API 구현
haewonee 9a20d33
fix: 피드백 반영
haewonee 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
30 changes: 0 additions & 30 deletions
30
src/main/java/umc/domain/controller/MissionController.java
This file was deleted.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
src/main/java/umc/domain/mission/controller/MissionController.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,53 @@ | ||
| package umc.domain.mission.controller; | ||
|
|
||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.Parameter; | ||
| import io.swagger.v3.oas.annotations.Parameters; | ||
| import jakarta.validation.Valid; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.validation.annotation.Validated; | ||
| import org.springframework.web.bind.annotation.*; | ||
| import umc.domain.mission.dto.req.MissionReqDTO; | ||
| import umc.domain.mission.dto.res.MissionResDTO; | ||
| import umc.domain.mission.entity.Mission; | ||
| import umc.domain.mission.service.command.MissionCommandService; | ||
| import umc.domain.mission.service.query.MissionQueryService; | ||
| import umc.global.annotation.CheckPage; | ||
| import umc.global.apiPayload.ApiResponse; | ||
| import umc.global.apiPayload.code.GeneralSuccessCode; | ||
|
|
||
| @RestController | ||
| @RequiredArgsConstructor | ||
| @Validated | ||
| @RequestMapping("/api/missions") | ||
| public class MissionController { | ||
| private final MissionCommandService missionCommandService; | ||
| private final MissionQueryService missionQueryService; | ||
|
|
||
| @PostMapping("/") | ||
| public ApiResponse<MissionResDTO.AddMissionResDTO> addMission( | ||
| @RequestBody @Valid MissionReqDTO.AddMissionReqDTO req | ||
| ){ | ||
| return ApiResponse.onSuccess( | ||
| GeneralSuccessCode.OK, | ||
| missionCommandService.addMission(req) | ||
| ); | ||
| } | ||
|
|
||
| @GetMapping("/store/{storeId}") | ||
| @Operation(summary = "특정 가게의 미션 목록 조회 API", description = "특정 가게의 미션 목록을 조회합니다. page는 1부터 시작합니다.") | ||
| @Parameters({ | ||
| @Parameter(name = "storeId", description = "가게의 아이디, path variable 입니다!"), | ||
| @Parameter(name = "page", description = "페이지 번호 (1 이상)") | ||
| }) | ||
| public ApiResponse<MissionResDTO.MissionByStoreListResDTO> getMissionByStore( | ||
| @PathVariable Long storeId, | ||
| @CheckPage @RequestParam(name = "page") Integer page | ||
| ){ | ||
| return ApiResponse.onSuccess( | ||
| GeneralSuccessCode.OK, | ||
| missionQueryService.getMissionByStoreListResDTO(storeId, page) | ||
| ); | ||
|
|
||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,4 +25,5 @@ public record AddMissionReqDTO( | |
| LocalDate deadline | ||
|
|
||
| ){} | ||
|
|
||
| } | ||
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
7 changes: 7 additions & 0 deletions
7
src/main/java/umc/domain/mission/service/query/MissionQueryService.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,7 @@ | ||
| package umc.domain.mission.service.query; | ||
|
|
||
| import umc.domain.mission.dto.res.MissionResDTO; | ||
|
|
||
| public interface MissionQueryService { | ||
| MissionResDTO.MissionByStoreListResDTO getMissionByStoreListResDTO(Long storeId, Integer page); | ||
| } |
35 changes: 35 additions & 0 deletions
35
src/main/java/umc/domain/mission/service/query/MissionQueryServiceImpl.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,35 @@ | ||
| package umc.domain.mission.service.query; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.data.domain.Page; | ||
| import org.springframework.data.domain.PageRequest; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
| import org.springframework.validation.annotation.Validated; | ||
| import umc.domain.mission.converter.MissionConverter; | ||
| import umc.domain.mission.dto.res.MissionResDTO; | ||
| import umc.domain.mission.entity.Mission; | ||
| import umc.domain.mission.repository.MissionRepository; | ||
| import umc.domain.store.entity.Store; | ||
| import umc.domain.store.exception.StoreException; | ||
| import umc.domain.store.exception.code.StoreErrorCode; | ||
| import umc.domain.store.repository.StoreRepository; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| @Transactional(readOnly = true) | ||
| public class MissionQueryServiceImpl implements MissionQueryService{ | ||
| private final MissionRepository missionRepository; | ||
| private final StoreRepository storeRepository; | ||
|
|
||
| @Override | ||
| public MissionResDTO.MissionByStoreListResDTO getMissionByStoreListResDTO(Long storeId, Integer page){ | ||
|
|
||
| Store store = storeRepository.findById(storeId).orElseThrow(()-> new StoreException(StoreErrorCode.NOT_FOUND)); | ||
| PageRequest pageRequest = PageRequest.of(page-1,10); | ||
| Page<Mission> missionPage = missionRepository.findAllByStore(store, pageRequest); | ||
|
|
||
| return MissionConverter.toMissionByStoreListResDTO(missionPage); | ||
|
|
||
| } | ||
| } |
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
40 changes: 40 additions & 0 deletions
40
src/main/java/umc/domain/review/controller/ReviewControllerDocs.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,40 @@ | ||
| package umc.domain.review.controller; | ||
|
|
||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.Parameter; | ||
| import io.swagger.v3.oas.annotations.Parameters; | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
| import org.springframework.web.bind.annotation.RequestParam; | ||
| import umc.domain.review.dto.res.ReviewResDTO; | ||
| import umc.global.annotation.CheckPage; | ||
| import umc.global.apiPayload.ApiResponse; | ||
| public interface ReviewControllerDocs { | ||
| @Operation( | ||
| summary = "가게의 리뷰 목록 조회 API By 박콩(개발 중)", | ||
| description = "특정 가게의 리뷰를 모두 조회합니다. 페이지네이션으로 제공합니다." | ||
| ) | ||
| @ApiResponses({ | ||
| @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200",description = "성공"), | ||
| @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "400", description = "실패") | ||
| }) | ||
| @Parameters({ | ||
| @Parameter(name="storeName", description = "가게 이름"), | ||
| @Parameter(name="page",description = "페이지 번호") | ||
| }) | ||
| ApiResponse<ReviewResDTO.ReviewPreViewListDTO> getReviews( | ||
| @RequestParam(name="storeName") String storeName, | ||
| @RequestParam(name="page") Integer page | ||
| ); | ||
|
Comment on lines
+11
to
+27
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. 옹 이렇게 인터페이스 만들어서 docs 관리하는 거 진짜 좋아보이네요 |
||
|
|
||
| @Operation(summary = "내가 작성한 리뷰 목록 조회 API", description = "나의 리뷰 목록을 조회합니다. page는 1부터 시작") | ||
| @ApiResponses({ | ||
| @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "성공"), | ||
| @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "400", description = "페이지 번호가 1보다 작을 때 발생") | ||
| }) | ||
| @Parameters({ | ||
| @Parameter(name = "page", description = "페이지 번호 (1 이상)") | ||
| }) | ||
| public ApiResponse<ReviewResDTO.MyReviewPreviewListDTO> getMyReviewList( | ||
| @CheckPage @RequestParam(name = "page") Integer page // 커스텀 어노테이션 적용! | ||
| ); | ||
| } | ||
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.
스터디 때 userId 어떻게 받아오냐고 여쭤보셨던 거 같아요!
방법은 찾아보시면 여러가지 있는데, 제가 알고있는 방식만 대략 설명드릴게요!
스프링 시큐리티 단에서 JWT 유효성 검증을 마치면, JWT로 부터 userId를 추출하여 컨트롤러의 인자로 바로 넘겨주는 방식이에요.
이때 컨트롤러가 필요로 하는 인자를 만들어주는건
ArgumentResolver의 역할이잖아요? 그래서 이걸 직접 커스텀해야해요.보통 경험 많으신 분들이 위처럼 만들어주실 거예요.
물론 다른 방법도 있겠지만, '이런 방법이 있다!' 로만 이해해주세요!