Skip to content

Commit

Permalink
Merge pull request #66 from Team-UMC/refactor/#63/board-refactor
Browse files Browse the repository at this point in the history
[REFACTOR,FIX] BOARD API ๋ฆฌํŒฉํ† ๋ง, ์ˆ˜์ •
  • Loading branch information
junseokkim authored Feb 8, 2024
2 parents 7783f24 + 073a651 commit d347ac1
Show file tree
Hide file tree
Showing 41 changed files with 650 additions and 789 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package com.umc.networkingService.domain.board.controller;

import com.umc.networkingService.config.security.auth.CurrentMember;
import com.umc.networkingService.domain.board.dto.request.comment.BoardCommentAddRequest;
import com.umc.networkingService.domain.board.dto.request.comment.BoardCommentUpdateRequest;
import com.umc.networkingService.domain.board.dto.response.comment.BoardCommentIdResponse;
import com.umc.networkingService.domain.board.dto.response.comment.BoardCommentPagingResponse;
import com.umc.networkingService.domain.board.dto.response.member.MyBoardCommentPagingWebResponse;
import com.umc.networkingService.domain.board.dto.response.member.MyBoardPagingResponse;
import com.umc.networkingService.domain.board.dto.request.BoardCommentRequest;
import com.umc.networkingService.domain.board.dto.response.BoardCommentResponse;
import com.umc.networkingService.domain.board.dto.response.MyBoardResponse;
import com.umc.networkingService.domain.board.entity.BoardType;
import com.umc.networkingService.domain.board.entity.HostType;
import com.umc.networkingService.domain.board.service.BoardCommentService;
Expand Down Expand Up @@ -41,8 +38,8 @@ public class BoardCommentController {
@ApiResponse(responseCode = "BOARD002", description = "๊ฒŒ์‹œ๊ธ€์„ ์ฐพ์„ ์ˆ˜ ์—†์„ ๊ฒฝ์šฐ ๋ฐœ์ƒ")
})
@PostMapping
public BaseResponse<BoardCommentIdResponse> addBoardComment(@CurrentMember Member member,
@Valid @RequestBody BoardCommentAddRequest request) {
public BaseResponse<BoardCommentResponse.BoardCommentId> addBoardComment(@CurrentMember Member member,
@Valid @RequestBody BoardCommentRequest.BoardCommentAddRequest request) {
return BaseResponse.onSuccess(boardCommentService.addBoardComment(member, request));
}

Expand All @@ -54,9 +51,9 @@ public BaseResponse<BoardCommentIdResponse> addBoardComment(@CurrentMember Membe

})
@PatchMapping("/{commentId}")
public BaseResponse<BoardCommentIdResponse> updateBoardComment(@CurrentMember Member member,
@PathVariable(value = "commentId") UUID commentId,
@Valid @RequestBody BoardCommentUpdateRequest request) {
public BaseResponse<BoardCommentResponse.BoardCommentId> updateBoardComment(@CurrentMember Member member,
@PathVariable(value = "commentId") UUID commentId,
@Valid @RequestBody BoardCommentRequest.BoardCommentUpdateRequest request) {
return BaseResponse.onSuccess(boardCommentService.updateBoardComment(member, commentId, request));
}

Expand All @@ -68,8 +65,8 @@ public BaseResponse<BoardCommentIdResponse> updateBoardComment(@CurrentMember Me
@ApiResponse(responseCode = "COMMENT002", description = "๋Œ“๊ธ€ ์‚ญ์ œ ๊ถŒํ•œ์ด ์—†์„ ๊ฒฝ์šฐ ๋ฐœ์ƒ")
})
@DeleteMapping("/{commentId}")
public BaseResponse<BoardCommentIdResponse> deleteBoardComment(@CurrentMember Member member,
@PathVariable(value = "commentId") UUID commentId) {
public BaseResponse<BoardCommentResponse.BoardCommentId> deleteBoardComment(@CurrentMember Member member,
@PathVariable(value = "commentId") UUID commentId) {
return BaseResponse.onSuccess(boardCommentService.deleteBoardComment(member, commentId));
}

Expand All @@ -82,9 +79,9 @@ public BaseResponse<BoardCommentIdResponse> deleteBoardComment(@CurrentMember Me
@Parameter(name = "page", description = " page ์‹œ์ž‘์€ 0๋ฒˆ๋ถ€ํ„ฐ, ์˜ค๋ฆ„์ฐจ์ˆœ์œผ๋กœ ์กฐํšŒ๋ฉ๋‹ˆ๋‹ค.")
})
@GetMapping(value = "/{boardId}")
public BaseResponse<BoardCommentPagingResponse> showBoardComments(@CurrentMember Member member,
@PathVariable(value = "boardId") UUID boardId,
@PageableDefault(sort = "created_at", direction = Sort.Direction.ASC)
public BaseResponse<BoardCommentResponse.BoardCommentPageInfos> showBoardComments(@CurrentMember Member member,
@PathVariable(value = "boardId") UUID boardId,
@PageableDefault(sort = "created_at", direction = Sort.Direction.ASC)
@Parameter(hidden = true) Pageable pageable) {
return BaseResponse.onSuccess(boardCommentService.showBoardComments(member, boardId, pageable));
}
Expand All @@ -98,9 +95,9 @@ public BaseResponse<BoardCommentPagingResponse> showBoardComments(@CurrentMember
@Parameter(name = "page", description = "page ์‹œ์ž‘์€ 0๋ฒˆ๋ถ€ํ„ฐ, ๋‚ด๋ฆผ์ฐจ์ˆœ์œผ๋กœ ์กฐํšŒ๋ฉ๋‹ˆ๋‹ค.")
})
@GetMapping(value = "/member/comments/app")
public BaseResponse<MyBoardPagingResponse> showBoardsByMemberCommentsForApp(@CurrentMember Member member,
@RequestParam(name = "keyword", required = false) String keyword,
@PageableDefault(sort = "created_at", direction = Sort.Direction.DESC)
public BaseResponse<MyBoardResponse.MyBoardPageInfos> showBoardsByMemberCommentsForApp(@CurrentMember Member member,
@RequestParam(name = "keyword", required = false) String keyword,
@PageableDefault(sort = "created_at", direction = Sort.Direction.DESC)
@Parameter(hidden = true) Pageable pageable) {
return BaseResponse.onSuccess(boardCommentService.showBoardsByMemberCommentForApp(member, keyword, pageable));
}
Expand All @@ -116,7 +113,7 @@ public BaseResponse<MyBoardPagingResponse> showBoardsByMemberCommentsForApp(@Cur
@Parameter(name = "keyword", description = "keyword๋ฅผ ์ฃผ์ง€ ์•Š์œผ๋ฉด ๋ชจ๋“  ๋‚ด๊ฐ€ ๋Œ“๊ธ€ ์“ด ๊ธ€์ด ์กฐํšŒ๋ฉ๋‹ˆ๋‹ค. keyword๋ฅผ ์ฃผ๋ฉด ๊ฒ€์ƒ‰์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค."),
@Parameter(name = "page", description = "page ์‹œ์ž‘์€ 0๋ฒˆ๋ถ€ํ„ฐ, ๋‚ด๋ฆผ์ฐจ์ˆœ์œผ๋กœ ์กฐํšŒ๋ฉ๋‹ˆ๋‹ค.")})
@GetMapping(value = "/member/comments/web")
public BaseResponse<MyBoardCommentPagingWebResponse> showBoardsByMemberCommentForWeb(@CurrentMember Member member,
public BaseResponse<MyBoardResponse.MyBoardCommentPageInfos> showBoardsByMemberCommentForWeb(@CurrentMember Member member,
@RequestParam(name = "host") HostType hostType,
@RequestParam(name = "board") BoardType boardType,
@RequestParam(name = "keyword", required = false) String keyword,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package com.umc.networkingService.domain.board.controller;

import com.umc.networkingService.config.security.auth.CurrentMember;
import com.umc.networkingService.domain.board.dto.request.BoardCreateRequest;
import com.umc.networkingService.domain.board.dto.request.BoardUpdateRequest;
import com.umc.networkingService.domain.board.dto.response.BoardDetailResponse;
import com.umc.networkingService.domain.board.dto.response.BoardIdResponse;
import com.umc.networkingService.domain.board.dto.response.BoardPagingResponse;
import com.umc.networkingService.domain.board.dto.response.BoardSearchPagingResponse;
import com.umc.networkingService.domain.board.dto.response.member.MyBoardPagingResponse;
import com.umc.networkingService.domain.board.dto.request.BoardRequest;
import com.umc.networkingService.domain.board.dto.response.BoardResponse;
import com.umc.networkingService.domain.board.dto.response.MyBoardResponse;
import com.umc.networkingService.domain.board.entity.BoardType;
import com.umc.networkingService.domain.board.entity.HostType;
import com.umc.networkingService.domain.board.service.BoardService;
Expand Down Expand Up @@ -51,9 +47,9 @@ public class BoardController {
@ApiResponse(responseCode = "FILE001", description = "ํŒŒ์ผ S3 ์—…๋กœ๋“œ ์‹คํŒจํ•  ๊ฒฝ์šฐ ๋ฐœ์ƒ")
})
@PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public BaseResponse<BoardIdResponse> createBoard(@CurrentMember Member member,
@Valid @RequestPart("request") BoardCreateRequest request,
@RequestPart(name = "file", required = false) List<MultipartFile> files) {
public BaseResponse<BoardResponse.BoardId> createBoard(@CurrentMember Member member,
@Valid @RequestPart("request") BoardRequest.BoardCreateRequest request,
@RequestPart(name = "file", required = false) List<MultipartFile> files) {
return BaseResponse.onSuccess(boardService.createBoard(member, request, files));
}

Expand All @@ -71,10 +67,10 @@ public BaseResponse<BoardIdResponse> createBoard(@CurrentMember Member member,
@ApiResponse(responseCode = "FILE001", description = "ํŒŒ์ผ S3 ์—…๋กœ๋“œ ์‹คํŒจํ•  ๊ฒฝ์šฐ ๋ฐœ์ƒ")
})
@PatchMapping(value = "/{boardId}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public BaseResponse<BoardIdResponse> updateBoard(@CurrentMember Member member,
@PathVariable(value = "boardId") UUID boardId,
@Valid @RequestPart("request") BoardUpdateRequest request,
@RequestPart(name = "file", required = false) List<MultipartFile> files) {
public BaseResponse<BoardResponse.BoardId> updateBoard(@CurrentMember Member member,
@PathVariable(value = "boardId") UUID boardId,
@Valid @RequestPart("request") BoardRequest.BoardUpdateRequest request,
@RequestPart(name = "file", required = false) List<MultipartFile> files) {

return BaseResponse.onSuccess(boardService.updateBoard(member, boardId, request, files));
}
Expand All @@ -86,8 +82,8 @@ public BaseResponse<BoardIdResponse> updateBoard(@CurrentMember Member member,
@ApiResponse(responseCode = "BOARD003", description = "๊ฒŒ์‹œ๊ธ€์„ ์‚ญ์ œํ•  ๊ถŒํ•œ์ด ์—†์„ ๊ฒฝ์šฐ ๋ฐœ์ƒ"),
})
@DeleteMapping("/{boardId}")
public BaseResponse<BoardIdResponse> deleteBoard(@CurrentMember Member member,
@PathVariable(value = "boardId") UUID boardId) {
public BaseResponse<BoardResponse.BoardId> deleteBoard(@CurrentMember Member member,
@PathVariable(value = "boardId") UUID boardId) {
return BaseResponse.onSuccess(boardService.deleteBoard(member, boardId));
}

Expand All @@ -103,10 +99,10 @@ public BaseResponse<BoardIdResponse> deleteBoard(@CurrentMember Member member,
@Parameter(name = "page", description = "page ์‹œ์ž‘์€ 0๋ฒˆ๋ถ€ํ„ฐ, ๋‚ด๋ฆผ์ฐจ์ˆœ์œผ๋กœ ์กฐํšŒ๋ฉ๋‹ˆ๋‹ค."),
})
@GetMapping
public BaseResponse<BoardPagingResponse> showBoards(@CurrentMember Member member,
@RequestParam(name = "host") HostType hostType,
@RequestParam(name = "board") BoardType boardType,
@PageableDefault(sort = "created_at", direction = Sort.Direction.DESC)
public BaseResponse<BoardResponse.BoardPageInfos> showBoards(@CurrentMember Member member,
@RequestParam(name = "host") HostType hostType,
@RequestParam(name = "board") BoardType boardType,
@PageableDefault(sort = "created_at", direction = Sort.Direction.DESC)
@Parameter(hidden = true) Pageable pageable) {

return BaseResponse.onSuccess(boardService.showBoards(member, hostType, boardType, pageable));
Expand All @@ -119,8 +115,8 @@ public BaseResponse<BoardPagingResponse> showBoards(@CurrentMember Member member
@ApiResponse(responseCode = "BOARD003", description = "๊ฒŒ์‹œ๊ธ€์„ ์กฐํšŒํ•  ๊ถŒํ•œ์ด ์—†์„ ๊ฒฝ์šฐ ๋ฐœ์ƒ"),
})
@GetMapping("/{boardId}")
public BaseResponse<BoardDetailResponse> showBoardDetail(@CurrentMember Member member,
@PathVariable(value = "boardId") UUID boardId) {
public BaseResponse<BoardResponse.BoardDetail> showBoardDetail(@CurrentMember Member member,
@PathVariable(value = "boardId") UUID boardId) {
return BaseResponse.onSuccess(boardService.showBoardDetail(member, boardId));
}

Expand All @@ -134,9 +130,9 @@ public BaseResponse<BoardDetailResponse> showBoardDetail(@CurrentMember Member m
@Parameter(name = "page", description = "page ์‹œ์ž‘์€ 0๋ฒˆ๋ถ€ํ„ฐ, ๋‚ด๋ฆผ์ฐจ์ˆœ์œผ๋กœ ์กฐํšŒ๋ฉ๋‹ˆ๋‹ค."),
})
@GetMapping(value = "/search")
public BaseResponse<BoardSearchPagingResponse> searchBoard(@CurrentMember Member member,
@RequestParam(name = "keyword") String keyword,
@PageableDefault(sort = "created_at", direction = Sort.Direction.DESC)
public BaseResponse<BoardResponse.BoardSearchPageInfos> searchBoard(@CurrentMember Member member,
@RequestParam(name = "keyword") String keyword,
@PageableDefault(sort = "created_at", direction = Sort.Direction.DESC)
@Parameter(hidden = true) Pageable pageable) {

return BaseResponse.onSuccess(boardService.searchBoard(member, keyword, pageable));
Expand All @@ -151,7 +147,7 @@ public BaseResponse<BoardSearchPagingResponse> searchBoard(@CurrentMember Member
@Parameter(name = "page", description = "page ์‹œ์ž‘์€ 0๋ฒˆ๋ถ€ํ„ฐ, ๋‚ด๋ฆผ์ฐจ์ˆœ์œผ๋กœ ์กฐํšŒ๋ฉ๋‹ˆ๋‹ค."),
})
@GetMapping(value = "/member/app")
public BaseResponse<MyBoardPagingResponse> showBoardsByMemberForApp(@CurrentMember Member member,
public BaseResponse<MyBoardResponse.MyBoardPageInfos> showBoardsByMemberForApp(@CurrentMember Member member,
@RequestParam(name = "keyword", required = false) String keyword,
@PageableDefault(sort = "created_at", direction = Sort.Direction.DESC)
@Parameter(hidden = true) Pageable pageable) {
Expand All @@ -171,7 +167,7 @@ public BaseResponse<MyBoardPagingResponse> showBoardsByMemberForApp(@CurrentMemb
@Parameter(name = "page", description = "page ์‹œ์ž‘์€ 0๋ฒˆ๋ถ€ํ„ฐ, ๋‚ด๋ฆผ์ฐจ์ˆœ์œผ๋กœ ์กฐํšŒ๋ฉ๋‹ˆ๋‹ค."),
})
@GetMapping(value = "/member/web")
public BaseResponse<MyBoardPagingResponse> showBoardsByMemberForWeb(@CurrentMember Member member,
public BaseResponse<MyBoardResponse.MyBoardPageInfos> showBoardsByMemberForWeb(@CurrentMember Member member,
@RequestParam(name = "host") HostType hostType,
@RequestParam(name = "board") BoardType boardType,
@RequestParam(name = "keyword", required = false) String keyword,
Expand All @@ -191,7 +187,7 @@ public BaseResponse<MyBoardPagingResponse> showBoardsByMemberForWeb(@CurrentMemb
@Parameter(name = "page", description = "page ์‹œ์ž‘์€ 0๋ฒˆ๋ถ€ํ„ฐ, ๋‚ด๋ฆผ์ฐจ์ˆœ์œผ๋กœ ์กฐํšŒ๋ฉ๋‹ˆ๋‹ค."),
})
@GetMapping(value = "/member/hearts/app")
public BaseResponse<MyBoardPagingResponse> showMemberBoardHeartForApp(@CurrentMember Member member,
public BaseResponse<MyBoardResponse.MyBoardPageInfos> showMemberBoardHeartForApp(@CurrentMember Member member,
@RequestParam(name = "keyword", required = false) String keyword,
@PageableDefault(sort = "created_at", direction = Sort.Direction.DESC)
@Parameter(hidden = true) Pageable pageable) {
Expand All @@ -210,11 +206,11 @@ public BaseResponse<MyBoardPagingResponse> showMemberBoardHeartForApp(@CurrentMe
@Parameter(name = "page", description = "page ์‹œ์ž‘์€ 0๋ฒˆ๋ถ€ํ„ฐ, ๋‚ด๋ฆผ์ฐจ์ˆœ์œผ๋กœ ์กฐํšŒ๋ฉ๋‹ˆ๋‹ค."),
})
@GetMapping(value = "/member/hearts/web")
public BaseResponse<MyBoardPagingResponse> showMemberBoardHeartForWeb(@CurrentMember Member member,
@RequestParam(name = "host") HostType hostType,
@RequestParam(name = "board") BoardType boardType,
@RequestParam(name = "keyword", required = false) String keyword,
@PageableDefault(sort = "created_at", direction = Sort.Direction.DESC)
public BaseResponse<MyBoardResponse.MyBoardPageInfos> showMemberBoardHeartForWeb(@CurrentMember Member member,
@RequestParam(name = "host") HostType hostType,
@RequestParam(name = "board") BoardType boardType,
@RequestParam(name = "keyword", required = false) String keyword,
@PageableDefault(sort = "created_at", direction = Sort.Direction.DESC)
@Parameter(hidden = true) Pageable pageable) {
return BaseResponse.onSuccess(boardService.showBoardsByMemberHeartForWeb(member, hostType, boardType, keyword, pageable));
}
Expand All @@ -226,8 +222,8 @@ public BaseResponse<MyBoardPagingResponse> showMemberBoardHeartForWeb(@CurrentMe
@ApiResponse(responseCode = "BOARD002", description = "๊ฒŒ์‹œ๊ธ€์„ ์ฐพ์„ ์ˆ˜ ์—†์„ ๊ฒฝ์šฐ ๋ฐœ์ƒ")
})
@PostMapping("/{boardId}/heart")
public BaseResponse<BoardIdResponse> toggleBoardLike(@CurrentMember Member member,
@PathVariable(value = "boardId") UUID boardId) {
public BaseResponse<BoardResponse.BoardId> toggleBoardLike(@CurrentMember Member member,
@PathVariable(value = "boardId") UUID boardId) {
return BaseResponse.onSuccess(boardService.toggleBoardLike(member, boardId));
}

Expand Down
Loading

0 comments on commit d347ac1

Please sign in to comment.