Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Team-19][BE] Bongf/Tree 기능 구현 #75

Open
wants to merge 115 commits into
base: dahun-lee-daji
Choose a base branch
from
Open
Changes from 3 commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
f3b304d
[All] Doc : Update Readme.md (#none)
dahun-lee-daji May 17, 2021
c6b142a
feat: Mock API 생성
bong6981 May 20, 2021
035e6ce
feat: 배포를 위한 환경설정 변경
bong6981 May 20, 2021
08d999b
feat: 데이터타입 변경
bong6981 May 21, 2021
6a1ce19
feat: DTO request entity 타입 변경
bong6981 May 21, 2021
7a61a95
feat: Entity 생성
bong6981 May 21, 2021
4cc210c
feat: Entity 생성(#8)
bong6981 May 21, 2021
0b4248b
chore : 데이터베이스 경로변경(#8)
bong6981 May 21, 2021
818e5e9
Merge pull request #19 from dahun-lee-daji/be/feat/8/entity
bong6981 May 21, 2021
43b63aa
chore: merge를 위한 커밋(#8)
bong6981 May 21, 2021
690caf6
chore: 머지를 위한 커밋(#8)
bong6981 May 21, 2021
0a01de9
feat: Contorller 분리(#16)
bong6981 May 21, 2021
57a2e5e
feat: gitignore 파일에 build 폴더 추가(#16)
bong6981 May 22, 2021
7baf303
feat: gitignore 파일 수정
bong6981 May 22, 2021
fed88da
chore : Room클래스에 변수명 수정
choitree May 22, 2021
1b8c75f
chore : 추적되고 있는 불필요한 .class 파일 삭제
choitree May 22, 2021
0172265
feat: entity내 파일들을 폴더로 묶음(#16)
bong6981 May 23, 2021
9c12f6c
feat: entity 관계 설정(#16)
bong6981 May 23, 2021
51f516b
feat: 관계적용을 한 스키마 변경(#16)
bong6981 May 24, 2021
7a2e23b
feat: entity 변경(#16)
bong6981 May 24, 2021
4cd7faf
Merge branch 'be/feat/16/get_booking' of https://github.com/dahun-lee…
bong6981 May 24, 2021
714ba6f
feat: 스키마 sql수정(#16)
bong6981 May 24, 2021
33257b9
feat: entity와 sql 일치하지 않은 부분 수정(#16)
bong6981 May 24, 2021
3c59509
feat: Booking 관계변경(#16)
bong6981 May 24, 2021
2dd678d
feat: Booking DAO에서 findById, save 구현(#16)
bong6981 May 25, 2021
cc92ed5
chore : .idea 디렉토리 내 파일캐시 삭제 불가능으로 커밋
choitree May 25, 2021
dd73db4
chore : 추적되고 있는 불필요한 파일 삭제
choitree May 25, 2021
3abd2e0
feat: 예외 추가(#16)
bong6981 May 25, 2021
aeb32ce
feat: NotFoundException 에 대한 예외 처리 구현(#16)
bong6981 May 25, 2021
7c286b3
Feat : post_booking 기능 구현(#11)
choitree May 25, 2021
8dd6bec
Feat : post_booking 기능 구현(#11)
choitree May 25, 2021
2e2977f
chore : 오타 수정 (#11)
choitree May 25, 2021
9de7a9f
chore : 16브랜치에서 pull한 코드 커밋
choitree May 25, 2021
81924e6
chore : 16브랜치에서 pull한 코드 커밋
choitree May 25, 2021
3e9187b
chore : 16브랜치에서 pull한 코드 커밋
choitree May 25, 2021
0c4b392
feat : 예약 삭제 기능 구현 (#13)
choitree May 25, 2021
f23589e
feat : 예약 삭제 기능 구현 (#13)
choitree May 25, 2021
cadf812
chore : BookingRequestDTO 수정
choitree May 25, 2021
e59c61c
chore : BookingDAO 수정
choitree May 25, 2021
f791edf
feat: Booking 가져오는 기능 구현완료(#16)
bong6981 May 25, 2021
46df044
feat: Booking 가져오는 기능 구현완료(#16)
bong6981 May 25, 2021
c069c84
feat: 생성자 추가하여 null 전달 삭제(#16)
bong6981 May 25, 2021
bf67dad
feat: null전달을 피하기 위한 생성자 추가(#16)
bong6981 May 25, 2021
0f14d7f
feat: null전달을 피하기 위한 생성자 추가 (#16)
bong6981 May 25, 2021
113ad6b
chore : PR 리뷰 반영
choitree May 25, 2021
7575b0b
chore : PR 리뷰 반영
choitree May 25, 2021
5a298b9
chore : PR 리뷰 반영
choitree May 25, 2021
7c0f810
chore : PR 리뷰 반영
choitree May 25, 2021
972ef88
chore : PR 리뷰 반영
choitree May 25, 2021
993efe5
chore : PR 리뷰 반영
choitree May 25, 2021
bfebe33
feat: booking 목록 가져오는 기능 구현(#15)
bong6981 May 25, 2021
7001965
Merge pull request #20 from dahun-lee-daji/be/feat/11/post_booking
bong6981 May 26, 2021
740f5f6
Merge branch 'Dev-BE' into be/feat/13/delete_booking
choitree May 26, 2021
5f3cb5a
Merge pull request #21 from dahun-lee-daji/be/feat/13/delete_booking
bong6981 May 26, 2021
20fbf95
chore : PR 리뷰 반영
choitree May 26, 2021
45f5367
Merge branch 'Dev-BE' into be/feat/16/get_booking
bong6981 May 26, 2021
a21e5e5
Merge pull request #22 from dahun-lee-daji/be/feat/16/get_booking
choitree May 26, 2021
34f82d8
Merge branch 'Dev-BE' into be/feat/15/get_bookings
bong6981 May 26, 2021
c55dc26
Merge pull request #23 from dahun-lee-daji/be/feat/15/get_bookings
choitree May 26, 2021
f20a594
feat: UserDao에서 조회 기능 구현(#9)
bong6981 May 26, 2021
6168e13
Delete .idea directory
choitree May 26, 2021
d3c4a60
Delete be/.idea directory
choitree May 26, 2021
e9975dd
Delete be/airbnb/.idea directory
choitree May 26, 2021
5e3640f
Delete .DS_Store
choitree May 26, 2021
562098d
Delete be/airbnb/.idea directory
choitree May 26, 2021
993165a
Delete be/.idea directory
choitree May 26, 2021
02c89dc
Delete .idea directory
choitree May 26, 2021
b493a2e
feat: RoomReponseDTO 반환기능 구현(#9)
bong6981 May 26, 2021
8f7dc88
fix: PR을 위한 코드 수정(#9)
bong6981 May 26, 2021
6035c42
feat: Main페이지 데이터 가져오기 구현(#10)
bong6981 May 27, 2021
f046a64
style: 불필요한 개행삭제(#10)
bong6981 May 27, 2021
bc3b79b
chore: 요구사항 보면서 부족한 부분 더함(#10)
bong6981 May 27, 2021
da968bc
feat : wishlist 추가 기능 구현 (#12)
choitree May 27, 2021
a6db7e3
feat : Room 안에 필드들 묶음(#10)
bong6981 May 27, 2021
65b03c8
feat: Get Room 기능 구현(#18)
bong6981 May 27, 2021
d8cbfa5
Merge pull request #24 from dahun-lee-daji/be/feat/9/get_wishlists
choitree May 28, 2021
eb8412b
Merge pull request #25 from dahun-lee-daji/be/feat/10/get_main
choitree May 28, 2021
c56591e
feat : wishlist 삭제 기능 구현 (#14)
choitree May 28, 2021
b334585
chore : wishlist를 리스트에 add하는 기능 분리(#12)
choitree May 28, 2021
8a67c1e
style : sql문 내부에 ; 제거
choitree May 28, 2021
8ca8e4c
chore : wishlist를 리스트에서 제거하는 기능 user 클래스로 분리
choitree May 28, 2021
e39d1b6
Merge branch 'Dev-BE' into be/feat/12/post_wishlist
bong6981 May 28, 2021
96aa51a
Merge pull request #29 from dahun-lee-daji/be/feat/12/post_wishlist
bong6981 May 28, 2021
881924f
Merge branch 'Dev-BE' into be/feat/14/delete_wishlist
bong6981 May 28, 2021
7fa0d02
Merge pull request #30 from dahun-lee-daji/be/feat/14/delete_wishlist
bong6981 May 28, 2021
28e638e
feat: dto 변수명 변경(#18)
bong6981 May 28, 2021
74cff12
feat: 수정된 entity에 맞게 테이블 필드 변경(#31)
bong6981 May 29, 2021
b608548
chore: 요구사항 보면서 부족한 부분 더함(#10)
bong6981 May 27, 2021
ac175d5
feat : Room 안에 필드들 묶음(#10)
bong6981 May 27, 2021
87546a0
feat: Get Room 기능 구현(#18)
bong6981 May 29, 2021
3b1bd96
feat: dto 변수명 변경(#18)
bong6981 May 28, 2021
49ed78b
feat: 수정된 entity에 맞게 테이블 필드 변경(#31)
bong6981 May 29, 2021
14f1652
Merge branch 'be/feat/31/findBookingById' of https://github.com/dahun…
bong6981 May 29, 2021
3305847
feat: Merge from DEV-BE(#31)
bong6981 May 29, 2021
e0b8033
Merge pull request #33 from dahun-lee-daji/be/feat/31/findBookingById
choitree May 29, 2021
7649197
feat : 가격 범위 검색하는 기능 구현 (#17)
choitree May 29, 2021
6cf4a03
feat : 가격 범위 검색하는 기능 구현 (#17)
choitree May 29, 2021
a1055c6
Merge pull request #34 from dahun-lee-daji/be/feat/17/price_range
bong6981 May 30, 2021
a8cafa0
chore : 위도 경도를 기준으로 반경 계산하는 로직을 dao로 분리 (#17)
choitree May 30, 2021
08daac3
feat: 예상 금액 가져오는 기능 구현(#35)
bong6981 May 30, 2021
2adec48
feat: Booking에서 totalPrice 계산할 수 있는 메소드 추가(#35)
bong6981 May 30, 2021
2163ad2
Merge pull request #36 from dahun-lee-daji/be/feat/35/getEstimate
choitree May 30, 2021
a128a79
feat : 전체 검색하는 기능(#32)
choitree May 30, 2021
4b369fe
feat : 전체 검색 기능 구현 (#32)
choitree May 30, 2021
3263dd9
chore : 풀하고 충돌 해결
choitree May 30, 2021
28a45ec
feat : 전체 검색하는 기능(#32)
choitree May 30, 2021
9dd79f2
style : 주석 삭제 및 인덴팅 수정(#32)
choitree May 30, 2021
06044b1
Merge pull request #37 from dahun-lee-daji/be/feat/32/search_rooms
bong6981 May 31, 2021
ca045b7
chore: room 데이터 20개입력
bong6981 May 31, 2021
edf5dbc
refactor: RoomController와 RoomService 리팩토링
bong6981 May 31, 2021
5f5b212
refactor: Booking 생성자를 builder 패턴으로 변경
bong6981 Jun 4, 2021
ee3a3c2
refactor : 코드 리팩토링
choitree Jun 4, 2021
0a8e755
Merge branch 'be/refactor/refactor' of https://github.com/dahun-lee-d…
choitree Jun 4, 2021
68c6c57
refactor : 코드 리팩토링
choitree Jun 4, 2021
82cbbb6
Merge pull request #39 from dahun-lee-daji/be/refactor/refactor
choitree Jun 4, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
package com.team19.airbnb.controller;

import com.team19.airbnb.ResponseBody;
import com.team19.airbnb.domain.room.Host;
import com.team19.airbnb.dto.BookingRequestDTO;
import com.team19.airbnb.dto.BookingResponseDTO;
import com.team19.airbnb.service.BookingService;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

@RequestMapping("/bookings")
@RestController
public class BookingController {

@@ -21,45 +18,23 @@ public BookingController(BookingService bookingService) {
this.bookingService = bookingService;
}

@PostMapping("/bookings/{userId}")
public void bookRoom(@RequestBody BookingRequestDTO bookingRequestDTO, @PathVariable Long userId) {
bookingService.createBooking(bookingRequestDTO, userId);
@PostMapping("/{userId}")
public void book(@RequestBody BookingRequestDTO bookingRequestDTO) {
System.out.println(bookingRequestDTO.toString());
}

@GetMapping("/bookings/{userId}")
public List<BookingResponseDTO> getBookings() {
return null;
@GetMapping("/{userId}")
public ResponseBody<List<BookingResponseDTO>> showBookings(@PathVariable Long userId) {
return ResponseBody.ok(bookingService.showBookings(userId));
}

@GetMapping("/bookings/{bookingId}/{userId}")
public ResponseBody<BookingResponseDTO> getBooking(@PathVariable Long bookingId, @PathVariable Long userId) {
return ResponseBody.ok(bookingService.findBooking(userId, bookingId));
@GetMapping("/{bookingId}/{userId}")
public ResponseBody<BookingResponseDTO> showBooking(@PathVariable Long bookingId, @PathVariable Long userId) {
return ResponseBody.ok(bookingService.showBooking(userId, bookingId));
}

@DeleteMapping("/bookings/{bookingId}/{userId}")
@DeleteMapping("/{bookingId}/{userId}")
public void deleteBooking(@PathVariable Long bookingId, @PathVariable Long userId) {
bookingService.delete(bookingId, userId);
}

private BookingResponseDTO createBookingResponseDTO(Long bookingId) {
LocalDate checkIn = LocalDate.of(2020,3,20);
LocalDate checkOut = LocalDate.of(2020, 4, 4);
Long roomId = 1L;
String roomName = "코드스쿼드";
String roomType = "원룸";
List<String> images = new ArrayList<>();
images.add("image1");
images.add("image2");
images.add("image3");
Host host = Host.create("홍길동", "image");
int guest = 5;
BigDecimal totalPrice = new BigDecimal(100000);
return new BookingResponseDTO(bookingId,
checkIn, checkOut,
roomId, roomName, roomType,
images,
host,
guest,
totalPrice);
}
}
Original file line number Diff line number Diff line change
@@ -35,20 +35,24 @@ public Booking save(Booking booking) {
}

public Optional<Booking> findById(Long id) {
String selectById = "SELECT * FROM booking WHERE id = ?";
String selectById = "SELECT `id`, `check_in`, `check_out`, `guest`, `total_price`, `user`, `room` FROM `booking` WHERE id = ?;";
List<Booking> result = jdbcTemplate.query(selectById, bookingRowMapper(), id);
return result.stream().findAny();
}

public List<Booking> findAllByUser(Long user) {
String findAllByUser = "SELECT `id`, `check_in`, `check_out`, `guest`, `total_price`, `user`, `room` FROM `booking` WHERE `user` = ?;";
return jdbcTemplate.query(findAllByUser, bookingRowMapper(), user);
}

private RowMapper<Booking> bookingRowMapper() {
return (rs, rowNum) -> {
Booking booking = Booking.create(rs.getLong("id"),
return Booking.create(rs.getLong("id"),
rs.getObject("check_in", LocalDate.class), rs.getObject("check_out", LocalDate.class),
rs.getInt("guest"),
rs.getBigDecimal("total_price"),
rs.getLong("user"),
rs.getLong("room"));
return booking;
};
}
// public Optional<Booking> findById(Long id) {
Original file line number Diff line number Diff line change
@@ -2,32 +2,58 @@

import com.team19.airbnb.domain.Booking;
import com.team19.airbnb.domain.User;
import com.team19.airbnb.domain.room.Room;
import com.team19.airbnb.dto.BookingResponseDTO;
import com.team19.airbnb.exception.BookingNotFoundException;
import com.team19.airbnb.exception.RoomNotFoundException;
import com.team19.airbnb.exception.UserNotFoundException;
import com.team19.airbnb.repository.BookingDAO;
import com.team19.airbnb.repository.RoomRepository;
import com.team19.airbnb.repository.UserRepository;
import org.springframework.stereotype.Service;

import com.team19.airbnb.dto.BookingRequestDTO;
import com.team19.airbnb.repository.UserDAO;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class BookingService {

private final BookingDAO bookingDAO;
private final UserRepository userRepository;
private final UserDAO userDAO;

public BookingService(BookingDAO bookingDAO, UserRepository userRepository, UserDAO userDAO) {
private final UserRepository userRepository;
private final RoomRepository roomRepository;

public BookingService(BookingDAO bookingDAO, UserRepository userRepository, UserDAO userDAO, RoomRepository roomRepository) {
this.bookingDAO = bookingDAO;
this.userRepository = userRepository;
this.userDAO = userDAO;
this.roomRepository = roomRepository;
}

public void findBooking(Long userId, Long bookingId) {
public BookingResponseDTO showBooking(Long userId, Long bookingId) {
//userService를 참조할지 userRepository를 참조할지 고민 (삭제할 부분이라 repository 참조)
//OAuth 구현식 삭제될 user 체크
User user = userRepository.findById(userId).orElseThrow(UserNotFoundException::new);

Booking booking = bookingDAO.findById(bookingId).orElseThrow(BookingNotFoundException::new);
return toResponseDTO(booking);
}

public List<BookingResponseDTO> showBookings(Long userId) {
//OAuth 구현식 삭제될 user 체크
User user = userRepository.findById(userId).orElseThrow(UserNotFoundException::new);

return bookingDAO.findAllByUser(userId).stream()
.map(this::toResponseDTO)
.collect(Collectors.toList());
}

private BookingResponseDTO toResponseDTO(Booking booking) {
Room room = roomRepository.findById(booking.getRoom()).orElseThrow(RoomNotFoundException::new);
return new BookingResponseDTO.Builder(booking, room).build();
}

public void createBooking(BookingRequestDTO bookingRequestDTO, Long userId) {