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

[FIX] 매칭 생성 시 해당 프로젝트 다른 요청들 거절하는 로직 구현 #122

Merged
merged 2 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import io.oeid.mogakgo.domain.project_join_req.domain.entity.ProjectJoinRequest;
import io.oeid.mogakgo.domain.project_join_req.exception.ProjectJoinRequestException;
import io.oeid.mogakgo.domain.project_join_req.infrastructure.ProjectJoinRequestJpaRepository;
import io.oeid.mogakgo.domain.user.application.UserCommonService;
import io.oeid.mogakgo.domain.project_join_req.presentation.dto.res.ProjectJoinRequestDetailAPIRes;
import io.oeid.mogakgo.domain.user.application.UserCommonService;
import io.oeid.mogakgo.domain.user.domain.User;
import io.oeid.mogakgo.domain.user.exception.UserException;
import io.oeid.mogakgo.domain.user.infrastructure.UserJpaRepository;
Expand Down Expand Up @@ -87,6 +87,11 @@ public Long accept(Long userId, Long projectRequestId) {
Long matchingId = matchingService.create(projectJoinRequest);
//----

// 프로젝트에 대한 요청들 수락 되지 않은 것들 다 거절 처리
// 비동기 가능
projectJoinRequestRepository.rejectNoAcceptedByProjectId(
projectJoinRequest.getProject().getId(), projectJoinRequest.getId());

// 내가 보낸 대기 중 요청이 있으면 취소 처리
// 여기서 나는 에러는 클라와 상관이 없으므로 에러가 발생해도 넘어갈 수 있게 처리.
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public interface ProjectJoinRequestJpaRepository extends JpaRepository<ProjectJo
@Query("select pjr from ProjectJoinRequest pjr where pjr.id = :id")
Optional<ProjectJoinRequest> findByIdWithProject(Long id);


@Query("select pjr from ProjectJoinRequest pjr where pjr.sender.id = :senderId and pjr.requestStatus = 'PENDING'")
Optional<ProjectJoinRequest> findPendingBySenderId(Long senderId);

Expand All @@ -24,8 +23,14 @@ public interface ProjectJoinRequestJpaRepository extends JpaRepository<ProjectJo
@Query("select pjr from ProjectJoinRequest pjr where pjr.sender.id = :userId")
Optional<ProjectJoinRequest> findAlreadyExistsAnotherJoinReq(Long userId);

@Modifying
@Query("update ProjectJoinRequest pjr set pjr.requestStatus = 'REJECTED' "
+ "where pjr.project.id = :projectId and pjr.id != :acceptedRequestId and pjr.requestStatus = 'PENDING'")
int rejectNoAcceptedByProjectId(Long projectId, Long acceptedRequestId);

@Modifying
@Query("update ProjectJoinRequest pjr set pjr.requestStatus = 'REJECTED' where pjr.project.id = :projectId and pjr.requestStatus = 'PENDING'")
int rejectAllByProjectId(Long projectId);


}
Loading