-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
315 additions
and
73 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
BE/airbnb/src/main/java/airbnb/controller/RoomController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package airbnb.controller; | ||
|
||
import airbnb.request.SearchRequest; | ||
import airbnb.response.RoomDetailPageResponse; | ||
import airbnb.response.RoomResponses; | ||
import airbnb.service.RoomService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api") | ||
public class RoomController { | ||
private final RoomService roomService; | ||
|
||
@GetMapping("/rooms") | ||
public ResponseEntity<RoomResponses> search(SearchRequest searchRequest) { | ||
return new ResponseEntity<>(roomService.findRoomsFilteredBy(searchRequest), HttpStatus.OK); | ||
} | ||
|
||
@GetMapping("/rooms/{roomId}") | ||
public ResponseEntity<RoomDetailPageResponse> viewDetailPage(@PathVariable Long roomId) { | ||
List<String> roomImages = new ArrayList<>(); | ||
roomImages.add("https://a0.muscache.com/im/pictures/a317fbfd-e121-4bcb-ac8b-f5720aaa016d.jpg?im_w=1200"); | ||
roomImages.add("https://a0.muscache.com/im/pictures/8a518449-1d87-4f5b-91db-e40e759db974.jpg?im_w=720"); | ||
roomImages.add("https://a0.muscache.com/im/pictures/cd05cf09-c7cf-4058-b6eb-f030bd4b76f4.jpg?im_w=720"); | ||
roomImages.add("https://a0.muscache.com/im/pictures/4725d94b-3f3b-4567-b5d1-bb08a3a131a0.jpg?im_w=720"); | ||
roomImages.add("https://a0.muscache.com/im/pictures/9273d0a4-a6de-422f-a33b-ea7f78c36504.jpg?im_w=720"); | ||
String title = "Seoul Sunday House (동대문/동묘역 가족 친구여행 2인기준, 주차 불가)"; | ||
String roomDescription = "서울 동대문 상가 위치에 있고 ,도매시장 두타 면세점 ,동묘역 빈티지시장 등 과 가깝습니다. 공항버스랑 지하철 역 도보 5분입니다\n" + | ||
"성인 2명 가격기준, 아이 6살 이하 무료,성인 한명 추가시 20000 원 추가 됩니다."; | ||
double rating = 4.7; | ||
String host = "제인"; | ||
String hostImage = "https://a0.muscache.com/im/pictures/user/524726c2-8633-479c-b7a7-88d964f3c713.jpg?im_w=240"; | ||
int pricePerNight = 85000; | ||
RoomDetailPageResponse detailPage = new RoomDetailPageResponse(roomImages, title, roomDescription, rating, host, hostImage, pricePerNight); | ||
return ResponseEntity.ok(detailPage); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package airbnb.domain; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public enum AmenityEnum { | ||
KITCHEN("주방"), | ||
HEATING("난방"), | ||
AIR_CONDITIONING("에어컨"), | ||
WASHER("세탁기"), | ||
DRYER("건조기"), | ||
WIFI("무선 인터넷"), | ||
BREAKFAST("아침식사"), | ||
INDOOR_FIREPLACE("실내 벽난로"), | ||
IRON("다리미"), | ||
HAIR_DRYER("헤어드라이어"), | ||
DEDICATED_WORKSPACE("업무 전용 공간"), | ||
TV("TV"), | ||
CRIB("아기 침대"), | ||
HIGH_CHAIR("유아용 식탁의자"), | ||
SELF_CHECK_IN("셀프 체크인"), | ||
SMOKE_ALARM("화재경보기"), | ||
CARBON_MONOXIDE_ALARM("일산화탄소 경보기"), | ||
PRIVATE_BATHROOM("욕실 단독 사용"), | ||
BEACHFRONT("해변에 인접"), | ||
WATERFRONT("수변에 인접"); | ||
|
||
private final String name; | ||
|
||
public static List<String> getAmenityList(Amenity amenity) { | ||
List<String> amenities = new ArrayList<>(); | ||
if (amenity.isKitchen()) { | ||
amenities.add(WIFI.name); | ||
} | ||
if (amenity.isWifi()) { | ||
amenities.add(WIFI.name); | ||
} | ||
if (amenity.isAirConditioning()) { | ||
amenities.add(AIR_CONDITIONING.name); | ||
} | ||
if (amenity.isDryer()) { | ||
amenities.add(DRYER.name); | ||
} | ||
return amenities; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package airbnb.domain; | ||
|
||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import javax.persistence.Embeddable; | ||
|
||
@Embeddable | ||
@NoArgsConstructor | ||
@Getter | ||
public class Guest { | ||
private Integer adults; | ||
private Integer children; | ||
private Integer infants; | ||
|
||
public int numberOfGuests() { | ||
return adults + children + infants; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,26 @@ | ||
package airbnb.domain; | ||
|
||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.persistence.*; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor | ||
public class Host { | ||
@Id | ||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
private String name; | ||
private String profileImage; | ||
private int numberOfReviews; | ||
|
||
@OneToMany(mappedBy = "host", cascade = CascadeType.ALL) | ||
@JsonIgnore | ||
@OneToMany(mappedBy = "host") | ||
private List<Room> rooms = new ArrayList<>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.