Skip to content

Commit

Permalink
fix: 방문 상태 변경 API 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeongh00 committed Aug 5, 2024
1 parent 866d276 commit cf6efd5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import com.likelion.coremodule.VisitList.domain.VisitList;
import com.likelion.coremodule.VisitList.service.VisitListQueryService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@RequiredArgsConstructor
@Transactional
@Slf4j
public class VisitListSaveUseCase {

private final VisitListQueryService visitListQueryService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public ApplicationResponse<String> changeToVisited(@RequestHeader(AuthConsts.ACC
@PathVariable Long visitlistId) {

visitListSaveUseCase.updateToVisited(accessToken, visitlistId);
return ApplicationResponse.ok("준비 완료로 변경했습니다.");
return ApplicationResponse.ok("방문 완료로 변경했습니다.");
}

// 방문 리스트 삭제
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public Map<LocalDate, List<OrderInfo>> findAllOrdersByDate(String accessToken) {

OrderInfo orderInfo = new OrderInfo(
order.getId(),
"결제 확인 대기",
"결제 확인 완료",
market.getName(),
store.getName(),
store.getImageUrl(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,32 @@ public class VisitList extends BaseEntity {

private LocalDate visitedDate;

@Enumerated(EnumType.STRING)
@Column(name = "visit_status", nullable = false)
private VisitStatus visit_status;

public void updateToPayment() {
this.visit_status = VisitStatus.PAYMENT;
}

public void updateToPreparing() {
if (this.visit_status != VisitStatus.PAYMENT) {
throw new IllegalStateException("Visit can only be updated to PREPARING from PAYMENT status");
}
this.visit_status = VisitStatus.PREPARING;
}

public void updateToPrepared() {
if (this.visit_status != VisitStatus.PREPARING) {
throw new IllegalStateException("Visit can only be updated to PREPARED from PREPARING status");
}
this.visit_status = VisitStatus.PREPARED;
}

public void updateToVisited() {
if (this.visit_status != VisitStatus.PREPARED) {
throw new IllegalStateException("Visit can only be updated to VISITED from PREPARED status");
}
this.visit_status = VisitStatus.VISITED;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public VisitList findVisitListById(Long id) {
return visitListRepository.findById(id).orElseThrow(() -> new VisitException(VisitErrorCode.NO_VISIT_LIST_INFO));
}

public void saveVisitList(VisitList visitList) {
visitListRepository.save(visitList);
}

public List<VisitList> findVisitListsByUserId(Long userId) {
return visitListRepository.findVisitListsByUserUserId(userId);
}
Expand Down

0 comments on commit cf6efd5

Please sign in to comment.