Skip to content

Commit

Permalink
refactor : 코드 리포멧팅
Browse files Browse the repository at this point in the history
  • Loading branch information
hyun2371 committed Jan 8, 2024
1 parent 7afb52a commit f18dbdc
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public class MemberWaitingController {
public ResponseEntity<MemberWaitingResponse> createWaiting(@PathVariable("shopId") Long shopId,
@PathVariable("memberId") Long memberId,
@Valid @RequestBody CreateWaitingRequest request) {
MemberWaitingResponse response = memberWaitingService.createWaiting(shopId, memberId, request);
MemberWaitingResponse response = memberWaitingService.createWaiting(shopId, memberId,
request);
return ResponseEntity.ok(response);
}

Expand All @@ -38,13 +39,15 @@ public ResponseEntity<MemberWaitingResponse> postponeWaiting(
}

@DeleteMapping("/{memberId}")
public ResponseEntity<MemberWaitingResponse> cancelWaiting(@PathVariable("memberId") Long memberId) {
public ResponseEntity<MemberWaitingResponse> cancelWaiting(
@PathVariable("memberId") Long memberId) {
MemberWaitingResponse response = memberWaitingService.cancelWaiting(memberId);
return ResponseEntity.ok(response);
}

@GetMapping("/{memberId}")
public ResponseEntity<MemberWaitingResponse> getWaiting(@PathVariable("memberId") Long memberId) {
public ResponseEntity<MemberWaitingResponse> getWaiting(
@PathVariable("memberId") Long memberId) {
MemberWaitingResponse response = memberWaitingService.getWaiting(memberId);
return ResponseEntity.ok(response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static MemberWaitingResponse toWaitingResponse(Waiting waiting, Long rank
.build();
}

public static OwnerWaitingResponse toOwnerWaitingResponse(Waiting waiting, Long rank){
public static OwnerWaitingResponse toOwnerWaitingResponse(Waiting waiting, Long rank) {
return OwnerWaitingResponse.builder()
.waitingId(waiting.getId())
.waitingNumber(waiting.getWaitingNumber())
Expand All @@ -49,11 +49,11 @@ public static OwnerWaitingResponse toOwnerWaitingResponse(Waiting waiting, Long
.build();
}

public static OwnerWaitingListResponse toOwnerWaitingListResponse(List<Waiting> waitings){
long rank=1L;
public static OwnerWaitingListResponse toOwnerWaitingListResponse(List<Waiting> waitings) {
long rank = 1L;
List<OwnerWaitingResponse> list = new ArrayList<>();
for (Waiting waiting : waitings){
list.add(toOwnerWaitingResponse(waiting,rank++));
for (Waiting waiting : waitings) {
list.add(toOwnerWaitingResponse(waiting, rank++));
}
return new OwnerWaitingListResponse(list);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import lombok.Builder;

@Builder
public record OwnerWaitingListResponse (
public record OwnerWaitingListResponse(
List<OwnerWaitingResponse> shopWaitings
){}
) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import lombok.Builder;

@Builder
public record OwnerWaitingResponse (
public record OwnerWaitingResponse(
Long waitingId,
int waitingNumber,
Long rank,
int peopleCount
){}
) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public <K, V> Object execute(RedisOperations<K, V> operations)
});
}

public List<Long> getShopWaitingIdsInOrder(Long shopId){
public List<Long> getShopWaitingIdsInOrder(Long shopId) {
List<String> stringList = redisTemplate.opsForList().range("s" + shopId, 0, -1);
if (stringList == null) {
throw new BadRequestCustomException(WAITING_DOES_NOT_EXIST);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
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.RedisWaitingLineRepository;
import com.prgrms.catchtable.waiting.repository.waitingline.WaitingLineRepository;
import java.util.List;
import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package com.prgrms.catchtable.owner.fixture;

import static com.prgrms.catchtable.member.domain.Gender.MALE;

import com.prgrms.catchtable.common.data.shop.ShopData;
import com.prgrms.catchtable.member.domain.Gender;
import com.prgrms.catchtable.owner.domain.Owner;
import com.prgrms.catchtable.owner.dto.request.JoinOwnerRequest;
import com.prgrms.catchtable.owner.dto.request.LoginOwnerRequest;
import com.prgrms.catchtable.shop.domain.Shop;
import java.time.LocalDate;
import org.springframework.test.util.ReflectionTestUtils;

import static com.prgrms.catchtable.member.domain.Gender.MALE;


public class OwnerFixture {

Expand All @@ -29,7 +28,7 @@ public static Owner getOwner(String email, String password) {
return owner;
}

public static Owner getOwner(Shop shop){
public static Owner getOwner(Shop shop) {
Owner owner = Owner.builder()
.name("ownerA")
.email("email")
Expand All @@ -43,7 +42,7 @@ public static Owner getOwner(Shop shop){
return owner;
}

public static JoinOwnerRequest getJoinOwnerRequest(String email, String password){
public static JoinOwnerRequest getJoinOwnerRequest(String email, String password) {
return JoinOwnerRequest.builder()
.name("ownerA")
.email(email)
Expand All @@ -54,7 +53,7 @@ public static JoinOwnerRequest getJoinOwnerRequest(String email, String password
.build();
}

public static LoginOwnerRequest getLoginOwnerRequest(String email, String password){
public static LoginOwnerRequest getLoginOwnerRequest(String email, String password) {
return LoginOwnerRequest.builder()
.email(email)
.password(password)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.springframework.data.redis.core.StringRedisTemplate;

class OwnerWaitingControllerTest extends BaseIntegrationTest {

@Autowired
private MemberRepository memberRepository;
@Autowired
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.prgrms.catchtable.waiting.fixture;

import static com.prgrms.catchtable.waiting.domain.WaitingStatus.*;
import static com.prgrms.catchtable.waiting.domain.WaitingStatus.COMPLETED;

import com.prgrms.catchtable.member.domain.Member;
import com.prgrms.catchtable.shop.domain.Shop;
import com.prgrms.catchtable.waiting.domain.Waiting;
import com.prgrms.catchtable.waiting.domain.WaitingStatus;
import java.time.LocalDateTime;
import org.springframework.test.util.ReflectionTestUtils;

public class WaitingFixture {
Expand All @@ -22,7 +20,7 @@ public static Waiting waiting(Member member, Shop shop, int waitingNumber) {

public static Waiting completedWaiting(Member member, Shop shop, int waitingNumber) {
Waiting waiting = waiting(member, shop, waitingNumber);
ReflectionTestUtils.setField(waiting, "status", COMPLETED) ;
ReflectionTestUtils.setField(waiting, "status", COMPLETED);
return waiting;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void countByShopAndCreatedAtBetween() {

@DisplayName("멤버의 아이디 리스트로 Waiting을 조회 가능하다.")
@Test
void findByIdsWithMember(){
void findByIdsWithMember() {
Waiting waiting1 = WaitingFixture.waiting(member1, shop, 1);
Waiting waiting2 = WaitingFixture.waiting(member2, shop, 2);
Waiting waiting3 = WaitingFixture.waiting(member3, shop, 3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ void getOwnerAllWaiting() {
given(ownerRepository.findById(1L)).willReturn(Optional.of(owner));
given(owner.getShop()).willReturn(shop);
given(shop.getId()).willReturn(1L);
given(waitingLineRepository.getShopWaitingIdsInOrder(any(Long.class))).willReturn(waitingIds);
given(waitingLineRepository.getShopWaitingIdsInOrder(any(Long.class))).willReturn(
waitingIds);
given(waitingRepository.findByIds(waitingIds)).willReturn(List.of(waiting));

//when
Expand Down

0 comments on commit f18dbdc

Please sign in to comment.