-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: 모집글 예외 처리 및 응답 포맷 통일 #54
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
13 changes: 13 additions & 0 deletions
13
recruitment-service/src/main/java/com/example/recruitment/config/RestTemplateConfig.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,13 @@ | ||
| package com.example.recruitment.config; | ||
|
|
||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.web.client.RestTemplate; | ||
|
|
||
| @Configuration | ||
| public class RestTemplateConfig { | ||
| @Bean | ||
| public RestTemplate restTemplate() { | ||
| return new RestTemplate(); | ||
| } | ||
| } |
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
61 changes: 56 additions & 5 deletions
61
recruitment-service/src/main/java/com/example/recruitment/dto/RecruitmentDetailDto.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,21 +1,72 @@ | ||
| package com.example.recruitment.dto; | ||
|
|
||
| import com.example.recruitment.entity.Recruitment; | ||
| import com.example.recruitment.entity.Store; | ||
| import com.example.recruitment.entity.User; | ||
| import lombok.Getter; | ||
| import lombok.Setter; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.util.List; | ||
|
|
||
| @Getter @Setter | ||
| @Getter | ||
| @Setter | ||
| public class RecruitmentDetailDto { | ||
|
|
||
| private Long id; | ||
| private String title; | ||
| private String description; | ||
| private String status; | ||
| private LocalDateTime deadlineTime; | ||
| private User user; | ||
| private Store store; | ||
| private List<User> participants; | ||
|
|
||
| private UserDto user; | ||
| private StoreDto store; | ||
| private List<UserDto> participants; | ||
| private List<Long> orderIds; | ||
|
|
||
| public RecruitmentDetailDto( | ||
| Recruitment recruitment, | ||
| UserDto writer, | ||
| List<UserDto> participantUsers, | ||
| List<Long> orderIds | ||
| ) { | ||
| this.id = recruitment.getId(); | ||
| this.title = recruitment.getTitle(); | ||
| this.description = recruitment.getDescription(); | ||
| this.status = recruitment.getStatus(); | ||
| this.deadlineTime = recruitment.getDeadlineTime(); | ||
| this.user = writer; // ✅ 유저 서비스로부터 가져온 작성자 정보 | ||
| this.store = new StoreDto(recruitment.getStore()); | ||
| this.participants = participantUsers; | ||
| this.orderIds = orderIds; | ||
| } | ||
|
|
||
| @Getter | ||
| @Setter | ||
| public static class UserDto { | ||
| private Long id; | ||
| private String name; | ||
| private String email; | ||
|
|
||
| public UserDto(Long id, String name, String email) { | ||
| this.id = id; | ||
| this.name = name; | ||
| this.email = email; | ||
| } | ||
| } | ||
|
|
||
| @Getter | ||
| @Setter | ||
| public static class StoreDto { | ||
| private Long id; | ||
| private String name; | ||
| private String category; | ||
| private String location; | ||
|
|
||
| public StoreDto(Store store) { | ||
| this.id = store.getId(); | ||
| this.name = store.getName(); | ||
| this.category = store.getCategory(); | ||
| this.location = store.getLocation(); | ||
| } | ||
| } | ||
| } |
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
Oops, something went wrong.
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.
🛠️ Refactor suggestion
UserClient 호출 시 예외 처리 필요
UserClient의 getUserById 메서드는 외부 서비스 호출이므로 실패할 수 있습니다. 특히 반복문 내에서 호출 시 일부 사용자 정보 조회 실패로 전체 요청이 실패할 수 있습니다.
부분 실패를 허용하는 방식으로 개선하거나, 최소한 적절한 예외 처리를 추가하세요:
📝 Committable suggestion
🤖 Prompt for AI Agents