-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feature : owner 웨이팅 조회 API 구현
- Loading branch information
Showing
25 changed files
with
447 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/com/prgrms/catchtable/waiting/controller/OwnerWaitingController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.prgrms.catchtable.waiting.controller; | ||
|
||
import com.prgrms.catchtable.waiting.dto.response.OwnerWaitingListResponse; | ||
import com.prgrms.catchtable.waiting.service.OwnerWaitingService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RequiredArgsConstructor | ||
@RequestMapping("owner/waitings") | ||
@RestController | ||
public class OwnerWaitingController { | ||
|
||
private final OwnerWaitingService ownerWaitingService; | ||
|
||
@GetMapping("/{ownerId}") | ||
public ResponseEntity<OwnerWaitingListResponse> getOwnerAllWaiting( | ||
@PathVariable("ownerId") Long ownerId) { | ||
OwnerWaitingListResponse response = ownerWaitingService.getOwnerAllWaiting(ownerId); | ||
return ResponseEntity.ok(response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ble/waiting/dto/CreateWaitingRequest.java → ...ing/dto/request/CreateWaitingRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...tchtable/waiting/dto/WaitingResponse.java → ...g/dto/response/MemberWaitingResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/java/com/prgrms/catchtable/waiting/dto/response/OwnerWaitingListResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.prgrms.catchtable.waiting.dto.response; | ||
|
||
import java.util.List; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record OwnerWaitingListResponse( | ||
List<OwnerWaitingResponse> shopWaitings | ||
) { | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/com/prgrms/catchtable/waiting/dto/response/OwnerWaitingResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.prgrms.catchtable.waiting.dto.response; | ||
|
||
import lombok.Builder; | ||
|
||
@Builder | ||
public record OwnerWaitingResponse( | ||
Long waitingId, | ||
int waitingNumber, | ||
Long rank, | ||
int peopleCount | ||
) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/main/java/com/prgrms/catchtable/waiting/service/OwnerWaitingService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.prgrms.catchtable.waiting.service; | ||
|
||
import static com.prgrms.catchtable.common.exception.ErrorCode.NOT_EXIST_OWNER; | ||
import static com.prgrms.catchtable.waiting.dto.WaitingMapper.toOwnerWaitingListResponse; | ||
|
||
import com.prgrms.catchtable.common.exception.custom.BadRequestCustomException; | ||
import com.prgrms.catchtable.owner.domain.Owner; | ||
import com.prgrms.catchtable.owner.repository.OwnerRepository; | ||
import com.prgrms.catchtable.waiting.domain.Waiting; | ||
import com.prgrms.catchtable.waiting.dto.response.OwnerWaitingListResponse; | ||
import com.prgrms.catchtable.waiting.repository.WaitingRepository; | ||
import com.prgrms.catchtable.waiting.repository.waitingline.WaitingLineRepository; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@RequiredArgsConstructor | ||
@Service | ||
public class OwnerWaitingService { | ||
|
||
private final WaitingRepository waitingRepository; | ||
private final WaitingLineRepository waitingLineRepository; | ||
private final OwnerRepository ownerRepository; | ||
|
||
@Transactional(readOnly = true) | ||
public OwnerWaitingListResponse getOwnerAllWaiting(Long ownerId) { | ||
Owner owner = ownerRepository.findById(ownerId) | ||
.orElseThrow(() -> new BadRequestCustomException(NOT_EXIST_OWNER)); | ||
List<Long> waitingIds = waitingLineRepository.getShopWaitingIdsInOrder( | ||
owner.getShop().getId()); | ||
List<Waiting> waitings = waitingRepository.findByIds(waitingIds); | ||
return toOwnerWaitingListResponse(waitings); | ||
} | ||
} |
Oops, something went wrong.