diff --git a/src/main/java/com/jangburich/domain/store/domain/Store.java b/src/main/java/com/jangburich/domain/store/domain/Store.java index 857835b..3dbc358 100644 --- a/src/main/java/com/jangburich/domain/store/domain/Store.java +++ b/src/main/java/com/jangburich/domain/store/domain/Store.java @@ -99,10 +99,6 @@ public static Store of(Owner owner, StoreCreateRequestDTO storeCreateRequestDTO) newStore.setName(storeCreateRequestDTO.getName()); newStore.setCategory(storeCreateRequestDTO.getCategory()); newStore.setRepresentativeImage(storeCreateRequestDTO.getRepresentativeImage()); - newStore.setReservationAvailable(storeCreateRequestDTO.getReservationAvailable()); - newStore.setMaxReservation(storeCreateRequestDTO.getMaxReservation()); - newStore.setMinPrepayment(storeCreateRequestDTO.getMinPrepayment()); - newStore.setPrepaymentDuration(storeCreateRequestDTO.getPrepaymentDuration()); newStore.setIntroduction(storeCreateRequestDTO.getIntroduction()); newStore.setLatitude(storeCreateRequestDTO.getLatitude()); newStore.setLongitude(storeCreateRequestDTO.getLongitude()); diff --git a/src/main/java/com/jangburich/domain/store/domain/StoreAdditionalInfoCreateRequestDTO.java b/src/main/java/com/jangburich/domain/store/domain/StoreAdditionalInfoCreateRequestDTO.java index 9dbb717..e87e09b 100644 --- a/src/main/java/com/jangburich/domain/store/domain/StoreAdditionalInfoCreateRequestDTO.java +++ b/src/main/java/com/jangburich/domain/store/domain/StoreAdditionalInfoCreateRequestDTO.java @@ -1,2 +1,15 @@ -package com.jangburich.domain.store.domain;public class StoreAdditionalInfoCreateRequestDTO { +package com.jangburich.domain.store.domain; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@RequiredArgsConstructor +public class StoreAdditionalInfoCreateRequestDTO { + private Boolean reservationAvailable; + private Long maxReservation; + private Long minPrepayment; + private Long prepaymentDuration; } diff --git a/src/main/java/com/jangburich/domain/store/domain/StoreCreateRequestDTO.java b/src/main/java/com/jangburich/domain/store/domain/StoreCreateRequestDTO.java index cfbeeaf..0ff8a97 100644 --- a/src/main/java/com/jangburich/domain/store/domain/StoreCreateRequestDTO.java +++ b/src/main/java/com/jangburich/domain/store/domain/StoreCreateRequestDTO.java @@ -21,10 +21,6 @@ public class StoreCreateRequestDTO { private Category category; private String representativeImage; - private Boolean reservationAvailable; - private Long maxReservation; - private Long minPrepayment; - private Long prepaymentDuration; private String introduction; private String contactNumber; diff --git a/src/main/java/com/jangburich/domain/store/domain/controller/StoreController.java b/src/main/java/com/jangburich/domain/store/domain/controller/StoreController.java index 9adc069..f588397 100644 --- a/src/main/java/com/jangburich/domain/store/domain/controller/StoreController.java +++ b/src/main/java/com/jangburich/domain/store/domain/controller/StoreController.java @@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.RestController; import com.jangburich.domain.oauth.domain.CustomOAuthUser; +import com.jangburich.domain.store.domain.StoreAdditionalInfoCreateRequestDTO; import com.jangburich.domain.store.domain.StoreCreateRequestDTO; import com.jangburich.domain.store.domain.StoreGetResponseDTO; import com.jangburich.domain.store.domain.StoreUpdateRequestDTO; @@ -39,6 +40,17 @@ public ResponseCustom createStore(Authentication authentication, .build()); } + @Operation(summary = "가게 추가정보 저장", description = "예약 가능 여부, 최소 선결제 금액, 선결제 사용 기간을 저장합니다.") + @PostMapping("/create/additionalInfo") + public ResponseCustom createAdditionalInfo(Authentication authentication, @RequestBody + StoreAdditionalInfoCreateRequestDTO storeAdditionalInfoCreateRequestDTO) { + CustomOAuthUser customOAuthUser = (CustomOAuthUser)authentication.getPrincipal(); + storeService.CreateAdditionalInfo(customOAuthUser, storeAdditionalInfoCreateRequestDTO); + return ResponseCustom.OK(Message.builder() + .message("success") + .build()); + } + @Operation(summary = "가게 정보 수정", description = "가게 정보를 수정합니다.") @PatchMapping("/{storeId}/update") public ResponseCustom updateStore(Authentication authentication, @PathVariable Long storeId, @RequestBody diff --git a/src/main/java/com/jangburich/domain/store/domain/service/StoreService.java b/src/main/java/com/jangburich/domain/store/domain/service/StoreService.java index 0b4b0d7..b185b3b 100644 --- a/src/main/java/com/jangburich/domain/store/domain/service/StoreService.java +++ b/src/main/java/com/jangburich/domain/store/domain/service/StoreService.java @@ -7,6 +7,7 @@ import com.jangburich.domain.owner.domain.Owner; import com.jangburich.domain.owner.domain.repository.OwnerRepository; import com.jangburich.domain.store.domain.Store; +import com.jangburich.domain.store.domain.StoreAdditionalInfoCreateRequestDTO; import com.jangburich.domain.store.domain.StoreCreateRequestDTO; import com.jangburich.domain.store.domain.StoreGetResponseDTO; import com.jangburich.domain.store.domain.StoreUpdateRequestDTO; @@ -37,6 +38,26 @@ public void CreateStore(CustomOAuthUser customOAuth2User, StoreCreateRequestDTO storeRepository.save(Store.of(owner, storeCreateRequestDTO)); } + @Transactional + public void CreateAdditionalInfo(CustomOAuthUser customOAuthUser, + StoreAdditionalInfoCreateRequestDTO storeAdditionalInfoCreateRequestDTO) { + User user = userRepository.findByProviderId(customOAuthUser.getUserId()) + .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); + + Owner owner = ownerRepository.findByUser(user) + .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); + + Store store = storeRepository.findByOwner(owner) + .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); + + store.setReservationAvailable(storeAdditionalInfoCreateRequestDTO.getReservationAvailable()); + store.setMinPrepayment(storeAdditionalInfoCreateRequestDTO.getMinPrepayment()); + store.setMaxReservation(storeAdditionalInfoCreateRequestDTO.getMaxReservation()); + store.setPrepaymentDuration(storeAdditionalInfoCreateRequestDTO.getPrepaymentDuration()); + + storeRepository.save(store); + } + @Transactional public void updateStore(CustomOAuthUser customOAuth2User, Long storeId, StoreUpdateRequestDTO storeUpdateRequestDTO) {