Skip to content

Commit

Permalink
Merge branch 'main' into feature/record-api
Browse files Browse the repository at this point in the history
  • Loading branch information
tfer2442 committed Feb 9, 2023
2 parents 1076fde + 6e9b29c commit 40585d8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/main/java/KNU/Navibook/server/controller/BookController.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,17 @@ public Book bookBorrow(@RequestBody Map<String, Object> requestData) {
book.setBookShelf(null);
book.setSelfFloor(null);


LocalDate nowDate = LocalDate.now(ZoneId.of("Asia/Seoul")); // 대출 현재 날짜 입력
Record record = new Record();
record.setTakeDate(nowDate.toString());
record.setBook(book);
record.setUser(user);

bookService.saveBook(book);
Book borrowedbook = bookService.saveBook(book);
recordService.saveRecord(record);
return book;

return borrowedbook;
}
//bookid에 맞는 book 없으면 404
//userid에 맞는 user 없으면 404
Expand Down Expand Up @@ -172,9 +174,9 @@ public Book bookReturn(@RequestBody Map<String, Object> requestData) {
Record record = records.get(records.size()-1); // 그 후 레코드의 마지막 값 가져오기 why? 그 레코드의 giveDate 만 바꿔줘야 하니까
record.setGiveDate(nowDate.toString());

bookService.saveBook(book);
Book returnedbook = bookService.saveBook(book);
recordService.saveRecord(record);

return book;
return returnedbook;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public List<BookInfo> returnBookInfo(@PathVariable("bookName") String name){

@GetMapping("/random/{count}")
@ResponseBody
public List<BookInfo> returnBookInfoRandom(@PathVariable("count") int count){
public List<BookInfo> returnBookInfoRandom(@PathVariable("count") Integer count){
return bookInfoService.findRandom(count);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public interface BookInfoRepository extends JpaRepository<BookInfo, Long>{
BookInfo findByid(Long id);

//@Query이용하여 jpql작성
@Query(value = "SELECT * FROM BOOK_INFO order by RAND() limit :count",nativeQuery = true)
@Query(value = "SELECT * FROM book_info order by RAND() limit :count",nativeQuery = true)
List<BookInfo> findRandom(@Param("count") int count);


Expand Down

0 comments on commit 40585d8

Please sign in to comment.