Skip to content

Commit

Permalink
[Merge] 2024-11-11 버전 적용 (#224)
Browse files Browse the repository at this point in the history

* MySQL 검색 기능 최적화 적용 및 README 추가 (#223)

* [Refactor] isbn으로 조회기능에서 id로 조회하도록 변경

* refactor: index 최적화 처리

* [Chore] QueryDSL 설정파일 추가

* [Refactor] 책 검색 쿼리 ngram parser 적용

* [Refactor] Book, Category 레포지토리계층 일부 DTO 조회로 대체

* [Docs] README.md 프로젝트 소개 작성

Signed-off-by: 이성훈 <[email protected]>

---------

Signed-off-by: 이성훈 <[email protected]>

* [Chore] Submodule 업데이트 내역 반영

* Update submodule-config

---------

Signed-off-by: 이성훈 <[email protected]>
Signed-off-by: simjaeyoun <[email protected]>
Co-authored-by: simjaeyoun <[email protected]>
  • Loading branch information
seonghooni and Simy2 authored Nov 11, 2024
1 parent 31ab171 commit 0c1d6e2
Show file tree
Hide file tree
Showing 58 changed files with 437 additions and 233 deletions.
44 changes: 22 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
# 누구나 할 수 있는 책 추천 웹서비스 '책국'
![image](https://github.com/user-attachments/assets/2a56b77c-d3c9-49b4-ab50-6da87f094b9b)

## Issue Convention
URL : https://www.bookpharmacy.store/

##### 1. 제목에 다음의 내용을 포함하기
- [ 이슈의 종류 ]
-> Feat, Docs, Refactor, Bug
- 이슈가 무엇인지
### 프로젝트 소개
책을 선택하는 데 어려움이 있던 당신, 혹은 책으로 힐링했던 그 순간을 공유하고 싶다면 책국이 처방해줍니다!
- 나의 고민을 글로 작성하여 다른 사람들과 AI로부터 추천받을 수 있습니다.
- 내가 책을 처방하는 의사가 되어 다른 사람들의 마음을 치유해줄 수 있습니다.
- 혹은 모두에게 간단하게 한줄처방을 작성할 수 있습니다.
- 나의 독서이력, 관심사를 등록해 AI로부터 책을 추천받을 수 있습니다.
- 책에 대해 검색하고, 연관된 책 목록을 추천받을 수 있습니다.

##### 2. 제목에 다음의 형식을 지키기
_ex) [Feat] 한줄처방/고민상담 서비스 로직 작성_
> 개발기간 : 2023.12.21 ~ 2024.06.15
##### 3. 태그는 종류별로 1개씩 선택하기
- Priority : Critical, High, Medium, Low
- Status : Available, Complete, In Progress, On Hold
- Type : Bug, Document, Feature, Refactor
> Frontend : 배영현, 강대원
> Backend : 이성훈, 심재윤
> Machine Learning : 이소정
##### 4. 브랜치를 분기할때 브랜치명에는 이슈의 번호를 적기
_ex) feat/#64_board_prescription_service_
-----

## PR Convention
### 기술 스택 (백앤드)
#### Environment
<img src="https://img.shields.io/badge/Intellij-000000?style=for-the-badge&logo=intellijidea&logoColor=white"> <img src="https://img.shields.io/badge/git-F05032?style=for-the-badge&logo=git&logoColor=white"> <img src="https://img.shields.io/badge/github-181717?style=for-the-badge&logo=github&logoColor=white">

##### 1. 제목에 다음의 형식을 지키기
_ex) [Feat] 한줄처방/고민상담 서비스 로직 작성_
##### 2. PR Template에 맞게 작성하기
##### 3. Overview에 관련된 이슈를 적고 연결하기
_ex) ```closed [Feat] 한줄처방/고민상담 서비스 로직 작성#67```
##### 4. Merge 전에 PR을 알리고 코드리뷰를 받기
##### 5. Conflict 발생시 같이 Merge하기
##### 6. Conflict 없이 코드리뷰가 완료되면 PR을 올린 사람이 Merge하기
#### Development
<img src="https://img.shields.io/badge/java-007396?style=for-the-badge&logo=java&logoColor=white"> <img src="https://img.shields.io/badge/spring-6DB33F?style=for-the-badge&logo=spring&logoColor=white"> <img src="https://img.shields.io/badge/springboot-6DB33F?style=for-the-badge&logo=springboot&logoColor=white"> <img src="https://img.shields.io/badge/python-3776AB?style=for-the-badge&logo=python&logoColor=white"> <img src="https://img.shields.io/badge/fastapi-009688?style=for-the-badge&logo=fastapi&logoColor=white"> <img src="https://img.shields.io/badge/mysql-4479A1?style=for-the-badge&logo=mysql&logoColor=white">

#### Communication
<img src="https://img.shields.io/badge/slack-4A154B?style=for-the-badge&logo=slack&logoColor=white"> <img src="https://img.shields.io/badge/notion-000000?style=for-the-badge&logo=notion&logoColor=white"> <img src="https://img.shields.io/badge/figma-F24E1E?style=for-the-badge&logo=figma&logoColor=white">
29 changes: 21 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,32 @@ repositories {
mavenCentral()
}

task copyPrivate(type: Copy) {
copy {
from './submodule-config'
include '*.yml'
into 'src/main/resources'
}
}
//task copyPrivate(type: Copy) {
// copy {
// from './submodule-config'
// include '*.yml'
// into 'src/main/resources'
// }
//}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'com.github.gavlyukovskiy:p6spy-spring-boot-starter:1.9.0'
implementation 'org.springframework.boot:spring-boot-starter-validation'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'org.mariadb.jdbc:mariadb-java-client'
// runtimeOnly 'org.mariadb.jdbc:mariadb-java-client'
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2'

// Querydsl 추가
implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta'
annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jakarta"
annotationProcessor 'jakarta.annotation:jakarta.annotation-api'
annotationProcessor 'jakarta.persistence:jakarta.persistence-api'

implementation 'com.github.gavlyukovskiy:p6spy-spring-boot-starter:1.9.0' // 개발 단계시 사용 (운영에서는 주석 처리)
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
Expand All @@ -57,3 +65,8 @@ dependencies {
tasks.named('test') {
useJUnitPlatform()
}

clean {
delete file('src/main/generated')
}

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Getter
@ToString(of = {"id" , "question","answer"})
@Table(indexes = {
@Index(name = "answer_question_index", columnList = "question")
})
public class Answer {
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public ResponseEntity<Page<BoardConcernPageDto>> getBoard(
@RequestParam("page") int page,
@RequestParam("size") int size
){
PageRequest pageRequest = PageRequest.of(page,size, Sort.by("createdDate").descending());
PageRequest pageRequest = PageRequest.of(page,size, Sort.by("id").descending());
return ResponseEntity.ok(boardService.getBoards(pageRequest));
}

Expand All @@ -52,7 +52,7 @@ public ResponseEntity<Page<BoardConcernPageDto>> getBoard(
,@RequestParam("page") int page
,@RequestParam("size") int size)
{
PageRequest pageRequest = PageRequest.of(page,size, Sort.by("createdDate").descending());
PageRequest pageRequest = PageRequest.of(page,size, Sort.by("id").descending());
return ResponseEntity.ok(boardService.getBoards(pageRequest, keyword));
}

Expand All @@ -63,7 +63,7 @@ public ResponseEntity<Page<BoardConcernPageDto>> getBoard(
@RequestParam("page") int page,
@RequestParam("size") int size
){
PageRequest pageRequest = PageRequest.of(page,size, Sort.by("createdDate").descending());
PageRequest pageRequest = PageRequest.of(page,size, Sort.by("id").descending());
return ResponseEntity.ok(boardService.getBoards(pageRequest,searchKeyword));
}
@GetMapping("/{boardId}")
Expand Down Expand Up @@ -99,7 +99,7 @@ public ResponseEntity<Page<BoardMyPageDto>> getBoard(
@RequestParam("page") int page,
@RequestParam("size") int size
){
PageRequest pageRequest = PageRequest.of(page,size, Sort.by("createdDate").descending());
PageRequest pageRequest = PageRequest.of(page,size, Sort.by("id").descending());

return ResponseEntity.ok(boardService.getMyBoards(pageRequest, userDetails));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
@Getter
@ToString(of = {"id" , "title","description","keyword"})
@Table(indexes = {
@Index(name = "board_keyword_index", columnList = "keyword"),
@Index(name = "board_created_date_index", columnList = "created_date")
@Index(name = "board_keyword_index", columnList = "keyword")
})
public class Board extends BaseTimeEntity {
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,33 +35,30 @@ public class BookController {
private final BookService bookService;
private final CategoryService categoryService;

@Operation(summary = "책 상세정보 출력", description = "isbn으로 책 상세정보 조회하기(parameter로 isbn 입력")
@Operation(summary = "책 상세정보 출력", description = "id로 책 상세정보 조회하기(parameter로 id 입력")
@GetMapping(value = "/detail")
public ResponseEntity<BookDto> getBookDetails(@RequestParam(name ="isbn") String isbn){
BookDto result = bookService.getBookDetails(isbn);
public ResponseEntity<BookDto> getBookDetails(@RequestParam(name ="id") Long id){
BookDto result = bookService.getBookDetails(id);

return ResponseEntity.ok(result);
}

@Operation(summary = "중분류에 해당하는 book 리스트 요청", description = "중분류에 해당하는 book들을 페이징해서 " +
"요청 예) /api/book/list/middle?name=한국소설&page=0&size=5")
@GetMapping(value = "/list/middle")
public ResponseEntity<Page<BookDto>> getBookListByMiddleCategory(@RequestParam(name = "name") String middleCategoryName,
public ResponseEntity<Page<BookSearchResponseDto>> getBookListByMiddleCategory(@RequestParam(name = "categoryId") Long categoryId,
@RequestParam(name = "page") int page, @RequestParam(name = "size") int size) {
PageRequest pageRequest = PageRequest.of(page, size, Sort.by("viewCount").descending());
Page<BookDto> result = bookService.getBookPageByMiddleCategory(middleCategoryName, pageRequest);
PageRequest pageRequest = PageRequest.of(page, size, Sort.by("view_count").descending());
Page<BookSearchResponseDto> result = bookService.getBookPageByMiddleCategory(categoryId, pageRequest);

return ResponseEntity.ok(result);
}

@Operation(summary = "대분류에 속하는 중분류들에 대한 각각의 book 리스트 요청", description = "Map<중분류 이름, 책리스트>로 반환")
@GetMapping(value = "/list/big")
public ResponseEntity<Object> getListMapByBigCategory(@RequestParam(name = "name") String bigCategoryName){
public ResponseEntity<Object> getListMapByBigCategory(@RequestParam(name = "id") Long bigCategoryId){

// 페이징 사이즈를 10으로 할당
PageRequest pageRequest = PageRequest.of(0,10);

List<Map<String, Object>> result = bookService.getBookListByBigCategoryChildren(bigCategoryName, pageRequest);
List<Map<String, Object>> result = bookService.getBookListByBigCategoryChildren(bigCategoryId);

return ResponseEntity.ok(result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class BookSearchController {
@GetMapping(params = {"title", "target=modal"})
public ResponseEntity<List<BookSearchResponseDto>> getBookListByTitleOnModal(@RequestParam(name = "title") String searchWord){

PageRequest pageRequest = PageRequest.of(0, 6, Sort.by("viewCount").descending());
PageRequest pageRequest = PageRequest.of(0, 6, Sort.by("one_line_count").descending());

List<BookSearchResponseDto> result = bookSearchService.searchBookOnModalByTitleContainingSearchWord(searchWord, pageRequest);

Expand All @@ -39,7 +39,7 @@ public ResponseEntity<List<BookSearchResponseDto>> getBookListByTitleOnModal(@Re
@GetMapping(params = {"author", "target=modal"})
public ResponseEntity<List<BookSearchResponseDto>> getBookListByAuthorOnModal(@RequestParam(name = "author") String searchWord){

PageRequest pageRequest = PageRequest.of(0, 6, Sort.by("viewCount").descending());
PageRequest pageRequest = PageRequest.of(0, 6, Sort.by("one_line_count").descending());

List<BookSearchResponseDto> result = bookSearchService.searchBookOnModalByAuthorContainingSearchWord(searchWord, pageRequest);

Expand All @@ -56,9 +56,9 @@ public ResponseEntity<Page<BookDto>> getBookListByTitleOnPageOrderByCount(@Reque
PageRequest pageRequest = PageRequest.of(page, size);

if(sortType.equals("oneline-count")){
pageRequest = PageRequest.of(page, size, Sort.by("oneLineCount").descending());
pageRequest = PageRequest.of(page, size, Sort.by("one_line_count").descending());
}else if(sortType.equals("view-count")){
pageRequest = PageRequest.of(page, size, Sort.by("viewCount").descending());
pageRequest = PageRequest.of(page, size, Sort.by("view_count").descending());
}

Page<BookDto> bookDtoList = bookSearchService.searchBookOnPageByTitleContainingSearchWord(searchWord, pageRequest);
Expand All @@ -76,9 +76,9 @@ public ResponseEntity<Page<BookDto>> getBookListByAuthorOnPage(@RequestParam(nam
PageRequest pageRequest = PageRequest.of(page, size);

if(sortType.equals("oneline-count")){
pageRequest = PageRequest.of(page, size, Sort.by("oneLineCount").descending());
pageRequest = PageRequest.of(page, size, Sort.by("one_line_count").descending());
}else if(sortType.equals("view-count")){
pageRequest = PageRequest.of(page, size, Sort.by("viewCount").descending());
pageRequest = PageRequest.of(page, size, Sort.by("view_count").descending());
}

Page<BookDto> bookDtoList = bookSearchService.searchBookOnPageByAuthorContainingSearchWord(searchWord, pageRequest);
Expand Down Expand Up @@ -108,9 +108,9 @@ public ResponseEntity<Page<BookDto>> getBookListBySearchAndKeyword(@RequestBody
PageRequest pageRequest = PageRequest.of(page, size);

if(sortType.equals("oneline-count")){
pageRequest = PageRequest.of(page, size, Sort.by("oneLineCount").descending());
pageRequest = PageRequest.of(page, size, Sort.by("one_line_count").descending());
}else if(sortType.equals("view-count")){
pageRequest = PageRequest.of(page, size, Sort.by("viewCount").descending());
pageRequest = PageRequest.of(page, size, Sort.by("view_count").descending());
}

List<String> keywordList = dto.getKeywordList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public ResponseEntity<?> getBoardBasedRecommend(@RequestParam("boardId") Long bo
}

@GetMapping("/bookbased")
@Operation(summary = "연관 책 리스트", description = "예시 isbn은 9788901126050임. 10개 넘겨짐")
public ResponseEntity<?> getBookBasedRecommend(@RequestParam("isbn") String isbn){
return ResponseEntity.ok(recommendService.getBookBasedRecommend(isbn));
@Operation(summary = "연관 책 리스트", description = "10개 넘겨짐")
public ResponseEntity<?> getBookBasedRecommend(@RequestParam("bookId") Long bookId){
return ResponseEntity.ok(recommendService.getBookBasedRecommend(bookId));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@ToString(of = {"isbn", "title", "author", "bigCategory", "middleCategory", "imageUrl", "count"})
@Table(indexes = {
@Index(name = "book_isbn_index", columnList = "isbn", unique = true),
@Index(name = "title_index", columnList = "title"),
@Index(name = "view_count_index", columnList = "view_count"),
@Index(name = "one_line_count_index", columnList = "one_line_count", unique = false)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@Data
public class BestSellerBookDto {

private String isbn;
private Long bookId;
private String imageUrl;
private String title;
private String author;
Expand All @@ -17,7 +17,7 @@ public class BestSellerBookDto {
public BestSellerBookDto(BestSellerBook bestSellerBook) {
Book book = bestSellerBook.getBook();

this.isbn = book.getIsbn();
this.bookId = book.getId();
this.imageUrl = book.getImageUrl();
this.title = book.getTitle();
this.author = book.getAuthor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@NoArgsConstructor
public class BoardBasedRecommendDto {
private Long id;
private String isbn;
private Long bookId;
private String imageUrl;
private String title;
private String author;
Expand All @@ -22,7 +22,7 @@ public BoardBasedRecommendDto(BoardRecommend boardRecommend){
Book book = boardRecommend.getBook();

this.id = book.getId();
this.isbn = book.getIsbn();
this.bookId = book.getId();
this.imageUrl = book.getImageUrl();
this.title = book.getTitle();
this.author = book.getAuthor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@NoArgsConstructor
public class BookBasedRecommendDto {
private Long id;
private String isbn;
private Long bookId;
private String imageUrl;
private String title;
private String author;
Expand All @@ -19,7 +19,7 @@ public class BookBasedRecommendDto {
public BookBasedRecommendDto(BookRecommend bookRecommend){
Book book = bookRecommend.getRecommendingBook();
this.id = book.getId();
this.isbn = book.getIsbn();
this.bookId = book.getId();
this.imageUrl = book.getImageUrl();
this.title = book.getTitle();
this.author = book.getAuthor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@Data
public class BookDto {

private String isbn;
private Long bookId;
private String title;
private String author; // 저자명
private String publishingHouse; // 출판사명
Expand All @@ -27,7 +27,7 @@ public class BookDto {
private List<KeywordItemDto> keywordItemList; // 키워드 리스트

public BookDto(Book book) {
this.isbn = book.getIsbn();
this.bookId = book.getId();
this.title = book.getTitle();
this.author = book.getAuthor();
this.publishingHouse = book.getPublishingHouse();
Expand All @@ -39,9 +39,9 @@ public BookDto(Book book) {
}

@Builder
public BookDto(String isbn, String title, String author, String publishingHouse, String publicYear, String content, String mediaFlagNumber,
public BookDto(Long bookId, String title, String author, String publishingHouse, String publicYear, String content, String mediaFlagNumber,
String middleCategoryName, String imageUrl) {
this.isbn = isbn;
this.bookId = bookId;
this.title = title;
this.author = author;
this.publishingHouse = publishingHouse;
Expand Down Expand Up @@ -111,7 +111,6 @@ public static Book toEntity(BookDto bookDto){
.author(bookDto.getAuthor())
.publishingHouse(bookDto.getPublishingHouse())
.publishYear(bookDto.getPublicYear())
.isbn(bookDto.getIsbn())
.content(bookDto.getContent())
.imageUrl(bookDto.getImageUrl())
.build();
Expand Down
Loading

0 comments on commit 0c1d6e2

Please sign in to comment.