Skip to content

Commit

Permalink
Merge branch 'develop' into feature/star-refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jo0oy committed Dec 15, 2023
2 parents 7d84355 + 478cbde commit 0ec6c48
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.fc.shimpyo_be.domain.reservationproduct.constant;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ReservationProductValidationConstants {

// validation constraint value
public static final String DATE_REGEX = "^\\d{4}-\\d{2}-\\d{2}$";
public static final String PHONE_NUMBER_REGEX = "^01(?:0|1|[6-9])-\\d{4}-\\d{4}$";
public static final int PRICE_MIN_VALUE = 0;

// validation message
public static final String DATE_PATTERN_MESSAGE = "올바른 날짜 형식이 아닙니다.(yyyy-MM-dd 형식으로 입력하세요.)";
public static final String PHONE_NUMBER_PATTERN_MESSAGE = "올바른 휴대전화 번호를 입력하세요.('-' 포함)";
public static final String PRICE_MIN_MESSAGE = "객실 이용 금액은 0원 이상부터 가능합니다.";
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public class ReservationProductRestController {

@DeleteMapping("/{id}")
public ResponseEntity<ResponseDto<Void>> cancel(@PathVariable Long id) {
log.info("[api][DELETE] /api/reservation-products");

reservationProductService.cancel(id, securityUtil.getCurrentMemberId());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,24 @@
import jakarta.validation.constraints.Pattern;
import lombok.Builder;

import static com.fc.shimpyo_be.domain.reservationproduct.constant.ReservationProductValidationConstants.*;

@Builder
public record ReservationProductRequestDto(
@NotNull
Long cartId,
@NotNull
Long roomId,
@Pattern(regexp = "^\\d{4}-\\d{2}-\\d{2}$", message = "올바른 날짜 형식이 아닙니다.(yyyy-MM-dd 형식으로 입력하세요.)")
@Pattern(regexp = DATE_REGEX, message = DATE_PATTERN_MESSAGE)
String startDate,
@Pattern(regexp = "^\\d{4}-\\d{2}-\\d{2}$", message = "올바른 날짜 형식이 아닙니다.(yyyy-MM-dd 형식으로 입력하세요.)")
@Pattern(regexp = DATE_REGEX, message = DATE_PATTERN_MESSAGE)
String endDate,
@NotBlank
String visitorName,
@NotBlank
@Pattern(regexp = "^0\\d{1,2}-\\d{3,4}-\\d{4}$")
@Pattern(regexp = PHONE_NUMBER_REGEX, message = PHONE_NUMBER_PATTERN_MESSAGE)
String visitorPhone,
@Min(value = 0, message = "객실 이용 금액은 0원 이상부터 가능합니다.")
@Min(value = PRICE_MIN_VALUE, message = PRICE_MIN_MESSAGE)
Integer price
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class ReservationProduct extends BaseTimeEntity {
private String visitorPhone;

@Builder
public ReservationProduct(
private ReservationProduct(
Long id,
Reservation reservation,
Room room,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class ReservationProductService {

@Transactional
public void cancel(Long id, Long memberId) {
log.info("{} ::: {}", getClass().getSimpleName(), "cancel");

ReservationProduct reservationProduct = reservationProductRepository.findByIdWithReservation(id)
.orElseThrow(ReservationProductNotFoundException::new);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.fc.shimpyo_be.domain.room.constant;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class RoomValidationConstants {

// validation constraint value
public static final int ROOM_REQ_MIN_SIZE = 1;
public static final int ROOM_REQ_MAX_SIZE = 3;
public static final long ROOMID_MIN_VALUE = 1;

// validation message
public static final String ROOM_REQ_SIZE_MESSAGE = "최소 1개, 최대 3개의 객실 식별자 정보가 필요합니다.";
public static final String ROOMID_MIN_MESSAGE = "객실 식별자는 최소 1 이상이어야 합니다.";
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import java.util.List;

import static com.fc.shimpyo_be.domain.room.constant.RoomValidationConstants.*;

@Slf4j
@RequiredArgsConstructor
@Validated
Expand All @@ -28,10 +30,9 @@ public class RoomRestController {

@GetMapping
public ResponseEntity<ResponseDto<RoomListWithProductInfoResponseDto>> getRoomsWithProductInfo(
@RequestParam @Size(min = 1, max = 3, message = "최소 1개, 최대 3개의 객실 식별자 정보가 필요합니다.")
List<@Min(value = 1, message = "객실 식별자는 최소 1 이상이어야 합니다.") Long> roomIds
@RequestParam @Size(min = ROOM_REQ_MIN_SIZE, max = ROOM_REQ_MAX_SIZE, message = ROOM_REQ_SIZE_MESSAGE)
List<@Min(value = ROOMID_MIN_VALUE, message = ROOMID_MIN_MESSAGE) Long> roomIds
) {
log.debug("GET /api/rooms, roomIds : {}", roomIds);

return ResponseEntity
.status(HttpStatus.OK)
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/fc/shimpyo_be/domain/room/entity/Room.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.OneToOne;

import java.time.LocalTime;
import java.util.ArrayList;
import java.util.List;

import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
Expand Down Expand Up @@ -66,7 +68,7 @@ public class Room {
private List<RoomImage> roomImages = new ArrayList<>();

@Builder
public Room(
private Room(
Long id,
Product product,
long code,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class RoomImage {
private String description;

@Builder
public RoomImage(Long id, Room room, String photoUrl, String description) {
private RoomImage(Long id, Room room, String photoUrl, String description) {
this.id = id;
this.room = room;
this.photoUrl = photoUrl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class RoomOption {
private boolean hairDryer;

@Builder
public RoomOption(Long id, boolean bathFacility, boolean bath, boolean homeTheater,
private RoomOption(Long id, boolean bathFacility, boolean bath, boolean homeTheater,
boolean airCondition, boolean tv, boolean pc, boolean cable, boolean internet,
boolean refrigerator, boolean toiletries, boolean sofa, boolean cooking, boolean diningTable,
boolean hairDryer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class RoomPrice {
private int peakWeekendMinFee;

@Builder
public RoomPrice(Long id, int offWeekDaysMinFee, int offWeekendMinFee, int peakWeekDaysMinFee,
private RoomPrice(Long id, int offWeekDaysMinFee, int offWeekendMinFee, int peakWeekDaysMinFee,
int peakWeekendMinFee) {
this.id = id;
this.offWeekDaysMinFee = offWeekDaysMinFee;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class RoomService {

@Transactional(readOnly = true)
public List<RoomWithProductResponseDto> getRoomsWithProductInfo(List<Long> roomIds) {
log.debug("{} ::: {}", getClass().getSimpleName(), "getRoomsWithProductInfo");

return roomRepository.findAllInIdsWithProductAndPrice(roomIds)
.stream()
Expand All @@ -31,7 +30,6 @@ public List<RoomWithProductResponseDto> getRoomsWithProductInfo(List<Long> roomI

@Transactional(readOnly = true)
public List<Long> getRoomIdsByCode(Long roomCode) {
log.debug("{} ::: {}", getClass().getSimpleName(), "getRoomIdListByRoomCode");

return roomRepository.findIdsByCode(roomCode);
}
Expand Down

0 comments on commit 0ec6c48

Please sign in to comment.