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] 프로젝트 취소 시 요청들 모두 취소하기 구현 #123

Merged
merged 1 commit 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 @@ -28,7 +28,6 @@
import io.oeid.mogakgo.domain.user.domain.User;
import io.oeid.mogakgo.domain.user.exception.UserException;
import io.oeid.mogakgo.domain.user.infrastructure.UserJpaRepository;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -77,11 +76,6 @@ public Long create(Long userId, ProjectCreateReq request) {
return project.getId();
}

private boolean isExistsNotEndProjectCard(User tokenUser) {
return !projectJpaRepository.findNotEndProjectOneByCreatorId(tokenUser.getId(),
PageRequest.of(0, 1)).isEmpty();
}

@Transactional
public void delete(Long userId, Long projectId) {
// 유저 존재 여부 체크
Expand All @@ -94,6 +88,7 @@ public void delete(Long userId, Long projectId) {
project.delete(user);
}

@Transactional
public void cancel(Long userId, Long projectId) {
// 유저 존재 여부 체크
User user = getUser(userId);
Expand All @@ -106,6 +101,9 @@ public void cancel(Long userId, Long projectId) {

// 프로젝트 취소
project.cancel(user, projectHasReq);

// 프로젝트가 받은 모든 요청 거절
projectJoinRequestJpaRepository.rejectAllByProjectId(projectId);
}

public CursorPaginationResult<projectJoinRequestRes> getJoinRequest(
Expand Down Expand Up @@ -160,6 +158,11 @@ public ProjectDensityRankRes getDensityRankProjects() {
return new ProjectDensityRankRes(regionRankList);
}

private boolean isExistsNotEndProjectCard(User tokenUser) {
return !projectJpaRepository.findNotEndProjectOneByCreatorId(tokenUser.getId(),
PageRequest.of(0, 1)).isEmpty();
}

private void fillWithDefaultRegionsIfNecessary(List<Region> regionRankList) {
if (regionRankList.size() < DENSITY_RANK_LIMIT) {
// 기본 지역 순위에서 이미 리스트에 있는 지역을 제외하고 남은 지역을 추가
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Optional;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

public interface ProjectJoinRequestJpaRepository extends JpaRepository<ProjectJoinRequest, Long>,
Expand All @@ -23,4 +24,8 @@ 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.requestStatus = 'PENDING'")
int rejectAllByProjectId(Long projectId);

}
Loading