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

[Merge] 2024-06-07 버전 적용 #218

Merged
merged 57 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
e3102f5
[Feat] 공통 예외 처리 클래스 작성 (#125)
seonghooni May 10, 2024
ae677be
[Hotfix] 05/08 버전 복구
seonghooni May 11, 2024
ad18971
[Refactor] 한줄처방 작성시 독서경험에도 추가하는 로직 작성 (#129)
seonghooni May 12, 2024
a0ee241
[Refactor] 공통 질문 수정 및 오타 수정 (#130)
Simy2 May 14, 2024
ac2057d
[Feat] 키워드와 함께 책을 검색하는 로직 추가 (#135)
seonghooni May 14, 2024
39b72d0
[Refactor] 회원 관련 전반적인 리펙토링 및 api 기능 추가 (#133)
Simy2 May 14, 2024
5dfe36a
[Refactor] 유저정보 api url, description 일부 수정
seonghooni May 14, 2024
c3d5271
Merge branch 'main' into develop
seonghooni May 14, 2024
75ab412
[Refactor] 한줄처방 키워드 매핑 적용
seonghooni May 15, 2024
a3d65a2
Merge branch 'develop' of https://github.com/kw-bookmedicine/backend …
seonghooni May 15, 2024
0deb6f2
Merge branch 'main' into develop
seonghooni May 15, 2024
fa9c26d
[Refactor] DTO의 LocalDateTime -> LocalDate로 변경
seonghooni May 15, 2024
2886ab0
Merge branch 'main' into develop
seonghooni May 15, 2024
5098c49
[Refactor] 마이페이지 api수정 (#140)
Simy2 May 18, 2024
bb37d88
[Refactor] 보드삭제 전 보드와 관련된 처방전 및 answer삭제하도록 설정 (#142)
Simy2 May 18, 2024
3d799f0
[Feat] 처방전 상세정보 조회 API 작성 (#144)
seonghooni May 18, 2024
b91690b
[Feat] 한줄처방 검색어 또는 키워드로 조회 기능 추가 (#147)
seonghooni May 18, 2024
c929eae
[Refactor] 질문사항 수정 (#152)
Simy2 May 21, 2024
471bffc
[Feat] 유저 관심사 테이블 및 입력 API 작성 (#151)
seonghooni May 21, 2024
4cd3042
Merge branch 'main' into develop
seonghooni May 21, 2024
5a12378
.
seonghooni May 22, 2024
57f2186
[Refactor] 한줄처방 수정하는 로직 변경 (#155)
seonghooni May 22, 2024
ecb1593
[Refactor] 책 상세정보 조회 오류 및 기타 수정 (#159)
seonghooni May 28, 2024
c85d79a
[Merge] 메인 브랜치로부터 병합 (#162)
seonghooni May 28, 2024
b0aac86
[Refactor] 쿠키의 maxage값 삭제 (#168)
Simy2 May 31, 2024
504e69f
[Feat] '좋아요, 도움이 되었어요' 기능 추가 (#164)
seonghooni May 31, 2024
fc859ad
Merge branch 'main' into develop
seonghooni May 31, 2024
578769e
[Refactor] 각종 API 미흡한 부분 수정 (#173)
seonghooni Jun 2, 2024
87ee424
[Feat] 추천 테이블 생성 및 로직 작성 (#171)
Simy2 Jun 2, 2024
ee7e38f
[Refactor] 내 게시판 가지고 오는 api에 nickname추가 (#180)
Simy2 Jun 2, 2024
22ac8d8
[Refactor] Oauth관련 버그 수정 (#174)
Simy2 Jun 2, 2024
f603d4a
[Feat] fastapi와 연동 (#165)
Simy2 Jun 2, 2024
bb2c9fa
[Feat] 인기/신간도서 관련 기능 및 API 작성 (#177)
seonghooni Jun 3, 2024
148de47
[Feat] 파이썬 서버로 요청보내는 로직 추가 (#182)
Simy2 Jun 3, 2024
aa79aa6
[Refactor] 책 키워드 검색 오류 일부 수정 (#185)
seonghooni Jun 3, 2024
7cf2379
[Feat] 좋아요/도움이 되었어요 개수 및 클릭 여부 전달하도록 코드 수정 (#183)
seonghooni Jun 3, 2024
86274fa
Merge branch 'main' into develop
seonghooni Jun 3, 2024
a6167ea
[Refactor] 2024-06-03 merge 후 발생 오류 해결
seonghooni Jun 3, 2024
c3cb7d9
Merge branch 'main' into develop
seonghooni Jun 3, 2024
50cd01d
[Refactor] 2024-06-03 merge 후 발생 오류 해결(2)
seonghooni Jun 3, 2024
c049793
Merge branch 'develop' of https://github.com/kw-bookmedicine/backend …
seonghooni Jun 3, 2024
9b17ee5
[Refactor] 모든 게시판을 조회하는 api에 description을 추가 (#193)
Simy2 Jun 3, 2024
d91b231
[Refactor] Emotion 추가 및 삭제 서비스 로직 오류 수정 (#195)
seonghooni Jun 4, 2024
753bff9
[Refactor] oauth로그인 시 스프링 세션에 정보 추가 (#199)
Simy2 Jun 4, 2024
c5e8ff9
[Refactor] 추천 관련 로직 수정 (#201)
Simy2 Jun 4, 2024
9b32d4b
[Refactor]내 처방전 리턴값, oauth 리턴값, 유저 관련 추천 로직 수정 (#203)
Simy2 Jun 4, 2024
b6921bf
Merge branch 'main' into develop
Simy2 Jun 4, 2024
78f1049
[Refactor] 책 조회시 처방전 개수 및 인기순으로 조회기능 추가 (#205)
seonghooni Jun 5, 2024
28a1493
[Feat] 관심사 기반 추천 기능 추가 (#211)
seonghooni Jun 6, 2024
9756fb6
[Refactor] 마이 페이지에서 출력할때 oauth로그인 여부 출력 (#209)
Simy2 Jun 6, 2024
a09344d
[Refactor] 데이터베이스 인스턴스 연결 주소 변경
seonghooni Jun 6, 2024
caa2139
Merge branch 'main' into develop
seonghooni Jun 6, 2024
5522727
[Hotfix] 메인페이지 API 및 검색 API 오류 수정
seonghooni Jun 6, 2024
4245073
[Hotfix] 메인페이지 API 및 검색 API 오류 수정
seonghooni Jun 6, 2024
bf83833
Merge branch 'develop' of https://github.com/kw-bookmedicine/backend …
seonghooni Jun 6, 2024
33b41f4
[Feat] 관심사 기반 추천 스케쥴링 코드 작성 (#217)
seonghooni Jun 7, 2024
cf83b2f
[Refactor] 서브모듈 업데이트 06/07
seonghooni Jun 7, 2024
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 @@ -48,7 +48,7 @@ public ResponseEntity<BookDto> getBookDetails(@RequestParam(name ="isbn") String
@GetMapping(value = "/list/middle")
public ResponseEntity<Page<BookDto>> getBookListByMiddleCategory(@RequestParam(name = "name") String middleCategoryName,
@RequestParam(name = "page") int page, @RequestParam(name = "size") int size) {
PageRequest pageRequest = PageRequest.of(page, size, Sort.by("count").descending());
PageRequest pageRequest = PageRequest.of(page, size, Sort.by("viewCount").descending());
Page<BookDto> result = bookService.getBookPageByMiddleCategory(middleCategoryName, pageRequest);

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("view-count").descending());
PageRequest pageRequest = PageRequest.of(0, 6, Sort.by("viewCount").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("view-count").descending());
PageRequest pageRequest = PageRequest.of(0, 6, Sort.by("viewCount").descending());

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public class Book {
private String publishingHouse; // 출판사명
private String publishYear; // 발행년도
private String content; // 책내용
private int reviewNum; // 리뷰 개수
private String mediaFlagNumber; // 미디어구분명
private String imageUrl; // 이미지 url
private int viewCount; // 조회된 횟수
Expand All @@ -51,14 +50,13 @@ public class Book {

@Builder
public Book(String isbn, String title, String author, String publishingHouse, String publishYear, String content,
int reviewNum, Categories bigCategory, Categories middleCategory, String imageUrl, int viewCount, int oneLineCount) {
Categories bigCategory, Categories middleCategory, String imageUrl, int viewCount, int oneLineCount) {
this.isbn = isbn;
this.title = title;
this.author = author;
this.publishingHouse = publishingHouse;
this.publishYear = publishYear;
this.content = content;
this.reviewNum = reviewNum;
this.bigCategory = bigCategory;
this.middleCategory = middleCategory;
this.imageUrl = imageUrl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ public class InterestRecommend {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "book_id")
private Book book;

public InterestRecommend(Book b) {
this.middleCategory = b.getMiddleCategory();
this.book = b;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import kr.KWGraduate.BookPharmacy.domain.book.dto.response.BookSearchResponseDto;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
Expand Down Expand Up @@ -76,4 +77,10 @@ public interface BookRepository extends JpaRepository<Book, Long> {
"where (LOWER(b.title) like %:searchWord% or LOWER(b.author) like %:searchWord%) and ki.name in :names")
Page<Book> findPagingBySearchWordAndKeyword(@Param("searchWord") String searchWord,
@Param("names") List<String> keywordNameList, Pageable pageable);

@Query("select b from Book b inner join ReadExperience re on b.id = re.book.id " +
"join fetch b.middleCategory m " +
"where m.id = :categoryId group by b.id " +
"order by count(re.id) desc")
Slice<Book> findPopularByCategory(@Param("categoryId") Long categoryId, Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@

public interface InterestRecommendRepository extends JpaRepository<InterestRecommend, Long> {

@EntityGraph(attributePaths = {"book"})
@Query("select ir from InterestRecommend ir join fetch ir.middleCategory mc where mc.id in :categoryIdList")
@Query(value = "select ir.* from book_pharmacy_local.interest_recommend as ir " +
"inner join book_pharmacy_local.book as b on ir.book_id = b.book_id " +
"order by RAND()", nativeQuery = true)
List<InterestRecommend> findRandAll(Pageable pageable);

@Query(value = "select ir.* from book_pharmacy_local.interest_recommend as ir " +
"inner join book_pharmacy_local.book as b on ir.book_id = b.book_id " +
"inner join book_pharmacy_local.categories as c on ir.category_id = c.category_id " +
"where c.category_id in :categoryIdList order by RAND()"
, nativeQuery = true)
List<InterestRecommend> findByInterestList(@Param("categoryIdList") List<Long> categoryIdList, Pageable pageable);
}

Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package kr.KWGraduate.BookPharmacy.domain.book.service;

import kr.KWGraduate.BookPharmacy.domain.book.domain.Book;
import kr.KWGraduate.BookPharmacy.domain.book.domain.ClientRecommend;
import kr.KWGraduate.BookPharmacy.domain.book.domain.InterestRecommend;
import kr.KWGraduate.BookPharmacy.domain.book.dto.response.BoardBasedRecommendDto;
import kr.KWGraduate.BookPharmacy.domain.book.dto.response.BookBasedRecommendDto;
import kr.KWGraduate.BookPharmacy.domain.book.dto.response.ClientBasedRecommendDto;
import kr.KWGraduate.BookPharmacy.domain.book.repository.BoardRecommendRepository;
import kr.KWGraduate.BookPharmacy.domain.book.repository.BookRecommendRepository;
import kr.KWGraduate.BookPharmacy.domain.book.repository.ClientRecommendRepository;
import kr.KWGraduate.BookPharmacy.domain.book.repository.InterestRecommendRepository;
import kr.KWGraduate.BookPharmacy.domain.book.repository.*;
import kr.KWGraduate.BookPharmacy.domain.category.domain.Categories;
import kr.KWGraduate.BookPharmacy.domain.category.repository.CategoryRepository;
import kr.KWGraduate.BookPharmacy.domain.client.domain.Client;
import kr.KWGraduate.BookPharmacy.domain.client.repository.ClientRepository;
import kr.KWGraduate.BookPharmacy.domain.interest.domain.Interest;
Expand Down Expand Up @@ -37,6 +37,8 @@ public class RecommendService {
private final InterestRecommendRepository interestRecommendRepository;
private final ClientRepository clientRepository;
private final ReadExperienceRepository readExperienceRepository;
private final CategoryRepository categoryRepository;
private final BookRepository bookRepository;

public List<ClientBasedRecommendDto> getClientBasedAiPrescription(AuthenticationAdapter authentication){
String username = authentication.getUsername();
Expand Down Expand Up @@ -125,17 +127,36 @@ public List<BookBasedRecommendDto> getBookBasedRecommend(String isbn){
.collect(Collectors.toList());
}

// 스케쥴러에 의해 관심사 추천 도서를 등록하는 함수
public void setInterestRecommend() {

interestRecommendRepository.deleteAll();
interestRecommendRepository.flush();

List<Categories> childCategories = categoryRepository.findChildCategories();

PageRequest pageRequest = PageRequest.of(0, 30);

for (Categories category: childCategories) {
Long categoryId = category.getId();
List<Book> popularBookList = bookRepository.findPopularByCategory(categoryId, pageRequest).getContent();
List<InterestRecommend> interestRecommendList = popularBookList.stream()
.map(book -> new InterestRecommend(book)).collect(Collectors.toList());
interestRecommendRepository.saveAll(interestRecommendList);
}
}

private List<InterestRecommend> getInterestRecommend(String username, Pageable pageable) {
List<Interest> interestList = interestRepository.findByLoginId(username); // 유저의 관심사리스트

List<InterestRecommend> interestRecommend;

if(interestList.isEmpty()) // 유저가 관심사를 하나도 등록하지 않았을 경우
{
interestRecommend = interestRecommendRepository.findAll(pageable).getContent();
interestRecommend = interestRecommendRepository.findRandAll(pageable);

}else{
List<Long> interestIdList = interestList.stream().map(interest -> interest.getId()).collect(Collectors.toList());
List<Long> interestIdList = interestList.stream().map(interest -> interest.getCategory().getId()).collect(Collectors.toList());
interestRecommend = interestRecommendRepository.findByInterestList(interestIdList, pageable);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

Expand All @@ -13,5 +14,5 @@ public interface InterestRepository extends JpaRepository<Interest, Long> {
// 유저의 아이디로 관심사를 조회함
@EntityGraph(attributePaths = {"category"})
@Query("select i from Interest i join fetch i.client c where c.loginId = :loginId")
List<Interest> findByLoginId(String loginId);
List<Interest> findByLoginId(@Param("loginId") String loginId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@Table(indexes = {
@Index(name = "read_experience_index", columnList = "book_id, client_id", unique = true) // 중복된 독서경험이 추가되지 않도록 하기 위함
})
public class ReadExperience extends BaseTimeEntity {
public class ReadExperience {

@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "read_experience_id")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package kr.KWGraduate.BookPharmacy.global.common.service;

import kr.KWGraduate.BookPharmacy.domain.book.service.BestSellerBookService;
import kr.KWGraduate.BookPharmacy.domain.book.service.RecommendService;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
Expand All @@ -12,9 +13,15 @@
public class BookSchedulerService {

private final BestSellerBookService bestSellerBookService;
private final RecommendService recommendService;

@Scheduled(cron = "0 0 0 * * *", zone = "Asia/Seoul") // 매일 서울기준, 00시 00분 00초에 실행
public void setBestSeller() {
bestSellerBookService.setBestSellerBooks();
}

@Scheduled(cron = "1 0 0 * * *", zone = "Asia/Seoul") // 매일 서울기준, 00시 00분 00초에 실행
public void setInterestRecommend() {
recommendService.setInterestRecommend();
}
}
2 changes: 1 addition & 1 deletion submodule-config