Skip to content
Open
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 @@ -109,4 +109,17 @@ public ResponseEntity<MateballResponse<?>> permitRequest(

return ResponseEntity.ok(MateballResponse.successWithNoData(SuccessCode.NO_CONTENT));
}

@Operation(summary = "요청 거절 api")
@PatchMapping("/match-reject/{matchId}")
public ResponseEntity<MateballResponse<?>> rejectRequest(
@AuthenticationPrincipal CustomUserDetails customUserDetails,
@PathVariable Long matchId
) {
Long userId = customUserDetails.getUserId();

groupV3Service.rejectRequest(userId, matchId);

return ResponseEntity.ok(MateballResponse.successWithNoData(SuccessCode.NO_CONTENT));
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package at.mateball.domain.group.core.service;

import at.mateball.domain.alarm.core.service.AlarmService;
import at.mateball.domain.chatting.api.dto.response.ChattingRes;
import at.mateball.domain.gameinformation.core.repository.GameInformationRepository;
import at.mateball.domain.group.api.dto.*;
import at.mateball.domain.group.api.dto.base.GroupMatchBaseRes;
import at.mateball.domain.group.core.GroupExecutorV3;
Expand All @@ -17,7 +15,6 @@
import at.mateball.domain.group.infrastructure.repository.GroupV3RepositoryCustom;
import at.mateball.domain.groupRequest.GroupRequestService;
import at.mateball.domain.groupmember.GroupMemberStatus;
import at.mateball.domain.groupmember.core.repository.GroupMemberRepository;
import at.mateball.domain.matchrequirement.core.constant.StyleMatch;
import at.mateball.domain.team.core.TeamNameMatch;
import at.mateball.exception.BusinessException;
Expand Down Expand Up @@ -336,4 +333,8 @@ public void permitRequest(Long userId, Long groupId) {
groupRequestService.permitRequest(userId, groupId);
}

@Transactional
public void rejectRequest(Long userId, Long matchId) {
groupRequestService.rejectRequest(userId, matchId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,17 @@ private boolean isGroupFull(GroupMatchSummaryRes summary) {
long totalMatched = summary.matchedParticipants() + 1;
return totalMatched == TOTAL_GROUP_MEMBER;
}

public void rejectRequest(Long userId, Long matchId) {
getValidatedGroup(userId, matchId);

GroupMatchSummaryRes summary = groupMemberV3Service.getMatchSummary(matchId);
Long requesterId = Optional.ofNullable(summary.requesterId())
.orElseThrow(() -> new BusinessException(BusinessErrorCode.REQUESTER_NOT_FOUND));

groupMemberV3Service.updateLeaderStatusPending(userId, matchId);
groupMemberV3Service.updateMemberStatusFailed(requesterId, matchId);

alarmService.readAllAlarms(userId);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package at.mateball.domain.groupmember.core.service;

import at.mateball.domain.groupmember.GroupMemberStatus;
import at.mateball.domain.groupmember.api.dto.GroupMatchSummaryRes;
import at.mateball.domain.groupmember.core.repository.GroupMemberRepository;
import at.mateball.exception.BusinessException;
import at.mateball.exception.code.BusinessErrorCode;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

Expand All @@ -18,4 +21,13 @@ public void updateMemberStatusMatched(Long userId, Long groupId) {
public void updateLeaderStatusPending(Long userId, Long groupId) {
groupMemberRepository.updateMemberStatus(userId, groupId, GroupMemberStatus.PENDING_REQUEST.getValue());
}

public void updateMemberStatusFailed(Long userId, Long groupId) {
groupMemberRepository.updateMemberStatus(userId, groupId, GroupMemberStatus.MATCH_FAILED.getValue());
}

public GroupMatchSummaryRes getMatchSummary(Long groupId) {
return groupMemberRepository.getMatchSummary(groupId)
.orElseThrow(() -> new BusinessException(BusinessErrorCode.REQUEST_NOT_FOUND));
}
}