-
Notifications
You must be signed in to change notification settings - Fork 5
Hotfix/mateboard : bio null 값 수정, 동행 신청 여부 판단 필드 추가 #177
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
Changes from all commits
ec79244
9c6b30a
71773f0
04a7544
2063919
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,8 +79,9 @@ public PageResponse<MateResponseDto> searchMatePosts( | |
| */ | ||
| @GetMapping("/{id}") | ||
| @ResponseStatus(HttpStatus.OK) | ||
| public MateResponseDto getMate(@PathVariable Long id) { | ||
| return mateService.getMate(id); | ||
| public MateResponseDto getMate(@PathVariable Long id, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| @AuthenticationPrincipal Long userId) { | ||
| return mateService.getMate(id, userId); | ||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,14 +40,16 @@ public class MateResponseDto { | |
| private final int commentCount; | ||
| private final int likeCount; | ||
| private final LocalDateTime createdAt; | ||
| private boolean isApplied; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
|
|
||
| @QueryProjection | ||
| public MateResponseDto(Long matePostId, Long authorId, String title, String content, | ||
| TravelRegion travelRegion, LocalDate travelStartDate, LocalDate travelEndDate, | ||
| RecruitmentStatus recruitmentStatus, MateGender mateGender, | ||
| int recruitCount, int appliedCount, String imageUrl, | ||
| String nickname, String bio, String profileImage, Gender authorGender, | ||
| int commentCount, int likeCount, LocalDateTime createdAt) { | ||
| int commentCount, int likeCount, LocalDateTime createdAt, boolean isApplied) { | ||
| this.matePostId = matePostId; | ||
| this.authorId = authorId; | ||
| this.title = title; | ||
|
|
@@ -67,5 +69,6 @@ public MateResponseDto(Long matePostId, Long authorId, String title, String cont | |
| this.commentCount = commentCount; | ||
| this.likeCount = likeCount; | ||
| this.createdAt = createdAt; | ||
| this.isApplied = isApplied; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,14 +20,15 @@ public class MateMapper { | |
| * @param mate 변환할 Mate 엔티티 | ||
| * @return MateResponseDto 변환 결과 | ||
| */ | ||
| public static MateResponseDto toResponseDto(Mate mate, String imageUrl) { | ||
| public static MateResponseDto toResponseDto(Mate mate, String imageUrl, boolean isApplied) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 기존의 |
||
|
|
||
| return MateResponseDto.builder() | ||
| .matePostId(mate.getId()) | ||
| .authorId(mate.getWriter().getId()) | ||
| .nickname(mate.getWriter().getNickname()) | ||
| .profileImage(mate.getWriter().getProfileImageUrl()) | ||
| .authorGender(mate.getWriter().getGender()) | ||
| .bio(mate.getWriter().getBio()) | ||
| .title(mate.getTitle()) | ||
| .content(mate.getContent()) | ||
| .recruitCount(mate.getRecruitCount()) | ||
|
|
@@ -41,6 +42,11 @@ public static MateResponseDto toResponseDto(Mate mate, String imageUrl) { | |
| .count()) | ||
| .imageUrl(imageUrl) | ||
| .createdAt(mate.getCreatedAt()) | ||
| .isApplied(isApplied) | ||
| .build(); | ||
| } | ||
|
|
||
| public static MateResponseDto toResponseDto(Mate mate, String imageUrl) { | ||
| return toResponseDto(mate, imageUrl, false); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| import static com.frend.planit.domain.mateboard.post.entity.QMatePostLike.matePostLike; | ||
|
|
||
| import com.frend.planit.domain.image.entity.QImage; | ||
| import com.frend.planit.domain.image.type.HolderType; | ||
| import com.frend.planit.domain.mateboard.application.entity.MateApplicationStatus; | ||
| import com.frend.planit.domain.mateboard.application.entity.QMateApplication; | ||
| import com.frend.planit.domain.mateboard.post.dto.response.MateResponseDto; | ||
|
|
@@ -100,6 +101,8 @@ public Page<MateResponseDto> searchMatePosts(String keyword, String status, Stri | |
| JPAExpressions | ||
| .select(image.url) | ||
| .from(image) | ||
| .where(image.holderType.eq(HolderType.MATEBOARD) | ||
| .and(image.holderId.eq(mate.id))) | ||
| .orderBy(image.id.asc()) | ||
| .limit(1), | ||
| user.nickname, | ||
|
|
@@ -108,7 +111,8 @@ public Page<MateResponseDto> searchMatePosts(String keyword, String status, Stri | |
| user.gender, | ||
| mateComment.countDistinct().intValue(), | ||
| matePostLike.countDistinct().intValue(), | ||
| mate.createdAt | ||
| mate.createdAt, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| Expressions.constant(false) | ||
| )) | ||
| .from(mate) | ||
| .leftJoin(mate.writer, user) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
|
|
||
| import com.frend.planit.domain.image.service.ImageService; | ||
| import com.frend.planit.domain.image.type.HolderType; | ||
| import com.frend.planit.domain.mateboard.application.repository.MateApplicationRepository; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| import com.frend.planit.domain.mateboard.post.dto.request.MateRequestDto; | ||
| import com.frend.planit.domain.mateboard.post.dto.response.MateResponseDto; | ||
| import com.frend.planit.domain.mateboard.post.entity.Mate; | ||
|
|
@@ -41,6 +42,7 @@ public class MateService { | |
| private final MateRepository mateRepository; | ||
| private final UserRepository userRepository; | ||
| private final ImageService imageService; | ||
| private final MateApplicationRepository mateApplicationRepository; | ||
|
|
||
| /** | ||
| * ID로 게시글을 조회하고, 존재하지 않으면 예외를 던집니다. | ||
|
|
@@ -89,14 +91,16 @@ public Long createMate(Long userId, MateRequestDto mateRequestDto) { | |
| * @return 조회된 게시글의 응답 DTO | ||
| * @throws RuntimeException 해당 ID의 게시글이 존재하지 않을 경우 예외 발생 | ||
| */ | ||
| public MateResponseDto getMate(Long id) { | ||
| public MateResponseDto getMate(Long id, Long userId) { | ||
| Mate mate = findMateOrThrow(id); | ||
|
|
||
| // 게시글 이미지 조회 | ||
| String imageUrl = imageService.getImage(HolderType.MATEBOARD, mate.getId()).imageUrl(); | ||
|
|
||
| boolean isApplied = mateApplicationRepository.existsByMateIdAndApplicantId(id, userId); | ||
|
|
||
| // DTO 변환 시 이미지 URL 포함 | ||
| return MateMapper.toResponseDto(mate, imageUrl); | ||
| return MateMapper.toResponseDto(mate, imageUrl, isApplied); | ||
| } | ||
|
|
||
| /** | ||
|
|
||
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.
좋은 추가입니다. MateApplication 엔티티에 대한 존재 여부를 효율적으로 확인할 수 있는 메서드가 추가되었습니다. 메서드 이름도 명확하고 좋습니다.