From 94738d3b821a2fa42b899c48220aa8dd0413ad67 Mon Sep 17 00:00:00 2001 From: soohyun Date: Mon, 7 Oct 2024 17:25:53 +0900 Subject: [PATCH] =?UTF-8?q?[#6]=20refactor:=20=EB=AA=A8=EC=9E=84=EC=9C=A0?= =?UTF-8?q?=EC=A0=80=20=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20uri=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EB=B0=8F=20responseEntity=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/GatheringUserController.java | 35 ++++++++----------- .../controller/docs/GatheringUserApiDocs.java | 12 +++---- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/Network-Office/src/main/java/dev/office/networkoffice/gatheringUser/controller/GatheringUserController.java b/Network-Office/src/main/java/dev/office/networkoffice/gatheringUser/controller/GatheringUserController.java index 16da919..edd59a8 100644 --- a/Network-Office/src/main/java/dev/office/networkoffice/gatheringUser/controller/GatheringUserController.java +++ b/Network-Office/src/main/java/dev/office/networkoffice/gatheringUser/controller/GatheringUserController.java @@ -5,8 +5,6 @@ import dev.office.networkoffice.gatheringUser.controller.response.ApplicantUserDto; import dev.office.networkoffice.gatheringUser.service.GatheringUserService; import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.security.Principal; @@ -14,50 +12,45 @@ @RestController @RequiredArgsConstructor -@RequestMapping("/api/v1/gathering-user") +@RequestMapping("api/v1/gathering-user") public class GatheringUserController implements GatheringUserApiDocs { private final GatheringUserService gatheringUserService; - @PostMapping("/{gatheringId}") - public ResponseEntity applyGathering(Principal principal, @PathVariable(name = "gatheringId") Long gatheringId) { + @PostMapping("{gatheringId}") + public void applyGathering(Principal principal, @PathVariable(name = "gatheringId") Long gatheringId) { Long userId = findUserIdInSession(principal); gatheringUserService.applyGathering(userId, gatheringId); - return ResponseEntity.status(HttpStatus.OK).build(); } - @GetMapping("/{gatheringId}") - public ResponseEntity getApplicantsInGatheringByHost(Principal principal, @PathVariable(name = "gatheringId") Long gatheringId) { + @GetMapping("{gatheringId}") + public ApplicantUserDto getApplicantsInGatheringByHost(Principal principal, @PathVariable(name = "gatheringId") Long gatheringId) { Long userId = findUserIdInSession(principal); - return ResponseEntity.ok(gatheringUserService.readApplicantsByGathering(userId, gatheringId)); + return gatheringUserService.readApplicantsByGathering(userId, gatheringId); } - @PatchMapping("/deny") - public ResponseEntity denyApplicants(Principal principal, @RequestBody DenyUserDto denyUserDto) { + @PatchMapping("deny") + public void denyApplicants(Principal principal, @RequestBody DenyUserDto denyUserDto) { Long userId = findUserIdInSession(principal); gatheringUserService.denyApplicants(userId, denyUserDto); - return ResponseEntity.status(HttpStatus.OK).build(); } - @PatchMapping("/deports") - public ResponseEntity deportsUser(Principal principal, @RequestBody DenyUserDto denyUserDto) { + @PatchMapping("deports") + public void deportsUser(Principal principal, @RequestBody DenyUserDto denyUserDto) { Long userId = findUserIdInSession(principal); gatheringUserService.deportsUser(userId, denyUserDto); - return ResponseEntity.status(HttpStatus.OK).build(); } - @PatchMapping("/accept") - public ResponseEntity approvedApplicants(Principal principal, @PathVariable(name = "applicantId") Long applicantId) { + @PatchMapping("accept") + public void approvedApplicants(Principal principal, @PathVariable(name = "applicantId") Long applicantId) { Long userId = findUserIdInSession(principal); gatheringUserService.approvedApplicants(userId, applicantId); - return ResponseEntity.status(HttpStatus.OK).build(); } - @PatchMapping("/block") - public ResponseEntity blockUserInGathering(Principal principal, @RequestBody DenyUserDto denyUserDto) { + @PatchMapping("block") + public void blockUserInGathering(Principal principal, @RequestBody DenyUserDto denyUserDto) { Long userId = findUserIdInSession(principal); gatheringUserService.blockedUserInGathering(userId, denyUserDto); - return ResponseEntity.status(HttpStatus.OK).build(); } private Long findUserIdInSession(Principal principal){ diff --git a/Network-Office/src/main/java/dev/office/networkoffice/gatheringUser/controller/docs/GatheringUserApiDocs.java b/Network-Office/src/main/java/dev/office/networkoffice/gatheringUser/controller/docs/GatheringUserApiDocs.java index a21daaa..eb88a14 100644 --- a/Network-Office/src/main/java/dev/office/networkoffice/gatheringUser/controller/docs/GatheringUserApiDocs.java +++ b/Network-Office/src/main/java/dev/office/networkoffice/gatheringUser/controller/docs/GatheringUserApiDocs.java @@ -25,7 +25,7 @@ public interface GatheringUserApiDocs { description = "유효하지 않은 코드가 전달되었을 때" ) }) - ResponseEntity applyGathering(Principal principal, @PathVariable(name = "gatheringId") Long gatheringId); + void applyGathering(Principal principal, @PathVariable(name = "gatheringId") Long gatheringId); @Operation(summary = "모임 신청 목록 조회") @ApiResponses(value = { @@ -38,7 +38,7 @@ public interface GatheringUserApiDocs { description = "유효하지 않은 코드가 전달되었을 때" ) }) - ResponseEntity getApplicantsInGatheringByHost(Principal principal, @PathVariable(name = "gatheringId") Long gatheringId); + ApplicantUserDto getApplicantsInGatheringByHost(Principal principal, @PathVariable(name = "gatheringId") Long gatheringId); @Operation(summary = "모임 거절") @ApiResponses(value = { @@ -51,7 +51,7 @@ public interface GatheringUserApiDocs { description = "유효하지 않은 코드가 전달되었을 때" ) }) - ResponseEntity denyApplicants(Principal principal, @RequestBody DenyUserDto denyUserDto); + void denyApplicants(Principal principal, @RequestBody DenyUserDto denyUserDto); @Operation(summary = "모임 추방") @ApiResponses(value = { @@ -64,7 +64,7 @@ public interface GatheringUserApiDocs { description = "유효하지 않은 코드가 전달되었을 때" ) }) - ResponseEntity deportsUser(Principal principal, @RequestBody DenyUserDto denyUserDto); + void deportsUser(Principal principal, @RequestBody DenyUserDto denyUserDto); @Operation(summary = "모임 신청 수락") @ApiResponses(value = { @@ -77,7 +77,7 @@ public interface GatheringUserApiDocs { description = "유효하지 않은 코드가 전달되었을 때" ) }) - ResponseEntity approvedApplicants(Principal principal, @PathVariable(name = "applicantId") Long applicantId); + void approvedApplicants(Principal principal, @PathVariable(name = "applicantId") Long applicantId); @Operation(summary = "모임에 해당 유저 차단") @ApiResponses(value = { @@ -90,6 +90,6 @@ public interface GatheringUserApiDocs { description = "유효하지 않은 코드가 전달되었을 때" ) }) - ResponseEntity blockUserInGathering(Principal principal, @RequestBody DenyUserDto denyUserDto); + void blockUserInGathering(Principal principal, @RequestBody DenyUserDto denyUserDto); }