Skip to content

Commit

Permalink
refactor : 코드 리포멧팅
Browse files Browse the repository at this point in the history
  • Loading branch information
hyun2371 committed Jan 15, 2024
1 parent 1d4f6a0 commit f93d7f8
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ public Long findRank(Long shopId, Long waitingId) {
return -1L;
}

public Long findRankValue(Long shopId,int rank) {
public Long findRankValue(Long shopId, int rank) {
Queue<Long> waitingLine = waitingLines.get(shopId);
int index = 0;
for (Long element : waitingLine) {
if (index == rank-1) {
if (index == rank - 1) {
return element;
}
index++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public MemberWaitingResponse createWaiting(Long shopId, Member member,

Long rank = waitingLineRepository.save(shopId, waiting.getId());// 대기열 저장

notification.sendMessageAsCreated(member, owner,rank);
notification.sendMessageAsCreated(member, owner, rank);

return toMemberWaitingResponse(savedWaiting, rank);
}
Expand All @@ -69,13 +69,14 @@ public MemberWaitingResponse createWaiting(Long shopId, Member member,
public MemberWaitingResponse postponeWaiting(Member member) {
Waiting waiting = getWaitingEntityInProgress(member);
Long shopId = waiting.getShop().getId();
Long previousRank = waitingLineRepository.findRank(shopId, waiting.getId()); // 미루기 전 rank 저장
Long previousRank = waitingLineRepository.findRank(shopId,
waiting.getId()); // 미루기 전 rank 저장

waiting.decreasePostponeRemainingCount();
Long rank = waitingLineRepository.postpone(shopId, waiting.getId());// 미룬 후 rank 저장

notification.sendEntryMessageToOthers(shopId, previousRank);
notification.sendMessageAsPostponed(member,previousRank);
notification.sendMessageAsPostponed(member, previousRank);

return toMemberWaitingResponse(waiting, rank);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.prgrms.catchtable.waiting.service;

import static com.prgrms.catchtable.common.exception.ErrorCode.WAITING_DOES_NOT_EXIST;
import static com.prgrms.catchtable.common.notification.WaitingNotificationContent.*;
import static com.prgrms.catchtable.waiting.dto.WaitingMapper.toOwnerWaitingListResponse;
import static com.prgrms.catchtable.waiting.dto.WaitingMapper.toOwnerWaitingResponse;

Expand Down Expand Up @@ -41,12 +40,12 @@ public OwnerWaitingResponse entryWaiting(Owner owner) {
waiting.changeStatusCompleted();

waitingNotification.sendMessageAsCompleted(waiting.getMember());
waitingNotification.sendEntryMessageToOthers(shopId,1L);
waitingNotification.sendEntryMessageToOthers(shopId, 1L);

return toOwnerWaitingResponse(waiting, 0L);
}

private Waiting getWaitingEntity(Long waitingId){
private Waiting getWaitingEntity(Long waitingId) {
return waitingRepository.findById(waitingId)
.orElseThrow(() -> new NotFoundCustomException(WAITING_DOES_NOT_EXIST));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
@Component
@RequiredArgsConstructor
public class WaitingNotification {

private final ApplicationEventPublisher publisher;
private final WaitingLineRepository waitingLineRepository;
private final WaitingRepository waitingRepository;
Expand All @@ -41,7 +42,7 @@ public void sendMessageAsCompleted(Member member) {
}

public void sendMessageAsCanceled(Member member, Owner owner, Long rank) {
sendMessageToMember(member,MEMBER_CANCELED.getContent());
sendMessageToMember(member, MEMBER_CANCELED.getContent());
sendMessageToOwner(owner, String.format(OWNER_CANCELED.getContent(), rank));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.prgrms.catchtable.waiting.controller;

import static com.prgrms.catchtable.waiting.domain.WaitingStatus.*;
import static com.prgrms.catchtable.waiting.domain.WaitingStatus.COMPLETED;
import static com.prgrms.catchtable.waiting.domain.WaitingStatus.PROGRESS;
import static org.mockito.BDDMockito.given;
import static org.springframework.http.MediaType.APPLICATION_JSON;
import static org.springframework.restdocs.payload.JsonFieldType.NUMBER;
Expand All @@ -15,7 +16,6 @@
import com.prgrms.catchtable.owner.domain.Owner;
import com.prgrms.catchtable.owner.fixture.OwnerFixture;
import com.prgrms.catchtable.owner.repository.OwnerRepository;
import com.prgrms.catchtable.waiting.domain.WaitingStatus;
import com.prgrms.catchtable.waiting.dto.response.OwnerWaitingListResponse;
import com.prgrms.catchtable.waiting.dto.response.OwnerWaitingResponse;
import com.prgrms.catchtable.waiting.service.OwnerWaitingService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.context.ApplicationEventPublisher;

@ExtendWith(MockitoExtension.class)
class MemberWaitingServiceTest {
Expand Down

0 comments on commit f93d7f8

Please sign in to comment.