Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -20,6 +20,7 @@
public class BookLogController {

private final BookLogService bookLogService;

@PostMapping("/booklog")
public ResponseEntity<?> addBooklog(
@PathVariable("mybook_id") Long myBookId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ public BookLog addBookLog(Long myBookId, BookLogReq request) {
.booklogType(BookLogType.THINK.name())
.build();

return bookLogRepository.save(bookLog);
BookLog insertedBookLog = bookLogRepository.save(bookLog);

myBook.updateNowPage(request.getPage());
myBookRepository.save(myBook);

return insertedBookLog;
}

@Override
Expand Down Expand Up @@ -69,7 +74,12 @@ public BookLog addCompleted(Long myBookId, CompletedReq request) {
.booklogType(BookLogType.REVIEW.name())
.build();

return bookLogRepository.save(bookLog);
BookLog insertedBookLog = bookLogRepository.save(bookLog);

myBook.updateNowPage(myBook.getBook().getPage());
myBookRepository.save(myBook);

return insertedBookLog;
}

@Override
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/ikdaman/domain/mybook/entity/MyBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public void updateToInactive() {
this.status = Status.INACTIVE;
}

public void updateNowPage(int page) {
this.nowPage = page;
}

@Builder
public MyBook(int mybookId, UUID memberId, Book book, int nowPage, Boolean isReading, MyBook.Status status, List<BookLog> bookLogs) {
this.mybookId = mybookId;
Expand Down