Skip to content

Commit

Permalink
♻️refactor: Conflict 해결 중 에러사항 수정(#133) (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
600gramSik authored Jun 18, 2024
1 parent 68727b5 commit 7545862
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public class BoardController {

@GetMapping //게시판 리스트 조회
@Operation(summary = "게시판 목록 조회", description = "전체 게시판 목록을 조회합니다. 페이징 적용, 생성 날짜 기준 내림차순 정렬.")
@GetMapping
public ApiResponse<Page<BoardDetailResponseDto.BoardList>> getBoardsList(
public ApiResponse<Page<BoardListDto>> getBoardsList(

@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "10") int size)
Expand Down Expand Up @@ -67,13 +66,13 @@ public ApiResponse<Page<BoardListDto>> getMyBoardsList(

@Operation(summary = "사용자 게시물 목록 조회", description = "특정 사람이 작성한 게시글 목록 조회. 페이징 적용, 생성 날짜 기준 내림차순 정렬.")
@GetMapping("/users/{userId}/boards")
public ApiResponse<Page<BoardDetailResponseDto.BoardList>> getUserBoardsList(
public ApiResponse<Page<BoardListDto>> getUserBoardsList(
@PathVariable Long userId,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "10") int size)
{
Pageable pageable = PageRequest.of(page, size);
Page<BoardDetailResponseDto.BoardList> userBoardsList = boardQueryService.getUserBoards(userId, pageable);
Page<BoardListDto> userBoardsList = boardQueryService.getUserBoards(userId, pageable);
return onSuccess(userBoardsList);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,14 @@ public Page<BoardListDto> getMyBoards(User user, Pageable pageable) {
return boards.map(BoardListDto::from);
}

public BoardDetailResponseDto getBoard(Long boardId) {
public Page<BoardDetailResponseDto.BoardList> getUserBoards(Long userId, Pageable pageable) {
public Page<BoardListDto> getUserBoards(Long userId, Pageable pageable) {
User user = userJpaRepository.findById(userId)
.orElseThrow(() -> new AccountsExceptionHandler(ErrorCode.USER_NOT_FOUND));
Page<Board> boards = getBoardsByUser(user, pageable);
return boards.map(BoardDetailResponseDto.BoardList::from);
return boards.map(BoardListDto::from);
}

public BoardResponseDto getBoard(Long boardId) {
public BoardDetailResponseDto getBoard(Long boardId) {
Board board = boardRepository.findById(boardId).orElseThrow(() -> new BoardExceptionHandler(ErrorCode.BOARD_NOT_FOUND));
Long likeCount = redisUtil.boardGetLikeCount(boardId);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.capstone.BnagFer.domain.board.service;

import com.capstone.BnagFer.domain.accounts.entity.User;
import com.capstone.BnagFer.domain.accounts.jwt.util.RedisUtil;
import com.capstone.BnagFer.domain.accounts.service.account.AccountsCommonService;
import com.capstone.BnagFer.domain.board.dto.request.BoardRequestDto;
import com.capstone.BnagFer.domain.board.dto.request.CreateCommentRequestDto;
Expand All @@ -17,6 +16,7 @@
import com.capstone.BnagFer.domain.board.repository.BoardRepository;
import com.capstone.BnagFer.global.common.ApiResponse;
import com.capstone.BnagFer.global.common.ErrorCode;
import com.capstone.BnagFer.global.util.RedisUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,7 @@ public ApiResponse<List<CreateTeamTacticResponseDto.MyTacticList>> getMyTactic(@
}
@GetMapping("/{teamId}/{positionDetailId}")
public ApiResponse<GetTeamResponseDto.getIndividualDetail> getIndividualDetail(@PathVariable Long teamId, Long positionDetailId) {
GetTeamResponseDto.getIndividualDetail positionDetail = teamQueryService .getIndividualDetail(teamId, positionDetailId);


@Operation(summary = "포지션 세부 설명", description = "11개의 포지션 버튼을 눌러 포지션의 세부 설명을 확인하는 기능")
@GetMapping("/{teamId}/{memberId}/positionDetail")
public ApiResponse<List<GetTeamResponseDto.getIndividualDetail>> getIndividualDetail(@PathVariable Long teamId, @PathVariable Long memberId, @LoginUser User user) {
List<GetTeamResponseDto.getIndividualDetail> positionDetail = teamQueryService .getIndividualDetail(teamId, memberId, user);

GetTeamResponseDto.getIndividualDetail positionDetail = teamQueryService.getIndividualDetail(teamId, positionDetailId);
return ApiResponse.onSuccess(positionDetail);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,36 +135,14 @@ public void deleteComment(Long commentId, User user) {
long commentCount = redisUtil.getCommentCount(tacticId);
long chlidCnt = tacticComment.getChildren().size();

if(!tacticComment.getUser().getId().equals(user.getId()))
if (!tacticComment.getUser().getId().equals(user.getId()))
throw new TacticExceptionHandler(ErrorCode.USER_NOT_MATCHED);

commentRepository.deleteById(commentId);
commentCount -= (chlidCnt + 1L);
redisUtil.saveCommentCount(tacticId, commentCount);
}

public ApiResponse<Object> likeButton(Long tacticId, User user) {

Tactic tactic = tacticRepository.findById(tacticId).orElseThrow(() -> new TacticExceptionHandler(ErrorCode.TACTIC_NOT_FOUND));

Optional<TacticLike> like = likeRepository.findByUserAndTactic(user, tactic);

long likeCount = redisUtil.getLikeCount(tacticId);

if (like.isPresent()) {
likeRepository.delete(like.get());
likeCount--;
redisUtil.saveLikeCount(tacticId, likeCount);
return ApiResponse.CANCELED_LIKE();
} else {
likeRepository.save(new TacticLike(user, tactic));
likeCount++;
redisUtil.saveLikeCount(tacticId, likeCount);
return ApiResponse.SUCCESS_LIKE();
}
}


public ApiResponse<Object> likeButton(Long tacticId, User user) {

Tactic tactic = tacticRepository.findById(tacticId).orElseThrow(() -> new TacticExceptionHandler(ErrorCode.TACTIC_NOT_FOUND));
Expand Down

0 comments on commit 7545862

Please sign in to comment.