Skip to content

Commit

Permalink
feat: board 조회 responseDto 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
char-yb committed Apr 6, 2024

Verified

This commit was signed with the committer’s verified signature.
ctrlcctrlv Fredrick Brennan
1 parent f33439e commit f675c5f
Showing 9 changed files with 28 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -30,9 +30,8 @@ public FindOneBoardResponse getBoard(
* 사용자가 작성한 일지 목록 조회
*/
@GetMapping("/boards")
public List<FindBoardResponse> getMyBoards(@LoginUsers CustomUserDetails userDetails) {
FindBoardListResponse tmp = boardService.getMyBoards(userDetails.getMemberId());
return tmp.boards();
public List<FindOneBoardResponse> getMyBoards(@LoginUsers CustomUserDetails userDetails) {
return boardService.getMyBoards(userDetails.getMemberId());
}

/**
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ public static BoardResponseDto from(Board board) {
board.getBoardId(),
board.getContent(),
board.getRespectBoardId(),
board.getMemeber().getId(),
board.getMember().getId(),
board.getCategory(),
board.getHearts(),
hashContents,
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ public static FindBoardResponse from(Board board) {
board.getBoardId(),
board.getContent(),
board.getRespectBoardId(),
board.getMemeber().getId(),
board.getMember().getId(),
board.getCategory(),
board.getHearts(),
board.getPaperType(),
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ public static FindOneBoardResponse of(Board board, List<ReactionTypeAndCount> re
board.getBoardId(),
board.getContent(),
board.getRespectBoardId(),
board.getMemeber().getId(),
board.getMember().getId(),
board.getCategory(),
heartsFromReactions,
hashContents,
4 changes: 2 additions & 2 deletions src/main/java/com/unit/daybook/domain/board/entity/Board.java
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ public class Board extends BaseTimeEntity {

@ManyToOne
@JoinColumn(name = "member_id")
private Member memeber;
private Member member;

@Column
private String paperType;
@@ -57,7 +57,7 @@ public Board(Long boardId, String content, Long respectBoardId, Member member, S
this.boardId = boardId;
this.content = content;
this.respectBoardId = respectBoardId;
this.memeber = member;
this.member = member;
this.category = category;
this.hearts = hearts;
this.paperType = paperType;
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

import java.util.List;

import com.unit.daybook.domain.board.dto.response.FindOneBoardResponse;
import com.unit.daybook.domain.board.entity.Board;

public interface BoardRepositoryCustom {
Original file line number Diff line number Diff line change
@@ -20,9 +20,9 @@ public class BoardRepositoryImpl implements BoardRepositoryCustom {
public List<Board> findBoardsByMemberId(Long memberId) {

return queryFactory
.select(board)
.from(board)
.join(board.memeber, member).fetchJoin()
.selectFrom(board)
.leftJoin(board.member, member)
.fetchJoin()
.where(
member.id.eq(memberId)
)
@@ -34,7 +34,7 @@ public List<Board> findNotReadBoardsByMemberId(Long memberId, List<Board> alread
return queryFactory
.select(board)
.from(board)
.join(board.memeber, member).fetchJoin()
.join(board.member, member).fetchJoin()
.where(
// member.id.eq(memberId)
//.and(
@@ -88,7 +88,7 @@ public List<Board> findCurrentBoards(Long memberId) {
tmps.add(memberId);
return queryFactory
.selectFrom(board)
.where(board.memeber.id.notIn(tmps))
.where(board.member.id.notIn(tmps))
.fetch();
}
}
Original file line number Diff line number Diff line change
@@ -64,17 +64,24 @@ public FindOneBoardResponse getBoard(Long boardId) {
Board board = boardRepository.findById(boardId)
.orElseThrow(() -> new CustomException(ErrorCode.BOARD_NOT_FOUND));
List<ReactionTypeAndCount> reactions = reactionRepository.findAllByBoardGroupByReactionType(board);
List<FindOneCommentResponse> comments = commentRepository.findCommentByBoard(boardId)
.stream()
.map(FindOneCommentResponse::from)
.toList();
return FindOneBoardResponse.of(board, reactions, comments);
// List<FindOneCommentResponse> comments = commentRepository.findCommentByBoard(boardId)
// .stream()
// .map(FindOneCommentResponse::from)
// .toList();
return FindOneBoardResponse.of(board, reactions, List.of());
}

@Transactional(readOnly = true)
public FindBoardListResponse getMyBoards(Long memberId) {
List<Board> boards= boardRepository.findBoardsByMemberId(memberId);
return FindBoardListResponse.from(boards);
public List<FindOneBoardResponse> getMyBoards(Long memberId) {
List<Board> boards = boardRepository.findBoardsByMemberId(memberId);
List<FindOneBoardResponse> boardResponses = new ArrayList<>();

for (Board board : boards) {
List<ReactionTypeAndCount> reactions = reactionRepository.findAllByBoardGroupByReactionType(board);
boardResponses.add(FindOneBoardResponse.of(board, reactions, List.of()));
}

return boardResponses;
}

public List<BoardResponseDto> getRandomBoards(Long memberId) {
6 changes: 0 additions & 6 deletions src/main/java/com/unit/daybook/global/util/JwtUtil.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
package com.unit.daybook.global.util;

import java.nio.charset.StandardCharsets;
import java.security.Key;
import java.util.Base64;
import java.util.Map;

import javax.crypto.SecretKey;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jws;
import io.jsonwebtoken.JwsHeader;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import io.jsonwebtoken.security.Keys;

@Component
public class JwtUtil {

0 comments on commit f675c5f

Please sign in to comment.