diff --git a/src/main/java/com/moing/backend/domain/board/application/dto/response/BoardBlocks.java b/src/main/java/com/moing/backend/domain/board/application/dto/response/BoardBlocks.java index 4c06d3c0..cb6d8f58 100644 --- a/src/main/java/com/moing/backend/domain/board/application/dto/response/BoardBlocks.java +++ b/src/main/java/com/moing/backend/domain/board/application/dto/response/BoardBlocks.java @@ -49,7 +49,7 @@ public void readBoard() { public void deleteMember() { if(Boolean.TRUE.equals(writerIsDeleted)) { this.writerNickName = "(알 수 없음)"; - this.writerProfileImage = "undef"; + this.writerProfileImage = null; } } } diff --git a/src/main/java/com/moing/backend/domain/board/application/mapper/BoardMapper.java b/src/main/java/com/moing/backend/domain/board/application/mapper/BoardMapper.java index dbc36017..92552ec3 100644 --- a/src/main/java/com/moing/backend/domain/board/application/mapper/BoardMapper.java +++ b/src/main/java/com/moing/backend/domain/board/application/mapper/BoardMapper.java @@ -36,13 +36,14 @@ public Board toBoard(Member member, TeamMember teamMember, Team team, CreateBoar public GetBoardDetailResponse toBoardDetail(Board board, boolean isWriter, boolean writerIsDeleted) { String nickName = writerIsDeleted ? "(알 수 없음)" : board.getWriterNickName(); + String writerProfileImage = writerIsDeleted ? null : board.getWriterProfileImage(); return GetBoardDetailResponse.builder() .boardId(board.getBoardId()) .title(board.getTitle()) .content(board.getContent()) .writerNickName(nickName) .writerIsLeader(board.isLeader()) - .writerProfileImage(board.getWriterProfileImage()) + .writerProfileImage(writerProfileImage) .createdDate(getFormattedDate(board.getCreatedDate())) .isWriter(isWriter) .isNotice(board.isNotice()) diff --git a/src/main/java/com/moing/backend/domain/board/domain/repository/BoardCustomRepositoryImpl.java b/src/main/java/com/moing/backend/domain/board/domain/repository/BoardCustomRepositoryImpl.java index 7dbf0074..1d58a06a 100644 --- a/src/main/java/com/moing/backend/domain/board/domain/repository/BoardCustomRepositoryImpl.java +++ b/src/main/java/com/moing/backend/domain/board/domain/repository/BoardCustomRepositoryImpl.java @@ -3,6 +3,7 @@ import com.moing.backend.domain.board.application.dto.response.BoardBlocks; import com.moing.backend.domain.board.application.dto.response.GetAllBoardResponse; import com.moing.backend.domain.board.domain.entity.Board; +import com.moing.backend.domain.teamMember.domain.entity.QTeamMember; import com.querydsl.jpa.impl.JPAQueryFactory; import javax.persistence.EntityManager; @@ -24,12 +25,16 @@ public BoardCustomRepositoryImpl(EntityManager em) { public GetAllBoardResponse findBoardAll(Long teamId, Long memberId) { // 전체 게시글 보기 List allBoards = queryFactory.selectFrom(board) + .distinct() + .leftJoin(board.teamMember, QTeamMember.teamMember).fetchJoin() // TeamMember를 함께 로드 .where(board.team.teamId.eq(teamId)) .orderBy(board.createdDate.desc()) .fetch(); // 읽은 게시글 보기 List readBoards = queryFactory.selectFrom(board) + .distinct() + .leftJoin(board.teamMember, QTeamMember.teamMember).fetchJoin() // TeamMember를 함께 로드 .join(boardRead).on(boardRead.board.eq(board)) .where(board.team.teamId.eq(teamId)) .where(boardRead.member.memberId.eq(memberId)) @@ -57,6 +62,7 @@ public GetAllBoardResponse findBoardAll(Long teamId, Long memberId) { if (isRead) { boardBlocks.readBoard(); } + return boardBlocks; }; diff --git a/src/main/java/com/moing/backend/domain/boardComment/application/dto/response/CommentBlocks.java b/src/main/java/com/moing/backend/domain/boardComment/application/dto/response/CommentBlocks.java index beb1c057..d9f3fb83 100644 --- a/src/main/java/com/moing/backend/domain/boardComment/application/dto/response/CommentBlocks.java +++ b/src/main/java/com/moing/backend/domain/boardComment/application/dto/response/CommentBlocks.java @@ -5,6 +5,9 @@ import lombok.Builder; import lombok.Getter; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + @Getter @Builder @AllArgsConstructor @@ -24,10 +27,30 @@ public class CommentBlocks { private Boolean writerIsDeleted; + private String createdDate; + + @QueryProjection + public CommentBlocks(Long boardCommentId, String content, String writerNickName, Boolean writerIsLeader, String writerProfileImage, Boolean isWriter, Boolean writerIsDeleted, LocalDateTime createdDate) { + this.boardCommentId = boardCommentId; + this.writerNickName = writerNickName; + this.writerIsLeader = writerIsLeader; + this.writerProfileImage = writerProfileImage; + this.content = content; + this.isWriter = isWriter; + this.writerIsDeleted=writerIsDeleted; + this.createdDate = getFormattedDate(createdDate); + deleteMember(); + } + public void deleteMember() { if (Boolean.TRUE.equals(writerIsDeleted)) { this.writerNickName = "(알 수 없음)"; - this.writerProfileImage = "undef"; + this.writerProfileImage = null; } } + + public String getFormattedDate(LocalDateTime localDateTime) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm"); + return localDateTime.format(formatter); + } } diff --git a/src/main/java/com/moing/backend/domain/boardComment/domain/repository/BoardCommentCustomRepositoryImpl.java b/src/main/java/com/moing/backend/domain/boardComment/domain/repository/BoardCommentCustomRepositoryImpl.java index 9b3ec7e4..603253b6 100644 --- a/src/main/java/com/moing/backend/domain/boardComment/domain/repository/BoardCommentCustomRepositoryImpl.java +++ b/src/main/java/com/moing/backend/domain/boardComment/domain/repository/BoardCommentCustomRepositoryImpl.java @@ -2,6 +2,7 @@ import com.moing.backend.domain.boardComment.application.dto.response.CommentBlocks; import com.moing.backend.domain.boardComment.application.dto.response.GetBoardCommentResponse; +import com.moing.backend.domain.boardComment.application.dto.response.QCommentBlocks; import com.moing.backend.domain.teamMember.domain.entity.QTeamMember; import com.moing.backend.domain.teamMember.domain.entity.TeamMember; import com.querydsl.core.types.ExpressionUtils; @@ -26,7 +27,7 @@ public BoardCommentCustomRepositoryImpl(EntityManager em) { @Override public GetBoardCommentResponse findBoardCommentAll(Long boardId, TeamMember teamMember) { List commentBlocks = queryFactory - .select(Projections.constructor(CommentBlocks.class, + .select(new QCommentBlocks( boardComment.boardCommentId, boardComment.content, boardComment.writerNickName, @@ -38,14 +39,13 @@ public GetBoardCommentResponse findBoardCommentAll(Long boardId, TeamMember team .where(QTeamMember.teamMember.eq(teamMember) .and(QTeamMember.teamMember.eq(boardComment.teamMember))) .exists(), "isWriter"), - boardComment.teamMember.isDeleted)) + boardComment.teamMember.isDeleted, + boardComment.createdDate)) .from(boardComment) .where(boardComment.board.boardId.eq(boardId)) .orderBy(boardComment.createdDate.asc()) .fetch(); - commentBlocks.forEach(CommentBlocks::deleteMember); - return new GetBoardCommentResponse(commentBlocks); } } diff --git a/src/main/java/com/moing/backend/domain/history/application/service/SaveSingleAlarmHistoryUseCase.java b/src/main/java/com/moing/backend/domain/history/application/service/SaveSingleAlarmHistoryUseCase.java index fbfe00a0..61030af7 100644 --- a/src/main/java/com/moing/backend/domain/history/application/service/SaveSingleAlarmHistoryUseCase.java +++ b/src/main/java/com/moing/backend/domain/history/application/service/SaveSingleAlarmHistoryUseCase.java @@ -16,7 +16,7 @@ public class SaveSingleAlarmHistoryUseCase { private final AlarmHistorySaveService alarmHistorySaveService; @Async - public void saveAlarmHistory(String fcmToken, Long memberId, String idInfo, String title, String body, String name, AlarmType alarmType, String path) { + public void saveAlarmHistory(Long memberId, String idInfo, String title, String body, String name, AlarmType alarmType, String path) { AlarmHistory alarmHistory = alarmHistoryMapper.toAlarmHistory(alarmType, path, idInfo, memberId, title, body, name); alarmHistorySaveService.saveAlarmHistory(alarmHistory); } diff --git a/src/main/java/com/moing/backend/domain/mypage/application/dto/response/GetMyPageTeamBlock.java b/src/main/java/com/moing/backend/domain/mypage/application/dto/response/GetMyPageTeamBlock.java index a05783c9..fd6f6d19 100644 --- a/src/main/java/com/moing/backend/domain/mypage/application/dto/response/GetMyPageTeamBlock.java +++ b/src/main/java/com/moing/backend/domain/mypage/application/dto/response/GetMyPageTeamBlock.java @@ -11,4 +11,5 @@ public class GetMyPageTeamBlock { private Long teamId; private String teamName; private Category category; + private String profileImgUrl; } diff --git a/src/main/java/com/moing/backend/domain/team/application/dto/response/TeamBlock.java b/src/main/java/com/moing/backend/domain/team/application/dto/response/TeamBlock.java index 7c2e1803..43c76e1c 100644 --- a/src/main/java/com/moing/backend/domain/team/application/dto/response/TeamBlock.java +++ b/src/main/java/com/moing/backend/domain/team/application/dto/response/TeamBlock.java @@ -7,7 +7,6 @@ import lombok.Getter; import lombok.NoArgsConstructor; -import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; @@ -27,9 +26,10 @@ public class TeamBlock { private String category; private String startDate; private LocalDateTime deletionTime; + private String profileImgUrl; @QueryProjection - public TeamBlock(Long teamId, LocalDateTime approvalTime, Integer levelOfFire, String teamName, Integer numOfMember, Category category, LocalDateTime deletionTime){ + public TeamBlock(Long teamId, LocalDateTime approvalTime, Integer levelOfFire, String teamName, Integer numOfMember, Category category, LocalDateTime deletionTime, String profileImgUrl) { this.teamId=teamId; this.duration=calculateDuration(approvalTime); this.levelOfFire=levelOfFire; @@ -38,6 +38,7 @@ public TeamBlock(Long teamId, LocalDateTime approvalTime, Integer levelOfFire, S this.category=category.getMessage(); this.startDate=approvalTime.toLocalDate().format(DateTimeFormatter.ofPattern("yyyy.MM.dd")); this.deletionTime=deletionTime; + this.profileImgUrl = profileImgUrl; } public Long calculateDuration(LocalDateTime approvalTime) { diff --git a/src/main/java/com/moing/backend/domain/team/domain/repository/TeamCustomRepositoryImpl.java b/src/main/java/com/moing/backend/domain/team/domain/repository/TeamCustomRepositoryImpl.java index f5c764c8..41a03a07 100644 --- a/src/main/java/com/moing/backend/domain/team/domain/repository/TeamCustomRepositoryImpl.java +++ b/src/main/java/com/moing/backend/domain/team/domain/repository/TeamCustomRepositoryImpl.java @@ -71,7 +71,7 @@ public List findTeamIdByMemberId(Long memberId){ public List findMyPageTeamByMemberId(Long memberId) { return queryFactory .select(Projections.constructor(GetMyPageTeamBlock.class, - team.teamId, team.name, team.category)) + team.teamId, team.name, team.category, team.profileImgUrl)) .from(teamMember) .innerJoin(teamMember.team, team) .on(teamMember.member.memberId.eq(memberId)) @@ -91,7 +91,8 @@ private List getTeamBlock(Long memberId) { team.name, team.numOfMember, team.category, - team.deletionTime)) + team.deletionTime, + team.profileImgUrl)) .from(teamMember) .innerJoin(teamMember.team, team) .on(teamMember.member.memberId.eq(memberId)) diff --git a/src/main/java/com/moing/backend/global/config/fcm/service/FcmService.java b/src/main/java/com/moing/backend/global/config/fcm/service/FcmService.java index 30276df5..fe5f10a9 100644 --- a/src/main/java/com/moing/backend/global/config/fcm/service/FcmService.java +++ b/src/main/java/com/moing/backend/global/config/fcm/service/FcmService.java @@ -24,7 +24,6 @@ public class FcmService { private final FirebaseMessaging firebaseMessaging; - @Retryable(value = FirebaseMessagingException.class, maxAttempts = 3, backoff = @Backoff(delay = 1000)) public SingleResponse sendSingleDevice(SingleRequest toSingleRequest) { diff --git a/src/test/java/com/moing/backend/domain/boardComment/presentation/BoardCommentControllerTest.java b/src/test/java/com/moing/backend/domain/boardComment/presentation/BoardCommentControllerTest.java index 3175bc6f..637ef310 100644 --- a/src/test/java/com/moing/backend/domain/boardComment/presentation/BoardCommentControllerTest.java +++ b/src/test/java/com/moing/backend/domain/boardComment/presentation/BoardCommentControllerTest.java @@ -142,6 +142,7 @@ public void get_board_comment_all() throws Exception { .writerProfileImage("작성자 프로필 이미지") .writerIsDeleted(false) .isWriter(true) + .createdDate("2023/12/05 23:29") .build(); commentBlocks.add(commentBlock); @@ -174,13 +175,14 @@ public void get_board_comment_all() throws Exception { responseFields( fieldWithPath("isSuccess").description("true"), fieldWithPath("message").description("댓글 목록을 모두 조회했습니다."), - fieldWithPath("data.commentBlocks[0].boardCommentId").description("댓글 아이디"), - fieldWithPath("data.commentBlocks[0].content").description("댓글 내용"), - fieldWithPath("data.commentBlocks[0].writerIsLeader").description("작성자 소모임장 여부"), - fieldWithPath("data.commentBlocks[0].writerNickName").description("작성자 닉네임"), - fieldWithPath("data.commentBlocks[0].writerProfileImage").description("작성자 프로필 이미지"), - fieldWithPath("data.commentBlocks[0].writerIsDeleted").description("작성자 삭제 여부"), - fieldWithPath("data.commentBlocks[0].isWriter").description("댓글 작성자 여부") + fieldWithPath("data.commentBlocks[].boardCommentId").description("댓글 아이디"), + fieldWithPath("data.commentBlocks[].content").description("댓글 내용"), + fieldWithPath("data.commentBlocks[].writerIsLeader").description("작성자 소모임장 여부"), + fieldWithPath("data.commentBlocks[].writerNickName").description("작성자 닉네임"), + fieldWithPath("data.commentBlocks[].writerProfileImage").description("작성자 프로필 이미지"), + fieldWithPath("data.commentBlocks[].writerIsDeleted").description("작성자 삭제 여부"), + fieldWithPath("data.commentBlocks[].isWriter").description("댓글 작성자 여부"), + fieldWithPath("data.commentBlocks[].createdDate").description("생성 시간") ) ) diff --git a/src/test/java/com/moing/backend/domain/mypage/presentation/MypageControllerTest.java b/src/test/java/com/moing/backend/domain/mypage/presentation/MypageControllerTest.java index c2932b6a..125aa2ea 100644 --- a/src/test/java/com/moing/backend/domain/mypage/presentation/MypageControllerTest.java +++ b/src/test/java/com/moing/backend/domain/mypage/presentation/MypageControllerTest.java @@ -125,6 +125,7 @@ public void get_mypage() throws Exception{ .teamId(1L) .teamName("소모임이름") .category(Category.SPORTS) + .profileImgUrl("프로필 이미지 url") .build(); getMyPageTeamBlocks.add(blocks); @@ -160,10 +161,11 @@ public void get_mypage() throws Exception{ fieldWithPath("data.profileImage").description("프로필 이미지 URL"), fieldWithPath("data.nickName").description("닉네임"), fieldWithPath("data.introduction").description("한줄 소개"), - fieldWithPath("data.categories[0]").description("내 열정의 불 해시태그"), - fieldWithPath("data.getMyPageTeamBlocks[0].teamId").description("소모임 아이디"), - fieldWithPath("data.getMyPageTeamBlocks[0].teamName").description("소모임 이름"), - fieldWithPath("data.getMyPageTeamBlocks[0].category").description("소모임 카테고리") + fieldWithPath("data.categories[]").description("내 열정의 불 해시태그"), + fieldWithPath("data.getMyPageTeamBlocks[].teamId").description("소모임 아이디"), + fieldWithPath("data.getMyPageTeamBlocks[].teamName").description("소모임 이름"), + fieldWithPath("data.getMyPageTeamBlocks[].category").description("소모임 카테고리"), + fieldWithPath("data.getMyPageTeamBlocks[].profileImgUrl").description("소모임 프로필 이미지 URL") ) ) ); diff --git a/src/test/java/com/moing/backend/domain/team/presentation/TeamControllerTest.java b/src/test/java/com/moing/backend/domain/team/presentation/TeamControllerTest.java index 7306ffe0..96b0cae6 100644 --- a/src/test/java/com/moing/backend/domain/team/presentation/TeamControllerTest.java +++ b/src/test/java/com/moing/backend/domain/team/presentation/TeamControllerTest.java @@ -112,6 +112,7 @@ public void get_team() throws Exception { .category("ETC") .startDate("2023.09.05") .deletionTime(LocalDateTime.now().withNano(0)) + .profileImgUrl("프로필 사진 url") .build(); TeamBlock teamBlock2=TeamBlock.builder() @@ -123,6 +124,7 @@ public void get_team() throws Exception { .category("SPORTS") .startDate("2023.09.01") .deletionTime(LocalDateTime.now().withNano(0)) + .profileImgUrl("프로필 사진 url") .build(); teamBlocks.add(teamBlock1); @@ -158,14 +160,15 @@ public void get_team() throws Exception { fieldWithPath("message").description("홈 화면에서 내 소모임을 모두 조회했습니다."), fieldWithPath("data.numOfTeam").description("소모임 개수(최대 3개)"), fieldWithPath("data.memberNickName").description("유저 닉네임"), - fieldWithPath("data.teamBlocks[0].teamId").description("소모임 아이디"), - fieldWithPath("data.teamBlocks[0].duration").description("소모임과 함께한 시간"), - fieldWithPath("data.teamBlocks[0].levelOfFire").description("불꽃 레벨"), - fieldWithPath("data.teamBlocks[0].teamName").description("소모임 이름"), - fieldWithPath("data.teamBlocks[0].numOfMember").description("소모임원 명 수"), - fieldWithPath("data.teamBlocks[0].category").description("소모임 카테고리"), - fieldWithPath("data.teamBlocks[0].startDate").description("소모임 시작일"), - fieldWithPath("data.teamBlocks[0].deletionTime").description("소모임 삭제 시간 (삭제 안했으면 null)") + fieldWithPath("data.teamBlocks[].teamId").description("소모임 아이디"), + fieldWithPath("data.teamBlocks[].duration").description("소모임과 함께한 시간"), + fieldWithPath("data.teamBlocks[].levelOfFire").description("불꽃 레벨"), + fieldWithPath("data.teamBlocks[].teamName").description("소모임 이름"), + fieldWithPath("data.teamBlocks[].numOfMember").description("소모임원 명 수"), + fieldWithPath("data.teamBlocks[].category").description("소모임 카테고리"), + fieldWithPath("data.teamBlocks[].startDate").description("소모임 시작일"), + fieldWithPath("data.teamBlocks[].deletionTime").description("소모임 삭제 시간 (삭제 안했으면 null)"), + fieldWithPath("data.teamBlocks[].profileImgUrl").description("프로필 사진 url") ) )