-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
# Conflicts: # src/main/java/com/dnd/accompany/domain/accompany/entity/AccompanyBoard.java # src/main/java/com/dnd/accompany/domain/accompany/entity/AccompanyImage.java # src/main/java/com/dnd/accompany/domain/accompany/entity/AccompanyRequest.java # src/main/java/com/dnd/accompany/domain/accompany/entity/AccompanyTag.java # src/main/java/com/dnd/accompany/domain/accompany/entity/AccompanyUser.java
There was a problem hiding this 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; |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이거 @AuthenticationPrincipal로 대체할 수 없나용?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
몰랐네요.. 바꿀게요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요거는 제가 바로 다음에 올릴 PR에서 적용해 볼게요 .. !
src/main/java/com/dnd/accompany/domain/accompany/entity/AccompanyRequest.java
Show resolved
Hide resolved
user.nickname)) | ||
.from(accompanyBoard) | ||
.leftJoin(accompanyUser).on(accompanyUser.accompanyBoard.id.eq(accompanyBoard.id) | ||
.and(accompanyUser.role.eq(HOST))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
accompanyUser.role.eq(HOST)
요런건 메소드로 분리해서 재사용해도 될 것 같아요
tagNames.stream() | ||
.map(tagName -> AccompanyTag.builder() | ||
.accompanyBoard(accompanyBoard) | ||
.name(tagName) | ||
.build()) | ||
.forEach(accompanyTagRepository::save); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
map() 이후에 saveAll()로 저장해도 될 것 같습니다!
참고
트랜잭션 필요할 것 같아요
AccompanyBoardDetailInfo detailInfo = result.get(0, AccompanyBoardDetailInfo.class); | ||
UserProfileDetailInfo profileInfo = result.get(1, UserProfileDetailInfo.class); | ||
|
||
ReadAccompanyBoardResponse response = new ReadAccompanyBoardResponse(detailInfo, profileInfo); |
There was a problem hiding this comment.
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는 서비스 계층에서 조립하는 식으로요
public boolean isExist(Long userId, Long boardId) { | ||
return accompanyUserRepository.existsByUserIdAndAccompanyBoardIdAndRole(userId, boardId, HOST); | ||
} |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AuthenticationPrincipal 사용하시면 userId를 컨트롤러에서 받아올 수 있을거에용
long total = queryFactory.select(accompanyUser.count()) | ||
.from(accompanyUser) | ||
.join(accompanyUser.accompanyBoard, accompanyBoard) | ||
.join(accompanyUser.user, user) | ||
.where(accompanyUser.role.eq(HOST)) | ||
.fetchOne(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
totalCount는 아직 사용 안하는 것 같은데 없어도 될 것 같습니당
📄 변경 사항
🤔 고민되는 부분
이후에 dto에 profile 필드 추가하고 테스트 코드 작성해서 올리겠습니다!
테스트는 Postman으로 해봤는데 문제는 없었습니다!
PR을 나눠서 올렸어야 했는데 어쩌다보니 쌓여버렸네요.. 죄송합니다..