-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [Feat] fastapi와 연동 (#165) * [Feat] 파이썬 서버와 통신하는 서비스 로직 작성 * [Test] 파이썬 서버와 통신하는 테스트 작성 * [Feat] 인기/신간도서 관련 기능 및 API 작성 (#177) * [Feat] 베스트셀러, 최신도서 조회 기능 추가 * [Feat] Spring Scheduler 기능 추가 및 베스트셀러 스케쥴 적용 * [Feat] 파이썬 서버로 요청보내는 로직 추가 (#182) * [Feat] board관련 update event생성 * [Feat] 게시판 수정, 생성 시 비동기 처리를 위한 로직 추가 * [Feat] 읽은 경험시 client추천 update이벤트 추가 * [Feat] 읽은 경험 update시 event발생하는 로직 추가 * [Refactor] 파이썬 서버 주소 수정 * [Feat] 이벤트 핸들러 작성 * [Refactor] 책 키워드 검색 오류 일부 수정 (#185) * [Feat] 좋아요/도움이 되었어요 개수 및 클릭 여부 전달하도록 코드 수정 (#183) Signed-off-by: 이성훈 <[email protected]> --------- Signed-off-by: 이성훈 <[email protected]> Signed-off-by: simjaeyoun <[email protected]> Co-authored-by: simjaeyoun <[email protected]>
- Loading branch information
1 parent
159a926
commit a209333
Showing
65 changed files
with
1,545 additions
and
158 deletions.
There are no files selected for viewing
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
14 changes: 14 additions & 0 deletions
14
src/main/java/kr/KWGraduate/BookPharmacy/domain/board/event/BoardUpdatedEvent.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,14 @@ | ||
package kr.KWGraduate.BookPharmacy.domain.board.event; | ||
|
||
import lombok.Getter; | ||
import org.springframework.context.ApplicationEvent; | ||
|
||
@Getter | ||
public class BoardUpdatedEvent extends ApplicationEvent { | ||
private final Long boardId; | ||
|
||
public BoardUpdatedEvent(Object source, Long boardId) { | ||
super(source); | ||
this.boardId = boardId; | ||
} | ||
} |
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
26 changes: 26 additions & 0 deletions
26
src/main/java/kr/KWGraduate/BookPharmacy/domain/book/api/BestSellerBookController.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,26 @@ | ||
package kr.KWGraduate.BookPharmacy.domain.book.api; | ||
|
||
import kr.KWGraduate.BookPharmacy.domain.book.dto.response.BestSellerBookDto; | ||
import kr.KWGraduate.BookPharmacy.domain.book.service.BestSellerBookService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/api/best-seller") | ||
@RequiredArgsConstructor | ||
public class BestSellerBookController { | ||
|
||
private final BestSellerBookService bestSellerBookService; | ||
|
||
@GetMapping() | ||
public ResponseEntity<List<BestSellerBookDto>> getBestSellerBooks() { | ||
List<BestSellerBookDto> result = bestSellerBookService.getBestSellerBookList(); | ||
|
||
return ResponseEntity.ok(result); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/kr/KWGraduate/BookPharmacy/domain/book/api/NewBookController.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,26 @@ | ||
package kr.KWGraduate.BookPharmacy.domain.book.api; | ||
|
||
import kr.KWGraduate.BookPharmacy.domain.book.dto.response.NewBookDto; | ||
import kr.KWGraduate.BookPharmacy.domain.book.service.NewBookService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/api/new-book") | ||
@RequiredArgsConstructor | ||
public class NewBookController { | ||
|
||
private final NewBookService newBookService; | ||
|
||
@GetMapping() | ||
public ResponseEntity<List<NewBookDto>> getBestSellerBooks() { | ||
List<NewBookDto> result = newBookService.getNewBookList(); | ||
|
||
return ResponseEntity.ok(result); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/kr/KWGraduate/BookPharmacy/domain/book/api/RecommendController.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,48 @@ | ||
package kr.KWGraduate.BookPharmacy.domain.book.api; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import kr.KWGraduate.BookPharmacy.domain.book.service.RecommendService; | ||
import kr.KWGraduate.BookPharmacy.global.security.common.dto.AuthenticationAdapter; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.security.core.userdetails.UserDetails; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/recommend/book") | ||
@Tag(name = "책 추천 api") | ||
public class RecommendController { | ||
|
||
private final RecommendService recommendService; | ||
|
||
@GetMapping("/clientbased/aiprescription") | ||
@Operation(summary = "메인 페이지에 출력되는 ai처방 3개", description = "아이디: string, password: string만 가능, 로그인 필수") | ||
public ResponseEntity<?> getClientBasedAiPrescription(@AuthenticationPrincipal UserDetails userDetails){ | ||
return ResponseEntity.ok(recommendService.getClientBasedAiPrescription((AuthenticationAdapter) userDetails)); | ||
} | ||
|
||
@GetMapping("/clientbased") | ||
@Operation(summary = "메인 페이지에 출력되는 비슷한 유저 기반 책 추천 10개", description = "아이디: string, password: string만 가능,로그인 필수") | ||
public ResponseEntity<?> getClientBasedRecommend(@AuthenticationPrincipal UserDetails userDetails){ | ||
return ResponseEntity.ok(recommendService.getClientBasedRecommend((AuthenticationAdapter) userDetails)); | ||
} | ||
|
||
@GetMapping("/boardbased") | ||
@Operation(summary = "고민 게시판 ai처방", description = "예시 boardId는 167임. 키워드(max=3) 넘겨주면 description은 프론트에서 구현해야함") | ||
public ResponseEntity<?> getBoardBasedRecommend(@RequestParam("boardId") Long boardId){ | ||
return ResponseEntity.ok(recommendService.getBoardBasedRecommend(boardId)); | ||
} | ||
|
||
@GetMapping("/bookbased") | ||
@Operation(summary = "연관 책 리스트", description = "예시 isbn은 9788901126050임. 10개 넘겨짐") | ||
public ResponseEntity<?> getBookBasedRecommend(@RequestParam("isbn") String isbn){ | ||
return ResponseEntity.ok(recommendService.getBookBasedRecommend(isbn)); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/kr/KWGraduate/BookPharmacy/domain/book/domain/BestSellerBook.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,27 @@ | ||
package kr.KWGraduate.BookPharmacy.domain.book.domain; | ||
|
||
import jakarta.persistence.*; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class BestSellerBook { | ||
|
||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@NotNull | ||
@OneToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "book_id") | ||
private Book book; | ||
|
||
@Builder | ||
public BestSellerBook(Book book) { | ||
this.book = book; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/kr/KWGraduate/BookPharmacy/domain/book/domain/BoardRecommend.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,38 @@ | ||
package kr.KWGraduate.BookPharmacy.domain.book.domain; | ||
|
||
import jakarta.persistence.*; | ||
import kr.KWGraduate.BookPharmacy.domain.board.domain.Board; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.hibernate.annotations.OnDelete; | ||
import org.hibernate.annotations.OnDeleteAction; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class BoardRecommend { | ||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "board_recommend_id") | ||
private Long id; | ||
|
||
@OneToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "board_id") | ||
@OnDelete(action = OnDeleteAction.CASCADE) | ||
private Board board; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "book_id") | ||
private Book book; | ||
|
||
private String keywords; | ||
|
||
@Builder | ||
public BoardRecommend(Board board, Book book, String keywords){ | ||
this.board = board; | ||
this.book = book; | ||
this.keywords = keywords; | ||
} | ||
} | ||
|
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
30 changes: 30 additions & 0 deletions
30
src/main/java/kr/KWGraduate/BookPharmacy/domain/book/domain/BookRecommend.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,30 @@ | ||
package kr.KWGraduate.BookPharmacy.domain.book.domain; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class BookRecommend { | ||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "book_recommend_id") | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "recommending_book_id") | ||
private Book recommendingBook; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "recommended_book_id") | ||
private Book recommendedBook; | ||
|
||
@Builder | ||
public BookRecommend(Book recommendedBook, Book recommendingBook){ | ||
this.recommendedBook = recommendedBook; | ||
this.recommendingBook = recommendingBook; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/kr/KWGraduate/BookPharmacy/domain/book/domain/ClientRecommend.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,38 @@ | ||
package kr.KWGraduate.BookPharmacy.domain.book.domain; | ||
|
||
import jakarta.persistence.*; | ||
import kr.KWGraduate.BookPharmacy.domain.client.domain.Client; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.hibernate.annotations.OnDelete; | ||
import org.hibernate.annotations.OnDeleteAction; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class ClientRecommend { | ||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "client_recommend_id") | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "client_id") | ||
@OnDelete(action = OnDeleteAction.CASCADE) | ||
private Client client; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "book_id") | ||
private Book book; | ||
|
||
private Integer rank; | ||
|
||
@Builder | ||
public ClientRecommend(Client client, Book book, Integer rank){ | ||
this.client = client; | ||
this.book = book; | ||
this.rank = rank; | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/kr/KWGraduate/BookPharmacy/domain/book/domain/NewBook.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,20 @@ | ||
package kr.KWGraduate.BookPharmacy.domain.book.domain; | ||
|
||
import jakarta.persistence.*; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.*; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class NewBook { | ||
|
||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@NotNull | ||
@OneToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "book_id") | ||
private Book book; | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/kr/KWGraduate/BookPharmacy/domain/book/dto/response/BestSellerBookDto.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,25 @@ | ||
package kr.KWGraduate.BookPharmacy.domain.book.dto.response; | ||
|
||
import kr.KWGraduate.BookPharmacy.domain.book.domain.BestSellerBook; | ||
import kr.KWGraduate.BookPharmacy.domain.book.domain.Book; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
@Data | ||
public class BestSellerBookDto { | ||
|
||
private String isbn; | ||
private String imageUrl; | ||
private String title; | ||
private String author; | ||
|
||
@Builder | ||
public BestSellerBookDto(BestSellerBook bestSellerBook) { | ||
Book book = bestSellerBook.getBook(); | ||
|
||
this.isbn = book.getIsbn(); | ||
this.imageUrl = book.getImageUrl(); | ||
this.title = book.getTitle(); | ||
this.author = book.getAuthor(); | ||
} | ||
} |
Oops, something went wrong.