Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -23,7 +23,8 @@ public class ArchiveCommentOutputDTO {
@Builder
public static class CommentDTO {
private Long id;
private String writer;
private String commentWriter;
private String commentWriterProfileImg;
private String content;
private boolean isDeleted;
private LocalDateTime createdDateTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public static class ArchiveSimpleDTO {
private Long id;
private String title;
private String writerNickname;
private String writerProfileImg; // 작성자 프로필 이미지 추가
private String thumbnail;
private int commentCount;
private int view; // 조회수 추가
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
@AllArgsConstructor
public class ArchiveOutputDTO {
private Long id;
private String writerUsername;
private String writerNickname;
private String writerProfileImg;
private String title;
private String description;
private LocalDate startDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class ArchiveMember extends BaseTimeEntity {
@JoinColumn(name = "archive_id")
private Archive archive;

@Column(name = "profile_img")
@Column(name = "profile_img", columnDefinition = "TEXT")
private String profileImg; // 멤버의 프로필 이미지 URL

@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,50 @@ public interface ArchiveRepository extends JpaRepository<Archive, Long> {
// 기본 조회 - 삭제되지 않은 아카이브만
Optional<Archive> findByIdAndIsDeletedFalse(Long id);

// 작성자 정보를 함께 조회하는 최적화된 메서드 (FETCH JOIN 사용)
@Query("SELECT a FROM Archive a JOIN FETCH a.writer WHERE a.id = :id AND a.isDeleted = false")
Optional<Archive> findByIdAndIsDeletedFalseWithWriter(@Param("id") Long id);

// 전체 목록 조회 - 삭제되지 않은 것만
Page<Archive> findByIsDeletedFalse(Pageable pageable);

// 상태별 조회 - 삭제되지 않은 것만
Page<Archive> findByStatusAndIsDeletedFalse(Status status, Pageable pageable);

// 상태별 조회 - 작성자 정보 포함 (FETCH JOIN 사용)
@Query("SELECT a FROM Archive a JOIN FETCH a.writer WHERE a.status = :status AND a.isDeleted = false")
Page<Archive> findByStatusAndIsDeletedFalseWithWriter(@Param("status") Status status, Pageable pageable);

// 카테고리별 조회 - 삭제되지 않은 것만
Page<Archive> findByCategoryAndIsDeletedFalse(Category category, Pageable pageable);

// 카테고리와 상태로 조회 - 삭제되지 않은 것만
Page<Archive> findByCategoryAndStatusAndIsDeletedFalse(Category category, Status status, Pageable pageable);

// 카테고리와 상태로 조회 - 작성자 정보 포함 (FETCH JOIN 사용)
@Query("SELECT a FROM Archive a JOIN FETCH a.writer WHERE a.category = :category AND a.status = :status AND a.isDeleted = false")
Page<Archive> findByCategoryAndStatusAndIsDeletedFalseWithWriter(@Param("category") Category category, @Param("status") Status status, Pageable pageable);

// 제목으로 검색 - 삭제되지 않은 것만
Page<Archive> findByTitleContainingIgnoreCaseAndIsDeletedFalse(String title, Pageable pageable);

// 제목으로 검색하고 상태로 필터링 - 삭제되지 않은 것만
Page<Archive> findByTitleContainingIgnoreCaseAndStatusAndIsDeletedFalse(String title, Status status, Pageable pageable);

// 제목으로 검색하고 상태로 필터링 - 작성자 정보 포함 (FETCH JOIN 사용)
@Query("SELECT a FROM Archive a JOIN FETCH a.writer WHERE a.title LIKE %:title% AND a.status = :status AND a.isDeleted = false")
Page<Archive> findByTitleContainingIgnoreCaseAndStatusAndIsDeletedFalseWithWriter(@Param("title") String title, @Param("status") Status status, Pageable pageable);

// 카테고리와 제목으로 검색 - 삭제되지 않은 것만
Page<Archive> findByCategoryAndTitleContainingIgnoreCaseAndIsDeletedFalse(Category category, String title, Pageable pageable);

// 카테고리와 제목으로 검색하고 상태로 필터링 - 삭제되지 않은 것만
Page<Archive> findByCategoryAndTitleContainingIgnoreCaseAndStatusAndIsDeletedFalse(Category category, String title, Status status, Pageable pageable);

// 카테고리와 제목으로 검색하고 상태로 필터링 - 작성자 정보 포함 (FETCH JOIN 사용)
@Query("SELECT a FROM Archive a JOIN FETCH a.writer WHERE a.category = :category AND a.title LIKE %:title% AND a.status = :status AND a.isDeleted = false")
Page<Archive> findByCategoryAndTitleContainingIgnoreCaseAndStatusAndIsDeletedFalseWithWriter(@Param("category") Category category, @Param("title") String title, @Param("status") Status status, Pageable pageable);

// 멤버 ID로 아카이브 검색 - 삭제되지 않은 것만
@Query("SELECT a FROM Archive a JOIN a.archiveMembers am WHERE am.member.id = :memberId AND a.isDeleted = false")
Page<Archive> findByMemberId(@Param("memberId") Long memberId, Pageable pageable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public ArchiveListDTO getAllArchives(int page, SortType sortType, String usernam
}

Pageable pageable = createPageableWithSort(page, sortType);
Page<Archive> archivePage = archiveRepository.findByStatusAndIsDeletedFalse(Status.평가완료, pageable);
Page<Archive> archivePage = archiveRepository.findByStatusAndIsDeletedFalseWithWriter(Status.평가완료, pageable);

List<ArchiveListDTO.ArchiveSimpleDTO> archives = archivePage.getContent().stream()
.map(archive -> {
Expand All @@ -203,6 +203,7 @@ public ArchiveListDTO getAllArchives(int page, SortType sortType, String usernam
.id(archive.getId())
.title(archive.getTitle())
.writerNickname(archive.getWriter().getNickname())
.writerProfileImg(archive.getWriter().getProfileImg())
.thumbnail(archive.getThumbnail())
.commentCount(archive.getComments().size())
.view(archive.getView())
Expand Down Expand Up @@ -236,15 +237,15 @@ public ArchiveListDTO searchArchives(
Page<Archive> archivePage;

if (category != null && keyword != null && !keyword.trim().isEmpty()) {
archivePage = archiveRepository.findByCategoryAndTitleContainingIgnoreCaseAndStatusAndIsDeletedFalse(
archivePage = archiveRepository.findByCategoryAndTitleContainingIgnoreCaseAndStatusAndIsDeletedFalseWithWriter(
category, keyword.trim(), Status.평가완료, pageable);
} else if (category != null) {
archivePage = archiveRepository.findByCategoryAndStatusAndIsDeletedFalse(category, Status.평가완료, pageable);
archivePage = archiveRepository.findByCategoryAndStatusAndIsDeletedFalseWithWriter(category, Status.평가완료, pageable);
} else if (keyword != null && !keyword.trim().isEmpty()) {
archivePage = archiveRepository.findByTitleContainingIgnoreCaseAndStatusAndIsDeletedFalse(
archivePage = archiveRepository.findByTitleContainingIgnoreCaseAndStatusAndIsDeletedFalseWithWriter(
keyword.trim(), Status.평가완료, pageable);
} else {
archivePage = archiveRepository.findByStatusAndIsDeletedFalse(Status.평가완료, pageable);
archivePage = archiveRepository.findByStatusAndIsDeletedFalseWithWriter(Status.평가완료, pageable);
}

List<ArchiveListDTO.ArchiveSimpleDTO> archives = archivePage.getContent().stream()
Expand All @@ -257,6 +258,7 @@ public ArchiveListDTO searchArchives(
.id(archive.getId())
.title(archive.getTitle())
.writerNickname(archive.getWriter().getNickname())
.writerProfileImg(archive.getWriter().getProfileImg())
.thumbnail(archive.getThumbnail())
.commentCount(archive.getComments().size())
.view(archive.getView())
Expand Down Expand Up @@ -287,9 +289,17 @@ private Pageable createPageableWithSort(int page, SortType sortType) {
return PageRequest.of(page, 18, sort);
}

// 댓글 작성자의 프로필 이미지를 가져오는 헬퍼 메서드
private String getCommentWriterProfileImg(String writerNickname) {
return memberRepository.findByNickname(writerNickname)
.map(MemberEntity::getProfileImg)
.orElse("default.png"); // 기본 이미지
}

// Archive 엔티티를 DTO로 변환
private ArchiveOutputDTO convertToDTO(Archive archive, String username, int viewCount) {
List<ArchiveOutputDTO.ArchiveMemberDTO> memberDTOs = archive.getArchiveMembers().stream()
.filter(archiveMember -> !archiveMember.getMember().getId().equals(archive.getWriter().getId()))
.map(archiveMember -> ArchiveOutputDTO.ArchiveMemberDTO.builder()
.username(archiveMember.getMember().getUsername())
.nickname(archiveMember.getMember().getNickname())
Expand Down Expand Up @@ -319,7 +329,8 @@ private ArchiveOutputDTO convertToDTO(Archive archive, String username, int view
for (ArchiveComment parentComment : parentComments) {
ArchiveCommentOutputDTO.CommentDTO parentDTO = ArchiveCommentOutputDTO.CommentDTO.builder()
.id(parentComment.getId())
.writer(parentComment.getWriter())
.commentWriter(parentComment.getWriter())
.commentWriterProfileImg(getCommentWriterProfileImg(parentComment.getWriter()))
.content(parentComment.isDeleted() ? "삭제된 댓글입니다." : parentComment.getContent())
.isDeleted(parentComment.isDeleted())
.createdDateTime(parentComment.getCreatedDateTime())
Expand All @@ -333,7 +344,8 @@ private ArchiveOutputDTO convertToDTO(Archive archive, String username, int view
for (ArchiveComment childComment : childComments) {
ArchiveCommentOutputDTO.CommentDTO childDTO = ArchiveCommentOutputDTO.CommentDTO.builder()
.id(childComment.getId())
.writer(childComment.getWriter())
.commentWriter(childComment.getWriter())
.commentWriterProfileImg(getCommentWriterProfileImg(childComment.getWriter()))
.content(childComment.isDeleted() ? "삭제된 댓글입니다." : childComment.getContent())
.isDeleted(childComment.isDeleted())
.createdDateTime(childComment.getCreatedDateTime())
Expand All @@ -347,7 +359,9 @@ private ArchiveOutputDTO convertToDTO(Archive archive, String username, int view

return ArchiveOutputDTO.builder()
.id(archive.getId())
.writerUsername(archive.getWriter().getUsername())
.writerNickname(archive.getWriter().getNickname())
.writerProfileImg(archive.getWriter().getProfileImg())
.title(archive.getTitle())
.description(archive.getDescription())
.startDate(archive.getStartDate())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import jakarta.persistence.*;
import lombok.Data;

import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import sequence.sequence_member.global.enums.enums.Degree;
import sequence.sequence_member.global.enums.enums.ProjectRole;
Expand All @@ -18,6 +18,7 @@

@Entity
@Data
@EqualsAndHashCode(callSuper = false)
@Table(name="education")
@NoArgsConstructor
public class EducationEntity extends BaseTimeEntity {
Expand Down
1 change: 1 addition & 0 deletions sequence_member/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ management:
# 이 설정은 /actuator/health 엔드포인트에서 헬스 체크 정보를 항상 상세히 보여주도록 설정합니다. 기본적으로, 헬스 체크 엔드포인트는 요약된 상태 정보만 제공하며, 상세 정보는 노출되지 않습니다.
prometheus:
enabled: true

prometheus:
metrics:
export:
Expand Down
Loading