Skip to content

Commit

Permalink
deploy: main develop 동기화 (#273)
Browse files Browse the repository at this point in the history
* fix : ID 반환 변경

* chore : BOOKED- > WAITING

* feat: exception 분리

* chore: example 변경

* fix: ENUM로직 수정

---------

Co-authored-by: Lee seung hak <90025978+leeseunghakhello@users.noreply.github.com>
Co-authored-by: 강현욱 <43662405+hyunw9@users.noreply.github.com>
Co-authored-by: hyunw9 <rkdgusdnr32@naver.com>
  • Loading branch information
4 people authored Feb 27, 2024
1 parent bc45f7a commit 65e92aa
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.shallwe.domain.reservation.domain.Reservation;
import com.shallwe.domain.reservation.domain.repository.ReservationMemoryPhotoRepository;
import com.shallwe.domain.reservation.exception.InvalidReservationException;
import com.shallwe.domain.reservation.exception.InvalidUserException;
import com.shallwe.domain.reservation.exception.InvalidSenderException;
import com.shallwe.domain.user.domain.User;
import com.shallwe.domain.user.domain.repository.UserRepository;
import com.shallwe.global.config.security.token.UserPrincipal;
Expand All @@ -34,7 +34,7 @@ public class MemoryPhotoServiceImpl implements MemoryPhotoService{
@Override
public List<MemoryPhotoDetailRes> getMemoryPhotoByDate(final UserPrincipal userPrincipal, final LocalDate date) {
User user = userRepository.findById(userPrincipal.getId())
.orElseThrow(InvalidUserException::new);
.orElseThrow(InvalidSenderException::new);
List<Reservation> reservations = reservationRepository.findReservationsByDateAndUser(date, user);

return reservations.stream()
Expand All @@ -46,7 +46,7 @@ public List<MemoryPhotoDetailRes> getMemoryPhotoByDate(final UserPrincipal userP
@Transactional
public Message uploadMemoryPhoto(UserPrincipal userPrincipal, UploadMemoryPhotoReq uploadMemoryPhotoReq) {
User user = userRepository.findById(userPrincipal.getId())
.orElseThrow(InvalidUserException::new);
.orElseThrow(InvalidSenderException::new);

Reservation reservation = reservationRepository.findById(uploadMemoryPhotoReq.getReservationId())
.orElseThrow(InvalidReservationException::new);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.shallwe.domain.reservation.application;

import static com.shallwe.domain.reservation.domain.ReservationStatus.BOOKED;
import static com.shallwe.domain.reservation.domain.ReservationStatus.WAITING;

import com.shallwe.domain.experiencegift.domain.ExperienceGift;
Expand All @@ -13,7 +14,7 @@
import com.shallwe.domain.reservation.dto.response.ValidTimeSlotRes;
import com.shallwe.domain.reservation.exception.InvalidAvailableTimeException;
import com.shallwe.domain.reservation.exception.InvalidReservationException;
import com.shallwe.domain.reservation.exception.InvalidUserException;
import com.shallwe.domain.reservation.exception.InvalidSenderException;
import com.shallwe.domain.shopowner.domain.repository.ShopOwnerRepository;
import com.shallwe.domain.user.domain.repository.UserRepository;
import com.shallwe.global.config.security.token.UserPrincipal;
Expand All @@ -40,7 +41,7 @@ public List<ValidTimeSlotRes> getValidReservationTime(UserPrincipal userPrincipa
.orElseThrow(ExperienceGiftNotFoundException::new);

List<Reservation> reservations = reservationRepository.findAllByExperienceGiftAndReservationStatus(
experienceGift, WAITING)
experienceGift, BOOKED)
.orElseThrow(InvalidAvailableTimeException::new);
System.out.println(Arrays.toString(reservations.toArray()));
return reservations.stream().map(reservation -> ValidTimeSlotRes.builder()
Expand Down Expand Up @@ -83,7 +84,7 @@ public List<ReservationIdOwnerRes> getReservationByDateOwner(UserPrincipal userP

public List<ReservationResponse> findUserReservation(UserPrincipal userPrincipal) {
return reservationRepository.findAllBySenderId(userPrincipal.getId()).orElseThrow(
InvalidUserException::new)
InvalidSenderException::new)
.stream().map(ReservationResponse::toDtoUser).collect(Collectors.toList());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
import com.shallwe.domain.reservation.dto.request.UserReservationCreate;
import com.shallwe.domain.reservation.dto.request.UpdateReservationReq;
import com.shallwe.domain.reservation.exception.InvalidReservationException;
import com.shallwe.domain.reservation.exception.InvalidUserException;
import com.shallwe.domain.reservation.exception.InvalidSenderException;
import com.shallwe.domain.reservation.exception.InvalidReceiverException;
import com.shallwe.domain.shopowner.domain.ShopOwner;
import com.shallwe.domain.shopowner.domain.repository.ShopOwnerRepository;
import com.shallwe.domain.shopowner.exception.InvalidShopOwnerException;
Expand Down Expand Up @@ -45,7 +46,7 @@ public List<ReservationResponse> addOwnerReservation(OwnerReservationCreate owne
ExperienceGift experienceGift = experienceGiftRepository.findById(ownerReservationCreate.getExperienceGiftId())
.orElseThrow(ExperienceGiftNotFoundException::new);

ShopOwner owner = shopOwnerRepository.findById(userPrincipal.getShopOwner().getId())
ShopOwner owner = shopOwnerRepository.findById(userPrincipal.getId())
.orElseThrow(InvalidShopOwnerException::new);

List<Reservation> reservations = OwnerReservationCreate.toEntityForOwner(ownerReservationCreate, experienceGift, owner);
Expand All @@ -58,10 +59,10 @@ public List<ReservationResponse> addOwnerReservation(OwnerReservationCreate owne
@Transactional
public ReservationResponse addUserReservation(UserReservationCreate reservationRequest, UserPrincipal userPrincipal) {
User sender = userRepository.findById(userPrincipal.getId())
.orElseThrow(InvalidUserException::new);
.orElseThrow(InvalidSenderException::new);

User receiver = userRepository.findByPhoneNumberAndStatus(reservationRequest.getPhoneNumber(), Status.ACTIVE)
.orElseThrow(InvalidUserException::new);
.orElseThrow(InvalidReceiverException::new);

ExperienceGift experienceGift = experienceGiftRepository.findById(reservationRequest.getExperienceGiftId())
.orElseThrow(ExperienceGiftNotFoundException::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ public class OwnerReservationCreate {
private Long experienceGiftId;

@Schema(description = "이용 가능 시간 map. \" 날짜1 \": \"시간1\", \"시간2\", \"시간3\" 형식",
example = "\"dateTimeMap\": {\n"
+ " \"2023-12-25\": [\"10:00\", \"13:00\"],\n"
+ " \"2023-12-26\": [\"11:00\", \"14:00\"]\n"
+ " }")
example =
"2024-02-05\": [\"11:00\", \"14:00\"]"
)
private Map<LocalDate, List<LocalTime>> dateTimeMap;

public static List<Reservation> toEntityForOwner(OwnerReservationCreate ownerReservationCreate,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.shallwe.domain.reservation.exception;

public class InvalidReceiverException extends RuntimeException{

public InvalidReceiverException(){super("수신자 정보가 올바르지 않습니다.");}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.shallwe.domain.reservation.exception;

public class InvalidSenderException extends RuntimeException{

public InvalidSenderException(){
super("발송자 정보가 올바르지 않습니다.");
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import static com.shallwe.domain.reservation.domain.ReservationStatus.BOOKED;
import static com.shallwe.domain.reservation.domain.ReservationStatus.CONFIRMED;
import static com.shallwe.domain.reservation.domain.ReservationStatus.WAITING;

import com.shallwe.domain.auth.domain.Token;
import com.shallwe.domain.auth.domain.repository.TokenRepository;
Expand Down

0 comments on commit 65e92aa

Please sign in to comment.