Skip to content

Commit

Permalink
Merge pull request #250 from haedoang/feature/report
Browse files Browse the repository at this point in the history
fix: 방등록 실패 오류 처리
  • Loading branch information
haedoang authored Dec 20, 2023
2 parents cdc6a61 + 37ed822 commit 2271e10
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public record RoomResponse(
@Schema(description = "방문 가능 일자")
LocalDate availableDate,

@Schema(description = "즉시 방문 가능 여부")
Boolean available,

@Schema(description = "방 설명 정보")
String description,

Expand All @@ -62,6 +65,7 @@ public static RoomResponse valueOf(Room entity) {
entity.getRoomInfo(),
entity.getFurnishings(),
entity.getAvailableDate(),
entity.getAvailable(),
entity.getDescription(),
WriterResponse.of(entity.getUser()),
entity.getImageFiles()
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/com/koliving/api/room/domain/Room.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import jakarta.persistence.Column;
import jakarta.persistence.Embedded;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
Expand Down Expand Up @@ -52,6 +54,8 @@ public class Room extends BaseEntity {
@GeneratedValue(strategy = IDENTITY)
private Long id;

private Boolean available = Boolean.FALSE;

@OneToOne
@JoinColumn(name = "user_id", nullable = false)
private User user;
Expand Down Expand Up @@ -82,7 +86,7 @@ public class Room extends BaseEntity {
)
private Set<Furnishing> furnishings = new HashSet<>();

@Column(name = "available_date", nullable = false)
@Column(name = "available_date")
private LocalDate availableDate;

@Lob
Expand All @@ -96,7 +100,7 @@ public class Room extends BaseEntity {
)
private Set<ImageFile> imageFiles;

private Room(Location location, RoomInfo roomInfo, Money deposit, Money monthlyRent, Maintenance maintenance, Set<Furnishing> furnishings, LocalDate availableDate, String description, Set<ImageFile> imageFiles) {
private Room(Location location, RoomInfo roomInfo, Money deposit, Money monthlyRent, Maintenance maintenance, Set<Furnishing> furnishings, LocalDate availableDate, boolean available, String description, Set<ImageFile> imageFiles) {
validate(deposit, monthlyRent, imageFiles);
this.location = location;
this.roomInfo = roomInfo;
Expand All @@ -105,6 +109,7 @@ private Room(Location location, RoomInfo roomInfo, Money deposit, Money monthlyR
this.maintenance = maintenance;
this.furnishings = furnishings;
this.availableDate = availableDate;
this.available = available;
this.description = description;
this.imageFiles = imageFiles;
}
Expand All @@ -120,7 +125,7 @@ public static Room valueOf(
String description,
Set<ImageFile> imageFiles
) {
return new Room(location, info, deposit, monthlyRent, maintenance, furnishings, availableDate, description, imageFiles);
return new Room(location, info, deposit, monthlyRent, maintenance, furnishings, availableDate, Objects.isNull(availableDate), description, imageFiles);
}

private void validate(Money deposit, Money monthlyRent, Set<ImageFile> imageFiles) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private BooleanExpression filterByAvailableDate(LocalDate localDate) {
return null;
}

return room.availableDate.eq(localDate);
return room.availableDate.eq(localDate).or(room.available.isTrue());
}


Expand Down

0 comments on commit 2271e10

Please sign in to comment.