From 75458623d6b29bce542e64756c62b5f029e60c20 Mon Sep 17 00:00:00 2001 From: Geunsik Kim <93639883+600gramSik@users.noreply.github.com> Date: Tue, 18 Jun 2024 17:26:48 +0900 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8Frefactor:=20Conflict=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0=20=EC=A4=91=20=EC=97=90=EB=9F=AC=EC=82=AC?= =?UTF-8?q?=ED=95=AD=20=EC=88=98=EC=A0=95(#133)=20(#134)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../board/controller/BoardController.java | 7 +++--- .../board/service/BoardQueryService.java | 7 +++--- .../domain/board/service/BoardService.java | 2 +- .../myteam/controller/TeamController.java | 9 +------ .../domain/tactic/service/TacticService.java | 24 +------------------ 5 files changed, 9 insertions(+), 40 deletions(-) diff --git a/src/main/java/com/capstone/BnagFer/domain/board/controller/BoardController.java b/src/main/java/com/capstone/BnagFer/domain/board/controller/BoardController.java index 46b09d35..911132ba 100644 --- a/src/main/java/com/capstone/BnagFer/domain/board/controller/BoardController.java +++ b/src/main/java/com/capstone/BnagFer/domain/board/controller/BoardController.java @@ -34,8 +34,7 @@ public class BoardController { @GetMapping //게시판 리스트 조회 @Operation(summary = "게시판 목록 조회", description = "전체 게시판 목록을 조회합니다. 페이징 적용, 생성 날짜 기준 내림차순 정렬.") - @GetMapping - public ApiResponse> getBoardsList( + public ApiResponse> getBoardsList( @RequestParam(defaultValue = "0") int page, @RequestParam(defaultValue = "10") int size) @@ -67,13 +66,13 @@ public ApiResponse> getMyBoardsList( @Operation(summary = "사용자 게시물 목록 조회", description = "특정 사람이 작성한 게시글 목록 조회. 페이징 적용, 생성 날짜 기준 내림차순 정렬.") @GetMapping("/users/{userId}/boards") - public ApiResponse> getUserBoardsList( + public ApiResponse> getUserBoardsList( @PathVariable Long userId, @RequestParam(defaultValue = "0") int page, @RequestParam(defaultValue = "10") int size) { Pageable pageable = PageRequest.of(page, size); - Page userBoardsList = boardQueryService.getUserBoards(userId, pageable); + Page userBoardsList = boardQueryService.getUserBoards(userId, pageable); return onSuccess(userBoardsList); } diff --git a/src/main/java/com/capstone/BnagFer/domain/board/service/BoardQueryService.java b/src/main/java/com/capstone/BnagFer/domain/board/service/BoardQueryService.java index 79f28663..7c4401d3 100644 --- a/src/main/java/com/capstone/BnagFer/domain/board/service/BoardQueryService.java +++ b/src/main/java/com/capstone/BnagFer/domain/board/service/BoardQueryService.java @@ -35,15 +35,14 @@ public Page getMyBoards(User user, Pageable pageable) { return boards.map(BoardListDto::from); } - public BoardDetailResponseDto getBoard(Long boardId) { - public Page getUserBoards(Long userId, Pageable pageable) { + public Page getUserBoards(Long userId, Pageable pageable) { User user = userJpaRepository.findById(userId) .orElseThrow(() -> new AccountsExceptionHandler(ErrorCode.USER_NOT_FOUND)); Page 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); diff --git a/src/main/java/com/capstone/BnagFer/domain/board/service/BoardService.java b/src/main/java/com/capstone/BnagFer/domain/board/service/BoardService.java index 8b0dd08f..60289b1f 100644 --- a/src/main/java/com/capstone/BnagFer/domain/board/service/BoardService.java +++ b/src/main/java/com/capstone/BnagFer/domain/board/service/BoardService.java @@ -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; @@ -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; diff --git a/src/main/java/com/capstone/BnagFer/domain/myteam/controller/TeamController.java b/src/main/java/com/capstone/BnagFer/domain/myteam/controller/TeamController.java index 6ec54bca..9a4889ba 100644 --- a/src/main/java/com/capstone/BnagFer/domain/myteam/controller/TeamController.java +++ b/src/main/java/com/capstone/BnagFer/domain/myteam/controller/TeamController.java @@ -88,14 +88,7 @@ public ApiResponse> getMyTactic(@ } @GetMapping("/{teamId}/{positionDetailId}") public ApiResponse getIndividualDetail(@PathVariable Long teamId, Long positionDetailId) { - GetTeamResponseDto.getIndividualDetail positionDetail = teamQueryService .getIndividualDetail(teamId, positionDetailId); - - - @Operation(summary = "포지션 세부 설명", description = "11개의 포지션 버튼을 눌러 포지션의 세부 설명을 확인하는 기능") - @GetMapping("/{teamId}/{memberId}/positionDetail") - public ApiResponse> getIndividualDetail(@PathVariable Long teamId, @PathVariable Long memberId, @LoginUser User user) { - List positionDetail = teamQueryService .getIndividualDetail(teamId, memberId, user); - + GetTeamResponseDto.getIndividualDetail positionDetail = teamQueryService.getIndividualDetail(teamId, positionDetailId); return ApiResponse.onSuccess(positionDetail); } diff --git a/src/main/java/com/capstone/BnagFer/domain/tactic/service/TacticService.java b/src/main/java/com/capstone/BnagFer/domain/tactic/service/TacticService.java index a8d0ca02..24bdf881 100644 --- a/src/main/java/com/capstone/BnagFer/domain/tactic/service/TacticService.java +++ b/src/main/java/com/capstone/BnagFer/domain/tactic/service/TacticService.java @@ -135,7 +135,7 @@ 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); @@ -143,28 +143,6 @@ public void deleteComment(Long commentId, User user) { redisUtil.saveCommentCount(tacticId, commentCount); } -public ApiResponse likeButton(Long tacticId, User user) { - - Tactic tactic = tacticRepository.findById(tacticId).orElseThrow(() -> new TacticExceptionHandler(ErrorCode.TACTIC_NOT_FOUND)); - - Optional 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 likeButton(Long tacticId, User user) { Tactic tactic = tacticRepository.findById(tacticId).orElseThrow(() -> new TacticExceptionHandler(ErrorCode.TACTIC_NOT_FOUND));