Skip to content
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

야간잔류 신청 기능 구현 #26

Merged
merged 23 commits into from
Nov 24, 2024
Merged

야간잔류 신청 기능 구현 #26

merged 23 commits into from
Nov 24, 2024

Conversation

ahyeonkong
Copy link
Member

@ahyeonkong ahyeonkong commented Nov 22, 2024

#️⃣ 연관된 이슈

#21

📝 작업 내용

  • Spring Security를 활용해서 사용자의 정보를 받아왔습니다.
  • Bearer Token에 값을 받아와서 사용자의 정보를 조회했습니다.
  • 사용자가 직접 appliedDate, coParticipants, privacyAgreement, status를 작성하도록 구현했습니다.
  • Application.builder()를 사용하여 로그인한 사용자 정보와 입력 받은 정보를 결합했습니다.
  • ApplicationController에서 ResponseEntity를 지우고 ApiResponse로 리턴 값을 변경했습니다.
  • .getCoParticipants().size() + 1로 사용 인원을 자동으로 계산했습니다.
  • 201 응답만 확인했습니다. (예외 처리는 나중에 하겠습니다.)
  • 회원 관련 정보와 공동 참여자 정보를 DTO로 묶는 방법으로 수정했습니다.

📷 스크린샷 (선택)

회원가입 후, 로그인을 한 뒤에 야간잔류 신청 기능을 이용할 수 있습니다.
image

coParticipants 엔티티 별도로 생성했습니다.
image

💬 리뷰 요구사항 (선택)

피드백 많이 남겨주세요!!
구현 완료했습니다. 🫠

* Application 엔티티에 컬럼 추가
* ApplicationController에서 ApiResponse를 이용한 응답 및 에러 처리
* ApplicationRequest에서 요청 DTO 구현
* ApplicationResponse에서 응답 DTO 구현
* ApplicationRepository와 MemberRepository 생성
* ApplicationService 구현

Ref: #21
@ahyeonkong ahyeonkong added the ✨ Feature 기능 개발 label Nov 22, 2024
@ahyeonkong ahyeonkong self-assigned this Nov 22, 2024
Copy link

Test Coverage Report

Overall Project 21.23% -71.7% 🍏
Files changed 0% 🍏

File Coverage
ApiResponse.java 0% 🍏
ApplicationService.java 0% 🍏
ApplicationRequest.java 0% 🍏
ApplicationResponse.java 0% 🍏
ApplicationController.java 0% 🍏

Comment on lines 21 to 22
@PostMapping
public ResponseEntity<ApiResponse<ApplicationResponse>> createApplication(@RequestBody ApplicationRequest applicationRequest) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ResponseEntity와 ApiResponse는 거의 같은 기능이어서 한 번 더 감싸지 않아도 될 것 같습니다!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵! 좋습니다. ApiResponse에 상태 코드별 메서드를 만들면 더 간단하게 구현할 수 있을 것 같습니다.

Comment on lines 27 to 30
.body(new ApiResponse<>(
new ApiResponse.Status(HttpStatus.BAD_REQUEST, "필수 값이 누락되었습니다"),
null
));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

따로 메시지를 첨부하려하니 관련 메서드가 없어서 구조가 이상해지는 것 같네요. 이 부분은 추가하겠습니다!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 간단하게 추가해주세요! 더 필요한 부분이 있다면 제가 나중에 추가하겠습니다.

Comment on lines 33 to 47
try {
ApplicationResponse applicationResponse = applicationService.createApplication(applicationRequest);
return ResponseEntity.ok(new ApiResponse<>(
new ApiResponse.Status(HttpStatus.CREATED, "신청이 완료되었습니다"),
applicationResponse
));
} catch (IllegalArgumentException e) {
// 401 에러 처리
return ResponseEntity
.status(HttpStatus.UNAUTHORIZED)
.body(new ApiResponse<>(
new ApiResponse.Status(HttpStatus.UNAUTHORIZED, "권한이 없습니다"),
null
));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try-catch 문을 반복적으로 사용해서 코드가 조금 길어지는 것 같습니다!

이 부분은 예외 상황에서 Http 응답이 아닌 예외만 반환하게 하고, 추후에 전역 예외 핸들러를 통해 통일된 Http 응답 형식으로 반환하는 방식으로 수정할 수 있을 것 같습니다.

@ExceptionHandler(RuntimeException.class)
public ApiResponse<Void> handle(RuntimeException exception, HttpServletRequest request) {
    logInfo(exception, request);

    return ApiResponse.exception(exception);
}

요런 느낌인데 나중에 시간나면 추가해볼게유

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 좋습니다! 일단 해당 코드는 주석 처리하고 나중에 예외 throw 하는 방식으로 바꾸겠습니다.

Comment on lines 17 to 27
private String name;
private MemberType type;
private Long memberId;
private String loginId;
private String phoneNumber;
private String email;
private Integer participantCount;
private List<String> coParticipantNames;
private Boolean privacyAgreement;
private LocalDateTime startTime;
private LocalDateTime endTime;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

회원이 로그인한 상태로 야간잔류를 신청한다는 걸 감안하면 request dto에서 신청자의 정보를 받을 필요 없이 현재 로그인된 회원의 정보를 그대로 가져올 수 있어서, 관련 필드 변수들을 빼도 될 것 같습니다!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 수정하겠습니다.

Comment on lines 16 to 26
private String loginId;
private String name;
private MemberType type;
private Long memberId;
private String phoneNumber;
private String email;
private Integer participantCount;
private List<String> coParticipantNames;
private Boolean privacyAgreement;
private LocalDateTime startTime;
private LocalDateTime endTime;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기서 회원 관련 정보는 히원 정보 DTO로 묶으면 좋을 것 같고, coParticipantNames도 단순 이름이 아닌 회원 정보 DTO 내용을 담으면 좋을 것 같습니다!
(관련 DTO 구현이 아직 해당 PR에는 반영되지 않아서 추후에 변경해도 괜찮을 것 같습니다.)

또한 participantCount의 경우, coParticipantNames.size() + 1로 자체 계산할 수 있을 것 같습니다.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 수정하겠습니다! 감사합니다☺️

@Muokok
Copy link
Member

Muokok commented Nov 23, 2024

충돌 해결해주시면 감사하겠습니다!

Copy link

Test Coverage Report

Overall Project 11.89% -8.69% 🍏
Files changed 0% 🍏

File Coverage
ApplicationResponse.java 0% 🍏
ApplicationRequest.java 0% 🍏
MyPageService.java 0% 🍏
ApiResponse.java 0% 🍏
ApplicationService.java 0% 🍏
ApplicationController.java 0% 🍏

Copy link

Test Coverage Report

Overall Project 13.42% -2.99% 🍏
Files changed 0% 🍏

File Coverage
MemberInfoResponse.java 0% 🍏
CoParticipantRequest.java 0% 🍏
ApiResponse.java 0% 🍏
ApplicationService.java 0% 🍏
ApplicationController.java 0% 🍏

Copy link

Test Coverage Report

Overall Project 13.42% -2.99% 🍏
Files changed 0% 🍏

File Coverage
MemberInfoResponse.java 0% 🍏
CoParticipantRequest.java 0% 🍏
ApiResponse.java 0% 🍏
ApplicationService.java 0% 🍏
ApplicationController.java 0% 🍏

Copy link

Test Coverage Report

Overall Project 13.74% -4.31% 🍏
Files changed 26.36% 🍏

File Coverage
ApplicationStatus.java 91.43% -8.57% 🍏
MemberInfoResponse.java 0% 🍏
CoParticipantRequest.java 0% 🍏
CoParticipant.java 0% 🍏
ApiResponse.java 0% 🍏
ApplicationService.java 0% 🍏
ApplicationController.java 0% 🍏

@ahyeonkong ahyeonkong linked an issue Nov 24, 2024 that may be closed by this pull request
5 tasks
@ahyeonkong ahyeonkong merged commit fb92b35 into develop Nov 24, 2024
1 check passed
@ahyeonkong ahyeonkong deleted the feat/#21 branch November 24, 2024 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Feature 기능 개발
Projects
None yet
Development

Successfully merging this pull request may close these issues.

야간잔류 신청 기능 구현
3 participants