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

[Refactor] 각종 API 미흡한 부분 수정 #173

Merged
merged 4 commits into from
Jun 2, 2024

Conversation

seonghooni
Copy link
Contributor

Overview

각종 API 미흡한 부분 수정
closed #172

변경 유형

  • 기능 추가
  • 버그 수정
  • 성능 개선
  • TC 추가
  • 기타 설정(환경 설정, CI/CD, 문서...)

수정 내용

  • [마이페이지] GET (/client) : 내가 남긴 고민과 처방 개수 필드 추가 필요
  • [중분류 페이지] GET (/api/book/list/middle) : total page 정보 필요함.
  • [중분류 페이지] 책에 대한 keyword가 전부 null 값으로 넘어옴.
  • [검색페이지] 추천검색어랑 사용자 추천키워드 제공
  • [책 상세정보 페이지] 이 책에 대한 한줄처방 목록 제공
  • [한 줄 처방 페이지] 한줄처방 추가시 발생하는 에러 수정

레퍼런스

@seonghooni seonghooni requested a review from Simy2 June 1, 2024 10:06
@seonghooni seonghooni linked an issue Jun 1, 2024 that may be closed by this pull request
@@ -48,15 +47,14 @@ public class Book {
private Categories middleCategory;

@Builder
public Book(String isbn, String title, String author, String publishingHouse, String publishYear, String content, float rating,
public Book(String isbn, String title, String author, String publishingHouse, String publishYear, String content,
int reviewNum, Categories bigCategory, Categories middleCategory, String imageUrl, int count) {
this.isbn = isbn;
this.title = title;
this.author = author;
this.publishingHouse = publishingHouse;
this.publishYear = publishYear;
this.content = content;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

db에 rating 컬럼삭제해주시면 될것같습니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네 알겠습니다!

@Query(value = "select new kr.KWGraduate.BookPharmacy.domain.book.dto.response.BookSearchResponseDto(b.title, b.author, b.publishingHouse, b.publishYear, b.isbn, b.imageUrl) " +
"from Book b join b.middleCategory mc where mc.name = :categoryName")
Page<BookSearchResponseDto> findDtoBook10ListByMiddleCategory(@Param("categoryName") String categoryName, Pageable pageable);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 그냥 book을 리턴하면 안되나요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

List를 말씀하시는걸까요?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BookSearchResponseDto 값 말고 그냥 BOOK이요!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DTO와 Entity는 속성이 같더라도 분리해야 하는게 맞는 것 같습니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

혹시 Select문에서 dto로 조회하지않고 book으로 조회하는 것에 대해서 말씀하시는 거라면,
최소한의 성능 개선이라도 이루는게 나을 것 같아, 프론트엔드에서 필요한 정보만 dto로 select하도록 설계했습니다..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

근데 다른 쿼리문은 엔티티 그대로 가지고 오지 않나요...?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

근데 다른 쿼리문은 엔티티 그대로 가지고 오지 않나요...?

그렇긴 합니다..
근데 이 경우 보통 중분류가 10개인데, 중분류당 10권을 불러옵니다.
즉, 한번의 쿼리당 10권씩 총 10번의 쿼리를 가져오기 때문에,
조금의 성능 개선을 위해 DTO로 select문을 작성했습니다.

일관성을 중요하게 여기긴 하지만, 이 경우 쿼리문을 특히 많이 발생시키고, 프론트엔드에서 실제로 오랜 시간이 걸리는 것을 확인해서 이처럼 작성했습니다.

괜찮으시다면 이렇게 가도 좋을 것 같습니다만 혹시 일관성을 더 중요하게 여기신다면 답변 부탁드립니다.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아하 그럼 괜찮은 것 같습니다!

public List<Map<String, Object>> getBookListByBigCategoryChildren(String bigCategoryName, Pageable pageable){

List<Map<String, Object>> result = new ArrayList<>();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Map<String,List> 이렇게 코드 바꾸시는 건 어떤가요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

List 처럼
작성해야해서
길어져서 Object로 적용했는데
저는 상관없을 것 같습니다.
그럼 변경하겠습니다.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도 상관없습니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그럼 그대로 유지하도록 하겠습니다!

@@ -34,6 +34,8 @@ public class Client extends BaseTimeEntity {
private String role;
private Integer passwordLength;
private String description;
private int boardCount;
private int prescriptionCount;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 혹시 signup때 값을 0으로 세팅하도록 되어있나요??
다른 dto들이나 다 수정된건가요? ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Integer는 null이 가능하지만
int는 무조건 0이 default로 반영이 됩니다!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 제가 말씀드린 것은 signup을 진행할때 save하기 전에 count값들이 0으로 설정되었나였습니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네 SINGUP때 기본으로 0으로 지정됩니다!
int 로 필드값을 설정하면 0으로 default로 지정됩니다.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아하 넵 알겠습니당

@Simy2
Copy link
Contributor

Simy2 commented Jun 1, 2024

머지 하셔도 될것같습니다!

@seonghooni seonghooni merged commit 578769e into develop Jun 2, 2024
@seonghooni seonghooni mentioned this pull request Jun 2, 2024
5 tasks
seonghooni added a commit that referenced this pull request Jun 2, 2024
* [Refactor] 각종 API 미흡한 부분 수정 (#173)

* [Refactor] GET(/client) 내가 남긴 고민과 처방 개수 필드 추가 필요

* [Refactor] 한줄처방 페이지 등록 오류 수정

* [Refactor] 중분류 페이지 키워드 함께 제공하도록 수정

* [Refactor] 책에 대한 한줄처방 목록 제공 api 추가

---------

Signed-off-by: 이성훈 <[email protected]>
Signed-off-by: simjaeyoun <[email protected]>
Co-authored-by: simjaeyoun <[email protected]>
@seonghooni seonghooni deleted the refactor/#172_api_issue_fix branch June 3, 2024 09:10
Simy2 added a commit that referenced this pull request Jun 4, 2024
* [Feat] 공통 예외 처리 클래스 작성 (#125)

* [Feat] global Exception 작성

* [Refactor] global exception 양식에 맞게 Client 예외처리 수정

* [Refactor] Client Exception 변경에 따른 예외처리 수정

* [Refactor] global Exception 변경에 따른 예외처리 코드 일부 수정

* [Hotfix] 05/08 버전 복구

* [Refactor]  한줄처방 작성시 독서경험에도 추가하는 로직 작성 (#129)

* [Refactor] 디렉토리구조 개편으로 인한 테스트코드 import 수정

* [Refactor] 처방전에서 bookId가 아닌 bookIsbn을 받도록 수정

* [Refactor] 한줄처방 작성시 독서경험 추가하도록 변경

---------

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

* [Refactor] 공통 질문 수정 및 오타 수정 (#130)

* [Refactor] redis password 주석삭제

* [Refactor] 이전 커밋 내역 복구

* [Refactor] 이전 커밋 내역 복구

* [Refactor] 이전 커밋내역 복구

* [Feat] 기타 키워드와 공통 질문 및 답변 작성

* [Feat] 기타 키워드 추가

* [Refactor] 공통 키워드 추가에 다른 로직 변경
1. 키워드 조회할때 '공통'키워드 조회 안함
2. 키워드에 대한 질문 조회할때 공통 키워드에 대한 질문과 함께 조회

* [Refactor] 한국어 키워드가 아닌 키워드 객체로 받도록 수정

* [Style] 소셜 오타 소설로 수정

---------

Signed-off-by: simjaeyoun <[email protected]>

* [Feat] 키워드와 함께 책을 검색하는 로직 추가 (#135)

* [Feat] 키워드와 함께 책을 검색하는 서비스 추가

* [Feat] 키워드로 책 검색하는 로직 추가

* [Refactor] 회원 관련 전반적인 리펙토링 및 api 기능 추가 (#133)

* [Feat] 비밀번호 길이와 자기소개 필드 추가

* [Feat] 생일 정보 추가 및 엔티티로 변환시 비밀번호 길이와 자기소개 값 추가

* [Feat] 비밀번호 길이와 자기소개 필드 추가

* [Refactor]필드 값 추가에 따른 회원가입 메서드 변경 및 authentication을 인자로 받도록 추가

* [Refactor] @AuthenticationPrincipal 추가 및 인자에도 추가

* [Feat] 닉네임, 아이디, 이메일 중복을 확인하는 메서드 추가

* [Feat] 중목을 확인하는 api작성

* [Refactor] 사용자 정보 수정에 관한 로직 추가 및 안쓰이는 로직 삭제

* [Refactor] update dto의 내부 필드 변경

* [Refactor] 사용자 정보 수정하는 로직 분할 및 변경

* [Feat] 사용자 정보 수정하는 api들 작성

* [Style] 출력하는 dto의 이름 명시적으로 변경

* [Feat] 메인페이지에 회원 정보 가져오는 로직 추가

* [Refactor] oauth2 리다이렉션 주소 변경

* [Refactor] 직업정보의 입출력을 키워드가 아닌 한글로 입출력을 하도록 수정

* [Refactor] 패스워드 set하는 메서드 로직 변경

* [Refactor] 패스워드 변경하는 메서드 변경에 따른 코드 변경

* [Style] 중복을 체크하는 api의 swagger description추가

* [Refactor] 유저정보 api url, description 일부 수정

* [Refactor] 한줄처방 키워드 매핑 적용

* [Refactor] DTO의 LocalDateTime -> LocalDate로 변경

* [Refactor] 마이페이지 api수정 (#140)

* [Feat] 닉네임 수정하는 dto 생성

* [Feat] 패스워드 수정하는 dto생성

* [Refactor] 비밀번호와 닉네임 수정하는 메서드 인자를 dto로 받는 것으로 수정

* [Refactor] 비밀번호와 닉네임 수정하는 api의 인자 dto로 수정

* [Refactor] dto를 만들때 오타 수정

* [Refactor] board의 status값 제거로 인한 수정

* [Refactor] 보드삭제 전 보드와 관련된 처방전 및 answer삭제하도록 설정 (#142)

* [Test] 디렉토리 구조 변경으로 인한 코드 변경

* [Test] client코드 변경으로 인한 코드 변경

* [Test] client코드 변경으로 인한 코드 변경

* [Test] boardId입력에 따른 삭제 테스트

* [Feat] boardId입력에 따른 삭제 추가

* [Feat] boardId입력에 따른 삭제 추가

* [Refactor] db외래키 제약으로 인해 board삭제시 answer와 prescription삭제

* [Refactor] board와의 연관관계에서 board가 삭제되면 같이 삭제되도록 어노테이션 설정

* [Refactor] 벌크성 쿼리로 수정하는 로직 삭제

* [Refactor] board를 삭제하는 로직 복구

* [Feat] 처방전 상세정보 조회 API 작성 (#144)

* [Refactor] 한줄처방 Response 필드 추가

* [Feat] 처방전 상세조회 서비스 및 API 작성

* [Refactor] Board status 삭제에 따른 index 수정

* [Feat] 한줄처방 검색어 또는 키워드로 조회 기능 추가 (#147)

* [Refactor] 질문사항 수정 (#152)

* [Refactor] 질문사항 수정
1. 경제관련 질문 중 경제에 대해 얼마나 알고 있나요 질문 삭제
2. 철학관련 질문 중 철학에 대해 얼마나 알고 있나요 질문 삭제
3. 공통질문 중 해당고민에 대한 책 얼마나 읽었는지 질문을 한달에 책을 얼마나 읽는지로 변경

* [Refactor] 질문 사항 변경으로 인한 코드 변경

* [Refactor] 질문사항 변경으로 인한 선택지 변경

* [Refactor] 철학 선택지 변경

* [Refactor] 공통질문이 밑으로 가게끔 수정

* [Style] 한달의 오타를 한달에로 수정

* [Feat] 유저 관심사 테이블 및 입력 API 작성 (#151)

* [Feat] 유저 관심사 도메인 추가

* [Refactor] 회원가입시 유저 관심사목록 필드 추가

* [Refactor] List<String> CategoryList로 List<Category> 조회하는 기능 추가

* [Refactor] Test 코드 변경사항 수정

* [Refactor] 한줄처방 수정하는 로직 변경 (#155)

* [Refactor] 비즈니스로직 성공적으로 동작시 'success' 응답하도록 수정

* [Refactor] 한줄처방 수정 로직에서 키워드도 변경 가능하도록 작성

* [Refactor] 책 상세정보 조회 오류 및 기타 수정 (#159)

* [Refactor] Board DTO 반환타입을 Slice에서 Page로 변경

* [Refactor] 키워드가 없는 책 상세정보 조회 오류

* [Merge] 메인 브랜치로부터 병합 (#162)

* [Merge] 2024-05-21 버전 적용 (#153)
* [Merge] 2024-05-22 버전 적용 (#156)
* [Merge] 2024-05-28 버전 적용 (#161)
* [Hotfix] BookController 관련 빌드 에러 해결 적용

---------

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

* [Refactor] 쿠키의 maxage값 삭제 (#168)

* [Feat] '좋아요, 도움이 되었어요' 기능 추가  (#164)

* [Refactor] 한줄처방에 좋아요/도움이되었어요 개수 필드 추가

* [Feat] 한줄처방 좋아요/도움이되었어요 엔티티 추가

* [Feat] 한줄처방 좋아요/도움이되었어요 Repository 계층 추가

* [Feat] 한줄처방 좋아요/도움이되었어요 Service 계층 추가

* [Feat] 한줄처방 좋아요/도움이되었어요 Controller 계층 추가

* [Refactor] 한줄처방 감정 도메인에 @onDelete 추가

* [Refactor] 각종 API 미흡한 부분 수정 (#173)

* [Refactor] GET(/client) 내가 남긴 고민과 처방 개수 필드 추가 필요

* [Refactor] 한줄처방 페이지 등록 오류 수정

* [Refactor] 중분류 페이지 키워드 함께 제공하도록 수정

* [Refactor] 책에 대한 한줄처방 목록 제공 api 추가

* [Feat] 추천 테이블 생성 및 로직 작성 (#171)

* [Refactor] client가 삭제되면 같이 삭제되오록 수정

* [Feat] 책 추천 테이블 셍성

* [Feat] 클라이언트 추천 테이블 생성

* [Feat] 게시판 관련 추천 테이블 생성

* [Refactor] private추가 및 컬럼명 변경

* [Refactor] 컬렴명 변경

* [Refactor]
1. 책 연관관계를 manytoOne으로 변경
2. keyword컬럼 생성
3. 빌더 생성

* [Refactor]
1. 책 관계를 manytoOne으로 변경
2. 빌더 생성

* [Refactor]
1. 클라이언트 관계를 manytoOne으로 변경
2. 빌더 생성

* [Feat] 추천 관련 테이블 연관관계 생성

* [Feat] 추천 관련 레포지토리 층 생성

* [Feat] 추천 관련 서비스층 생성

* [Feat] 추천 관련 dto생성

* [Feat] 추천 관련 api생성

* [Test] 추천 레포지토리층 테스트

* [Test] 추천 관련 서비스층 테스트

* [Refactor] swagger ui에서 나타나는 description에 예시 추가

* [Refactor] @onetomany삭제

* [Refactor] 빌더 인자 변경

* [Refactor]
1. recommend repository삭제
2. 개별 repository로 올김
3. 쿼리문 변경
3. 반환값 변경

* [Refactor] repository명 변경

* [Test] 코드 수정에 따른 테스트 코드 변경

* [Test] 코드 수정에 따른 테스트 코드 변경

* [Refactor] 내 게시판 가지고 오는 api에 nickname추가 (#180)

* [Refactor] Oauth관련 버그 수정 (#174)

* [Refactor] 사용자의 이메일과 repository애 있는지 확인하는 필드 추가

* [Refactor] 사용자의 이메일을 출력하는 함수와 레포지토리에 사용자가 있는지 확인하는 메서드 추가

* [Refactor] 사용자의 이메일 추가 및 레포지토리 검색 후 없으면 추가하는 로직 삭제

* [Refactor]
1. 사용자가 존재한다면 쿠키값을 메인페이로 리다이렉션
2. 사용자가 존재하지 않다면 redis에 사용자의 정보 저장 및 회원가입 페이지로 리다이렉션

* [Feat] redis에 저장될 사용자 정보

* [Feat] 사용자 정보 서비스층 작성

* [Feat] oauth용 회원가입 dto작성

* [Feat] oauth 회원가입 메서드 작성

* [Feat] oauth회원가입 api작성

* [Refactor] refreshtoken 디렉토리 구조 변경

* [Refactor] oauth2 redis hash테이블 명 변경

* [Refactor] 로그인 시 리다이렉션 주소 변경

* [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]>

* [Refactor] 2024-06-03 merge 후 발생 오류 해결(2)

* [Refactor] 모든 게시판을 조회하는 api에 description을 추가 (#193)

* [Refactor] Emotion 추가 및 삭제 서비스 로직 오류 수정 (#195)

* [Refactor] 한줄처방 Emotion 추가 및 삭제 로직 변경

* [Refactor] 조인이 아닌 조회수 컬럼을 참조하도록 코드 변경

* [Refactor] oauth로그인 시 스프링 세션에 정보 추가 (#199)

* [Feat] 로그인시 security session에 값 추가

* [Feat] 로그인 시 security session에 값 추가

* [Refactor] 리다이렉션 주소 수정

* [Refactor] 인증을 요구하는 api의 타입 수정

* [Refactor] 추천 관련 로직 수정 (#201)

* [Refactor] book의 join을 left join으로 변경

* [Refactor] 게시판 관련 추천에 대한 return값 수정

* [Refactor] recommending필드 추가

* [Style] 스웨거에 나타내는 설명문 변경

* [Refactor]내 처방전 리턴값, oauth 리턴값, 유저 관련 추천 로직 수정 (#203)

* [Refactor] 반환되는 값 Page로 변경

* [Refactor] oauth로 로그인 시 아이디 값을 slicing하도록 변경

* [Refactor] 쿼리문 rank수 변경

* [Refactor] 랜덤으로 가져오고 sorting해서 출력하도록 변경

---------

Signed-off-by: 이성훈 <[email protected]>
Signed-off-by: simjaeyoun <[email protected]>
Co-authored-by: 이성훈 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Refactor] 각종 API 미흡한 부분 수정
2 participants