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

feat: 동행글 관련 API를 구현한다. #18

Merged
merged 28 commits into from
Aug 7, 2024
Merged

feat: 동행글 관련 API를 구현한다. #18

merged 28 commits into from
Aug 7, 2024

Conversation

min429
Copy link
Collaborator

@min429 min429 commented Aug 5, 2024

📄 변경 사항

  • 동행글 CRUD, 동행신청 API를 구현했습니다.
  • 관련 예외도 추가했습니다.
  • soft delete를 위해 엔티티 설정을 변경했습니다.
  • 클래스 이름을 변경했습니다.(복수형 -> 단수형)
  • 엔티티에 enum 및 필드를 추가했습니다.
  • authentication에서 userId를 가져오는 SecurityUtil을 추가했습니다.

🤔 고민되는 부분

  • 혹시 request, response dto 및 controller를 이렇게 구성해도 될까요??

이후에 dto에 profile 필드 추가하고 테스트 코드 작성해서 올리겠습니다!
테스트는 Postman으로 해봤는데 문제는 없었습니다!
PR을 나눠서 올렸어야 했는데 어쩌다보니 쌓여버렸네요.. 죄송합니다..

@min429 min429 requested a review from rlarltj August 5, 2024 11:23
@min429 min429 self-assigned this Aug 5, 2024
Copy link
Member

@rlarltj rlarltj left a comment

Choose a reason for hiding this comment

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

고생하셨습니다!
TC 포함 300자 내외면 좋을 것 같습니다 ~!!


@Override
public Page<AccompanyBoardInfo> findBoardInfos(Pageable pageable) {
QAccompanyUser accompanyUser = QAccompanyUser.accompanyUser;
Copy link
Member

Choose a reason for hiding this comment

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

QClass는 static import 하는게 더 깔끔합니다 👍

import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;

public record AccompanyRequestRequest(
Copy link
Member

Choose a reason for hiding this comment

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

클래스 명이 약간 어색합니다 .. ! createAccompanyRequest 이렇게 가져갈 수도 있을 것 같아용

import com.dnd.accompany.domain.auth.dto.jwt.JwtAuthentication;
import com.dnd.accompany.domain.auth.dto.jwt.JwtAuthenticationToken;

public class SecurityUtil {
Copy link
Member

Choose a reason for hiding this comment

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

이거 @AuthenticationPrincipal로 대체할 수 없나용?

Copy link
Collaborator Author

@min429 min429 Aug 5, 2024

Choose a reason for hiding this comment

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

몰랐네요.. 바꿀게요!

Copy link
Member

@rlarltj rlarltj Aug 5, 2024

Choose a reason for hiding this comment

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

요거는 제가 바로 다음에 올릴 PR에서 적용해 볼게요 .. !

user.nickname))
.from(accompanyBoard)
.leftJoin(accompanyUser).on(accompanyUser.accompanyBoard.id.eq(accompanyBoard.id)
.and(accompanyUser.role.eq(HOST)))
Copy link
Member

Choose a reason for hiding this comment

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

accompanyUser.role.eq(HOST) 요런건 메소드로 분리해서 재사용해도 될 것 같아요

Comment on lines 19 to 24
tagNames.stream()
.map(tagName -> AccompanyTag.builder()
.accompanyBoard(accompanyBoard)
.name(tagName)
.build())
.forEach(accompanyTagRepository::save);
Copy link
Member

Choose a reason for hiding this comment

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

map() 이후에 saveAll()로 저장해도 될 것 같습니다!
참고

트랜잭션 필요할 것 같아요

Comment on lines 100 to 103
AccompanyBoardDetailInfo detailInfo = result.get(0, AccompanyBoardDetailInfo.class);
UserProfileDetailInfo profileInfo = result.get(1, UserProfileDetailInfo.class);

ReadAccompanyBoardResponse response = new ReadAccompanyBoardResponse(detailInfo, profileInfo);
Copy link
Member

Choose a reason for hiding this comment

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

이런 로직은 service layer에서 처리해야 할 것 같아요(repository 역할이 너무 많은 것 같습니다)
두 개의 dto 프로젝션을 하지 않고, ReadAccompanyBoardResult 등 dto 하나에 전부 데이터를 받아오면 어떨까요 ?_?
response는 서비스 계층에서 조립하는 식으로요

Comment on lines 30 to 32
public boolean isExist(Long userId, Long boardId) {
return accompanyUserRepository.existsByUserIdAndAccompanyBoardIdAndRole(userId, boardId, HOST);
}
Copy link
Member

Choose a reason for hiding this comment

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

메소드 이름이 변경되어야 할 것 같아요.
isExist인데 HOST인 유저만 조회하고 있어서용


@Transactional
public void delete(Long boardId) {
Long userId = getCurrentUserId();
Copy link
Member

Choose a reason for hiding this comment

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

@AuthenticationPrincipal 사용하시면 userId를 컨트롤러에서 받아올 수 있을거에용

Comment on lines 54 to 59
long total = queryFactory.select(accompanyUser.count())
.from(accompanyUser)
.join(accompanyUser.accompanyBoard, accompanyBoard)
.join(accompanyUser.user, user)
.where(accompanyUser.role.eq(HOST))
.fetchOne();
Copy link
Member

Choose a reason for hiding this comment

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

totalCount는 아직 사용 안하는 것 같은데 없어도 될 것 같습니당

@min429 min429 requested a review from rlarltj August 6, 2024 06:29
@min429 min429 closed this Aug 6, 2024
@min429 min429 reopened this Aug 6, 2024
@min429 min429 merged commit 6c1b19a into main Aug 7, 2024
1 check passed
@min429 min429 deleted the ISSUE-66 branch August 7, 2024 04:57
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.

2 participants