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

[FEAT] 선택한 구역에 대한 프로젝트, 프로필 카드 리스트 랜덤 조회 API, 프로젝트 매칭 요청 생성 API 개발 #92

Merged
merged 39 commits into from
Feb 19, 2024

Conversation

JIN-076
Copy link
Collaborator

@JIN-076 JIN-076 commented Feb 19, 2024

🚀 개발 사항

  • 프로젝트 카드 리스트 랜덤 조회 API
  • 프로필 카드 리스트 랜덤 조회 API
  • 커서 기반 페이지네이션 공통 포맷 적용
  • 프로젝트 매칭 요청 생성 API

이슈 번호

특이 사항 🫶

@JIN-076 JIN-076 added ⭐️ Feat 새로운 기능 🎯 MVP1 mvp1 개발사항 labels Feb 19, 2024
@JIN-076 JIN-076 self-assigned this Feb 19, 2024
Copy link

github-actions bot commented Feb 19, 2024

Test Results

0 tests   0 ✅  0s ⏱️
0 suites  0 💤
0 files    0 ❌

Results for commit c012a47.

♻️ This comment has been updated with latest results.

@JIN-076 JIN-076 changed the title [FEAT] 선택한 구역에 대한 프로젝트, 프로필 카드 리스트 랜덤 조회 API 개발 [FEAT] 선택한 구역에 대한 프로젝트, 프로필 카드 리스트 랜덤 조회 API, 프로젝트 매칭 요청 생성 API 개발 Feb 19, 2024
Copy link
Member

@tidavid1 tidavid1 left a comment

Choose a reason for hiding this comment

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

리뷰 확인해주세요!

@@ -12,7 +12,7 @@

@Schema(description = "회원 프로필 조회 응답")
@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@AllArgsConstructor(access = AccessLevel.PUBLIC)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@AllArgsConstructor(access = AccessLevel.PUBLIC)
@AllArgsConstructor

@UserId Long userId, @Valid @RequestBody ProjectJoinCreateReq request
) {
return ResponseEntity.status(201)
.body(ProjectJoinRequestAPIRes.from(projectJoinRequestService.create(userId, request)));
Copy link
Member

Choose a reason for hiding this comment

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

엔터가 두개?!

import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/project-join-request")
Copy link
Member

Choose a reason for hiding this comment

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

project-join-request 보다 project/join-request는 어떨까요?

Comment on lines +45 to +77
private User validateToken(Long userId) {
return userRepository.findById(userId)
.orElseThrow(() -> new UserException(USER_NOT_FOUND));
}

private void validateSender(User tokenUser, Long userId) {
if (!tokenUser.getId().equals(userId)) {
throw new ProjectJoinRequestException(PROJECT_JOIN_REQUEST_FORBIDDEN_OPERATION);
}
}

private Project validateProjectExist(Long projectId) {
return projectRepository.findById(projectId)
.orElseThrow(() -> new ProjectException(PROJECT_NOT_FOUND));
}

private void validateProjectCreator(Project project, Long userId) {
if (project.getCreator().getId().equals(userId)) {
throw new ProjectJoinRequestException(PROJECT_JOIN_REQUEST_FORBIDDEN_OPERATION);
}
}

private void validateAlreadyExistRequest(Long userId, Long projectId) {
if (projectJoinRequestRepository.findAlreadyExists(userId, projectId).isPresent()) {
throw new ProjectJoinRequestException(PROJECT_JOIN_REQUEST_ALREADY_EXIST);
}
}

private void validateUserCertRegion(Project project, User tokenUser) {
if (!tokenUser.getRegion().equals(project.getCreatorInfo().getRegion())) {
throw new ProjectJoinRequestException(INVALID_PROJECT_JOIN_REQUEST_REGION);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

나중에 유틸로 빼거나 하면 좋을 것 같아요! 👍🏻

private final MeetingInfoResponse meetingInfo;


public ProjectDetailAPIRes(Long projectId, UserPublicApiResponse creator,
Copy link
Member

Choose a reason for hiding this comment

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

퍼블릭으로 따로 사용할 이유가 있을까요?!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

QueryDsl에서 Projections.constructor를 사용해서 바인딩받을 때 생성자를 사용하기 때문에 public으로 열어두어야 해서 이렇게 작성했습니다!

@Schema(description = "프로젝트 만남 장소", example = "맥심플랜트 이태원점")
private final String meetDetail;

public MeetingInfoResponse(LocalDateTime meetStartTime, LocalDateTime meetEndTime, String meetDetail) {
Copy link
Member

Choose a reason for hiding this comment

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

밑에 팩토리 메서드가 있는데 퍼블릭으로 있는 이유가 궁금해요!

Comment on lines +125 to +126
// 요청할 때마다 랜덤 정렬
Collections.shuffle(projects.getData());
Copy link
Member

Choose a reason for hiding this comment

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

👍🏻

@Valid @ModelAttribute CursorPaginationInfoReq pageable
) {
return ResponseEntity.ok().body(
profileCardService.getRandomOrderedProfileCardsByRegion(userId, region, pageable)
Copy link
Member

Choose a reason for hiding this comment

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

엔터가 두번 눌린 것 같습니다!

@JIN-076 JIN-076 merged commit 6911ccd into develop Feb 19, 2024
3 checks passed
@JIN-076 JIN-076 linked an issue Feb 19, 2024 that may be closed by this pull request
2 tasks
@JIN-076 JIN-076 deleted the feat/#30-cards_list_up_by_zone branch March 4, 2024 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⭐️ Feat 새로운 기능 🎯 MVP1 mvp1 개발사항
Projects
None yet
3 participants